diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-09 15:34:04 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-09 15:34:04 -0400 |
commit | b7050e2584803a6abe71fb0b94a63b63e59cff9c (patch) | |
tree | b4b1735e900c73c643c31bb131a52d6d8269d051 /src/interfaces/ecpg/test/preproc/variable.pgc | |
parent | f734857a9211afcd4fc068dfa322642b6be99b87 (diff) | |
download | postgresql-b7050e2584803a6abe71fb0b94a63b63e59cff9c.tar.gz postgresql-b7050e2584803a6abe71fb0b94a63b63e59cff9c.zip |
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
Diffstat (limited to 'src/interfaces/ecpg/test/preproc/variable.pgc')
-rw-r--r-- | src/interfaces/ecpg/test/preproc/variable.pgc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/preproc/variable.pgc b/src/interfaces/ecpg/test/preproc/variable.pgc index 423a01c16e2..032c2fe57b8 100644 --- a/src/interfaces/ecpg/test/preproc/variable.pgc +++ b/src/interfaces/ecpg/test/preproc/variable.pgc @@ -30,6 +30,8 @@ exec sql begin declare section; } ind_personal, *i; ind ind_children; struct t1 { str name; }; struct t2 { str name; }; + static varchar vc1[50], vc2[50], vc3[255]; + static int i1, i2, i3; exec sql end declare section; exec sql char *married = NULL; @@ -97,5 +99,12 @@ exec sql end declare section; strcpy(msg, "disconnect"); exec sql disconnect; + /* this just to silence unused-variable warnings: */ + vc1.len = vc2.len = vc3.len = 0; + i1 = i2 = i3 = 0; + printf("%d %d %d %d %d %d\n", + vc1.len, vc2.len, vc3.len, + i1, i2, i3); + return 0; } |