Fix possible omission of variable storage markers in ECPG.
authorTom Lane <[email protected]>
Fri, 9 Sep 2022 19:34:04 +0000 (15:34 -0400)
committerTom Lane <[email protected]>
Fri, 9 Sep 2022 19:34:04 +0000 (15:34 -0400)
commitfbb54d742ac888370e3221c556c5f336a1f4e888
tree7db359ddae57fb8e0bc6e24b1672a14ee8e6c806
parente0636ca90b819d7ca2e6e6dd35cf84d7032d473b
Fix possible omission of variable storage markers in ECPG.

The ECPG preprocessor converted code such as

static varchar str1[10], str2[20], str3[30];

into

static  struct varchar_1  { int len; char arr[ 10 ]; }  str1 ;
        struct varchar_2  { int len; char arr[ 20 ]; }  str2 ;
        struct varchar_3  { int len; char arr[ 30 ]; }  str3 ;

thus losing the storage attribute for the later variables.
Repeat the declaration for each such variable.

(Note that this occurred only for variables declared "varchar"
or "bytea", which may help explain how it escaped detection
for so long.)

Andrey Sokolov

Discussion: https://postgr.es/m/942241662288242@mail.yandex.ru
src/interfaces/ecpg/preproc/ecpg.trailer
src/interfaces/ecpg/preproc/type.h
src/interfaces/ecpg/test/expected/preproc-variable.c
src/interfaces/ecpg/test/expected/preproc-variable.stderr
src/interfaces/ecpg/test/expected/preproc-variable.stdout
src/interfaces/ecpg/test/preproc/variable.pgc