Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id DD7094248 for ; Thu, 22 Mar 2012 14:57:20 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SAmGB-00067X-UN for pgsql-bugs@postgresql.org; Thu, 22 Mar 2012 17:57:18 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q2MHv25m010778; Thu, 22 Mar 2012 13:57:02 -0400 (EDT) To: aburacze@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter In-reply-to: References: Comments: In-reply-to aburacze@gmail.com message dated "Thu, 22 Mar 2012 17:38:00 -0000" Date: Thu, 22 Mar 2012 13:57:02 -0400 Message-ID: <10777.1332439022@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/164 X-Sequence-Number: 32725 aburacze@gmail.com writes: > I have just found strange behaviour of PL/pgSQL in case of using OUT > parameters and GET DIAGNOSTICS var = ROW_COUNT (PostgreSQL 9.1.3). Here is a > self-contained example: Wow, that's been broken since the beginning, apparently. There's an entirely bogus test in exec_stmt_getdiag(): if (diag_item->target <= 0) continue; It's not clear what the point of this is, since there is no case in which the target variable should be invalid, but in any case the effect is to ignore attempts to assign to any variable with dno zero --- which will be the one first defined in the function, eg the first parameter if any. I guess I can see how this escaped detection for a long time, but it's broken for sure. Thanks for the report! regards, tom lane