X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A9DD3A4160 for ; Mon, 25 Oct 2004 20:45:08 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42841-04 for ; Mon, 25 Oct 2004 19:44:57 +0000 (GMT) Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) by svr1.postgresql.org (Postfix) with ESMTP id E70743A3AC2 for ; Mon, 25 Oct 2004 20:44:58 +0100 (BST) Received: from localhost (morework [127.0.0.1]) by morework.geizhals.at (Postfix) with ESMTP id 2626FDF07C for ; Mon, 25 Oct 2004 21:44:55 +0200 (CEST) Received: from [127.0.0.1] (chello080110242194.117.11.tuwien.teleweb.at [80.110.242.194]) by morework.geizhals.at (Postfix) with ESMTP for ; Mon, 25 Oct 2004 21:44:55 +0200 (CEST) Message-ID: <417D57B1.8010507@geizhals.at> Date: Mon, 25 Oct 2004 21:44:49 +0200 From: Marinos Yannikos User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: plpgsql: PERFORM vs. SELECT INTO (PERFORM not setting FOUND variable?) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 at geizhals.at X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/182 X-Sequence-Number: 19285 Hi, I'm probably misintepreting the documented equivalence of PERFORM and SELECT INTO as far as the special variable FOUND is concerned, but the following 2 definitions do not seem to produce the same result. create table blup ( t1 text, t2 text ); create function blup_unique2 (text,text) returns boolean as 'begin perform (select 1 from blup where t1=$1 or t1=$2 or t2=$1 or t2=$2 or $1=$2 limit 1); return NOT FOUND; end' LANGUAGE plpgsql; create function blup_unique3 (text,text) returns boolean as 'declare x record; begin select into x 1 from blup where t1=$1 or t1=$2 or t2=$1 or t2=$2 or $1=$2 limit 1; return NOT FOUND; end' LANGUAGE plpgsql; The first will always produce false, i.e. apparently the subquery used by PERFORM will not set the variable FOUND as expected. Is this correct? (btw.: I'm trying a few ways to ensure that all values in both t1 and t2 are unique: alter table blup add constraint check (blup_unique3(t1,t2)); - perhaps there are more elegant ways, any suggestions?) Regards, Marinos