Rearrange use of plpgsql_add_initdatums() so that only the parsing of a

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 6eb61d578f3c9fc4fff78d69851b7558821668e3
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2007-02-08T18:38:28Z
Releases: 7.3.19
Rearrange use of plpgsql_add_initdatums() so that only the parsing of a
DECLARE section needs to know about it.  Formerly, everyplace besides DECLARE
that created variables needed to do "plpgsql_add_initdatums(NULL)" to prevent
those variables from being sucked up as part of a subsequent DECLARE block.
This is obviously error-prone, and in fact the SQLSTATE/SQLERRM patch had
failed to do it for those two variables, leading to the bug recently exhibited
by Asif Ali Rehman: a DECLARE within an exception handler tried to reinitialize
SQLERRM.

Although the SQLSTATE/SQLERRM patch isn't in any pre-8.1 branches, and so
I can't point to a demonstrable failure there, it seems wise to back-patch
this into the older branches anyway, just to keep the logic similar to HEAD.

Files

PathChange+/−
src/pl/plpgsql/src/gram.y modified +5 −5
src/pl/plpgsql/src/pl_comp.c modified +13 −12