Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNin9-0002q3-Hs for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2017 17:19:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNin9-0002O6-5l for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Dec 2017 17:19:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eNin8-0002Nx-Vk for pgsql-hackers@lists.postgresql.org; Sat, 09 Dec 2017 17:19:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eNin2-0004IX-4m for pgsql-hackers@lists.postgresql.org; Sat, 09 Dec 2017 17:19:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vB9HJn8Q000772; Sat, 9 Dec 2017 12:19:49 -0500 From: Tom Lane To: Pavel Stehule cc: pgsql-hackers@lists.postgresql.org Subject: Re: plpgsql fails to reinitialize record variables at block re-entry In-reply-to: References: <22994.1512800671@sss.pgh.pa.us> Comments: In-reply-to Pavel Stehule message dated "Sat, 09 Dec 2017 07:47:29 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <770.1512839989.1@sss.pgh.pa.us> Date: Sat, 09 Dec 2017 12:19:49 -0500 Message-ID: <771.1512839989@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavel Stehule writes: > 2017-12-09 7:24 GMT+01:00 Tom Lane : >> Surely that ought to have failed at the i=2 iteration. There is >> code in plpgsql's exec_stmt_block() that tries to reinitialize >> PLPGSQL_DTYPE_REC variables, but it's never reached (as a quick >> look at coverage.postgresql.org will confirm), because what it >> scans is only the variables attached to the block by >> plpgsql_add_initdatums() --- and that function thinks it should >> only pay attention to PLPGSQL_DTYPE_VAR variables. > +1 Pushed. Some excavation in our git history says this bug has been there since the initial commit of plpgsql, making it a little over 19 years old. Might be a new record for the age of a PG bug. regards, tom lane