mirror of
https://github.com/postgres/postgres.git
synced 2026-04-14 13:37:39 -04:00
The code associated with EXEC SQL DEFINE was unreadable and full of bugs, notably: * It'd attempt to free a non-malloced string if the ecpg program tries to redefine a macro that was defined on the command line. * Possible memory stomp if user writes "-D=foo". * Undef'ing or redefining a macro defined on the command line would change the state visible to the next file, when multiple files are specified on the command line. (While possibly that could have been an intentional choice, the code clearly intends to revert to the original macro state; it's just failing to consider this interaction.) * Missing "break" in defining a new macro meant that redefinition of an existing name would cause an extra entry to be added to the definition list. While not immediately harmful, a subsequent undef would result in the prior entry becoming visible again. * The interactions with input buffering are subtle and were entirely undocumented. It's not that surprising that we hadn't noticed these bugs, because there was no test coverage at all of either the -D command line switch or multiple input files. This patch adds such coverage (in a rather hacky way I guess). In addition to the code bugs, the user documentation was confused about whether the -D switch defines a C macro or an ecpg one, and it failed to mention that you can write "-Dsymbol=value". These problems are old, so back-patch to all supported branches. Discussion: https://postgr.es/m/998011.1713217712@sss.pgh.pa.us
76 lines
4.3 KiB
Text
76 lines
4.3 KiB
Text
[NO_PID]: ECPGdebug: set to 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 19: query: create table test ( a int , b text ); with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 19: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 19: OK: CREATE TABLE
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 20: query: insert into test values ( 29 , 'abcdef' ); with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 20: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 20: OK: INSERT 0 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 23: query: insert into test values ( null , 'defined' ); with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 23: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 23: OK: INSERT 0 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 31: query: insert into test values ( null , 'someothervar not defined' ); with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 31: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 36: query: select 1 , 29 :: text || '-' || 'abcdef'; with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 36: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 36: correctly got 1 tuples with 2 fields
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_get_data on line 36: RESULT: 1 offset: -1; array: no
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_get_data on line 36: RESULT: 29-abcdef offset: -1; array: no
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 42: query: insert into test values ( 29 , 'no string' ); with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 42: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 42: OK: INSERT 0 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 53: query: set TIMEZONE to 'UTC'; with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 53: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 53: OK: SET
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 57: query: select 123; with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 57: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 57: correctly got 1 tuples with 1 fields
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_get_data on line 57: RESULT: 123 offset: -1; array: no
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 62: query: select 42; with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 62: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 62: correctly got 1 tuples with 1 fields
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_get_data on line 62: RESULT: 42 offset: -1; array: no
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 67: query: select 43; with 0 parameter(s) on connection ecpg1_regression
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 67: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 67: correctly got 1 tuples with 1 fields
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_get_data on line 67: RESULT: 43 offset: -1; array: no
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_finish: connection ecpg1_regression closed
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|