pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@gmail.com>
To: Joe Van Dyk <joe@tanga.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: plpgsql plan caching allowing invalid data to enter table?
Date: Tue, 09 Jul 2013 16:29:06 -0700
Message-ID: <51DC9CC2.1020709@gmail.com> (raw)
In-Reply-To: <CACfv+pJUbc5Kg7HQ-xSpw_HDhExZWOWhff0pVyADb24bkokaaQ@mail.gmail.com>
References: <CACfv+pJUbc5Kg7HQ-xSpw_HDhExZWOWhff0pVyADb24bkokaaQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

On 07/09/2013 04:05 PM, Joe Van Dyk wrote:
> It's looking like I can use a plpgsql function to insert data into a
> table that violates a domain constraint. Is this a known problem?
>
> Session 1:
>
> create domain my_domain text check (length(value) > 2);
> create table my_table (name my_domain);
>
> create function f(text) returns void as $$
> declare my_var my_domain := $1;
> begin
>     insert into my_table values (my_var);
> end $$ language plpgsql;
>
> Session 2:
> select f('test');
> delete from my_table;
> -- Keep session open!
>
> Session 1:
> alter domain my_domain drop constraint my_domain_check;
> alter domain my_domain add constraint my_domain_check check
> (length(value) > 5);
>
> Session 2:
> select f('test');
> -- This works, but it should fail.
> -- I have a constraint of more than 5 characters on the domain.
> -- But I can insert a row with 4 characters.

My guess this has more to do with MVCC. Session 1 and 2 are looking at 
different snapshots of the database and acting accordingly.

-- 
Adrian Klaver
adrian.klaver@gmail.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (6+ messages)  latest in thread

Message-ID: <51DC9CC2.1020709@gmail.com>
Permalink:  ../51DC9CC2.1020709@gmail.com/
Also on:    postgresql.org/message-id/51DC9CC2.1020709@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: adrian.klaver@gmail.com, joe@tanga.com, pgsql-general@postgresql.org
  Subject: Re: plpgsql plan caching allowing invalid data to enter table?
  In-Reply-To: <51DC9CC2.1020709@gmail.com>
  References: <CACfv+pJUbc5Kg7HQ-xSpw_HDhExZWOWhff0pVyADb24bkokaaQ@mail.gmail.com> <51DC9CC2.1020709@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox