Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UwhLR-0007EH-Nc for pgsql-general@arkaria.postgresql.org; Tue, 09 Jul 2013 23:29:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UwhLQ-0008GA-Q1 for pgsql-general@arkaria.postgresql.org; Tue, 09 Jul 2013 23:29:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UwhLP-0008G3-IV for pgsql-general@postgresql.org; Tue, 09 Jul 2013 23:29:15 +0000 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UwhLK-0002at-AR for pgsql-general@postgresql.org; Tue, 09 Jul 2013 23:29:13 +0000 Received: by mail-pa0-f43.google.com with SMTP id hz11so6020741pad.30 for ; Tue, 09 Jul 2013 16:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=yq16Qe5MoFi9c/x0u1dUcFr8y6IxdPfkAKvRjBWgur0=; b=vP2z3x9wR3/qtKAed1oy2NTjvSXmPqzER/sjDmVGkaOoW2sVYyexrFAkeS+TI5hHPI WffLeWv+8qs82JkCn4qq8fAFwuXkdmAFB80Z9jI9aRyqVUzz8+tIGn5k3JdtSUeJhyyH KXwUkokbJ5VkUZqBW8zxCW5xi4MqiP/YpLe1r36rhNUY6YWqhPaQ79dTrZMgVjkKXzX6 NB/8SzqMmwpXDyX8sUMbEGJwTLInxzSLUdXDi5YCAU62j3XpTdoiT2X7wOOGq63rbas0 BeeF5Ny/u5erLX+roZnx/nfPTfy5ifFmkJIH+OZLHBfUJCM68glxgoSksOAvqD2GI2Wn 6Qew== X-Received: by 10.68.212.229 with SMTP id nn5mr28761220pbc.44.1373412548797; Tue, 09 Jul 2013 16:29:08 -0700 (PDT) Received: from [192.168.1.2] (174-21-183-190.tukw.qwest.net. [174.21.183.190]) by mx.google.com with ESMTPSA id ry2sm30374538pbc.41.2013.07.09.16.29.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jul 2013 16:29:08 -0700 (PDT) Message-ID: <51DC9CC2.1020709@gmail.com> Date: Tue, 09 Jul 2013 16:29:06 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Joe Van Dyk CC: "pgsql-general@postgresql.org" Subject: Re: plpgsql plan caching allowing invalid data to enter table? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org 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