pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix assorted bugs in ecpg's macro mechanism.
8+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2024-04-19 dd3fddc851 f7e8917481 de84608e26 c6bfeab42b cd26f08e47 Fix MSVC recipe for ecpg regression tests, redux.
2024-04-19 61dd815e0b 1e7b1b026d 0018f0af5a df66319f77 481597fc6c Fix MSVC recipe for ecpg regression tests.
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/4631646391ec105c54ee3ed27211ae85d2f2a3d6
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
11 files changed, 288 insertions(+), 80 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2b6a74afe17045d3f3c02330ec0331af7782c5e6
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
11 files changed, 288 insertions(+), 80 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/392e6e9e6adab1af013b16158dc3aec0dc3739d0
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/meson.build | 3 +-
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
src/interfaces/ecpg/test/sql/meson.build | 1 +
13 files changed, 291 insertions(+), 81 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/25f937217200740d800113953c375691e985f2d3
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
11 files changed, 288 insertions(+), 80 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/02531e8ca8dc37a82b35fb6e068db291088eca37
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
11 files changed, 288 insertions(+), 80 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-16 16:31 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-16 16:31 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix assorted bugs in ecpg's macro mechanism.
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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6f0cef9353fcef50e74c31bb06c96c40207fd535
Modified Files
--------------
doc/src/sgml/ecpg.sgml | 8 ++
doc/src/sgml/ref/ecpg-ref.sgml | 6 +-
src/interfaces/ecpg/preproc/ecpg.c | 79 +++++++------
src/interfaces/ecpg/preproc/pgc.l | 127 +++++++++++++++------
src/interfaces/ecpg/preproc/type.h | 22 +++-
src/interfaces/ecpg/test/expected/sql-define.c | 65 ++++++++++-
.../ecpg/test/expected/sql-define.stderr | 24 ++++
.../ecpg/test/expected/sql-define.stdout | 3 +
src/interfaces/ecpg/test/sql/Makefile | 3 +
src/interfaces/ecpg/test/sql/define.pgc | 25 ++++
src/interfaces/ecpg/test/sql/define_prelim.pgc | 6 +
src/interfaces/ecpg/test/sql/meson.build | 1 +
12 files changed, 289 insertions(+), 80 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-18 22:55 Andrew Dunstan <andrew@dunslane.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Dunstan @ 2024-04-18 22:55 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-committers@lists.postgresql.org
On 2024-04-16 Tu 12:31, Tom Lane wrote:
> Fix assorted bugs in ecpg's macro mechanism.
>
Buildfarm animals running the old MSVC build system don't like this.
It looks to me like we'll need an adjustment in
src/tools/msvc/ecpg_regression.proj to replicate the special rules
surrounding define.c and define_prelim.c. Not sure who has the requisite
knowledge to do that - I don't.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix assorted bugs in ecpg's macro mechanism.
@ 2024-04-18 23:46 Tom Lane <tgl@sss.pgh.pa.us>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2024-04-18 23:46 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers@lists.postgresql.org
Andrew Dunstan <andrew@dunslane.net> writes:
> On 2024-04-16 Tu 12:31, Tom Lane wrote:
>> Fix assorted bugs in ecpg's macro mechanism.
> Buildfarm animals running the old MSVC build system don't like this.
Oh, duh, I'd already forgotten about that...
> It looks to me like we'll need an adjustment in
> src/tools/msvc/ecpg_regression.proj to replicate the special rules
> surrounding define.c and define_prelim.c. Not sure who has the requisite
> knowledge to do that - I don't.
I will see if I can fix it.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2024-04-18 23:46 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-18 22:55 ` Andrew Dunstan <andrew@dunslane.net>
2024-04-18 23:46 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 16:31 pgsql: Fix assorted bugs in ecpg's macro mechanism. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox