Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 72A8AEEA155 for ; Wed, 14 Dec 2011 06:32:24 -0400 (AST) Received: from mail-ee0-f46.google.com ([74.125.83.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ram8L-0007gI-0u for pgsql-hackers@postgresql.org; Wed, 14 Dec 2011 10:32:25 +0000 Received: by eekc4 with SMTP id c4so605286eek.19 for ; Wed, 14 Dec 2011 02:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=vDVaJVYnKUDac4+BeHk5sdx+jny+iNEhrC3prx9W1Ys=; b=gDty1smJ10LgdKdkAfRKjCf3KVBRqVYDSq8xmGG7ceHfq/eoU/Vg2HAkLGG4fq6+wy Cu7tbjz3pTzhhkw2b0WaTFXVkRSTvt2TFZ4CrIY7qFjEnEEPZNt/xeAOkZnMEnqMzcQB p1HirqWMiox1VwXMSEgqUc3w1G/WcVr/JC2sk= Received: by 10.213.27.17 with SMTP id g17mr491104ebc.33.1323858728194; Wed, 14 Dec 2011 02:32:08 -0800 (PST) Received: from [192.168.73.63] (5357DA75.cm-6-8d.dynamic.ziggo.nl. [83.87.218.117]) by mx.google.com with ESMTPS id 39sm1398785eei.1.2011.12.14.02.32.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Dec 2011 02:32:06 -0800 (PST) Message-ID: <4EE87B1B.7070609@gmail.com> Date: Wed, 14 Dec 2011 11:31:55 +0100 From: Yeb Havinga User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Tom Lane CC: Heikki Linnakangas , Kevin Grittner , pgsql-hackers@postgresql.org Subject: Re: [REVIEW] Patch for cursor calling with named parameters References: <4EE607B90200002500043C0F@gw.wicourts.gov> <4EE77BB5.5040906@enterprisedb.com> <627.1323797659@sss.pgh.pa.us> In-Reply-To: <627.1323797659@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/620 X-Sequence-Number: 199872 On 2011-12-13 18:34, Tom Lane wrote: > Heikki Linnakangas writes: >> Attached is a patch with those changes. I also I removed a few of the >> syntax error regression tests, that seemed excessive, plus some general >> naming and comment fiddling. I'll apply this tomorrow, if it still looks >> good to me after sleeping on it. > However, I'm still concerned about whether this approach gives > reasonable error messages in cases where the error would be > detected during parse analysis of the rearranged statement. > The regression test examples don't cover such cases, and I'm > too busy right now to apply the patch and check for myself. > What happens for example if a named parameter's value contains > a misspelled variable reference, or a type conflict? I tested this and seems to be ok: regression=# select namedparmcursor_test1(20000, 20000) as "Should be false", namedparmcursor_test1(20, 20) as "Should be true"; ERROR: column "yy" does not exist LINE 1: SELECT x AS param1, yy AS param12; regression=# select namedparmcursor_test1(20000, 20000) as "Should be false", namedparmcursor_test1(20, 20) as "Should be true"; ERROR: invalid input syntax for integer: "2011-11-29 19:26:10.029084" CONTEXT: PL/pgSQL function "namedparmcursor_test1" line 8 at OPEN regards, Yeb Havinga last error was created with create or replace function namedparmcursor_test1(int, int) returns boolean as $$ declare c1 cursor (param1 int, param12 int) for select * from rc_test where a > param1 and b > param12; y int := 10; x timestamp := now(); nonsense record; begin open c1(param12 := $1, param1 := x); end $$ language plpgsql;