Re: BUG #19925: ECPG inserts host variables unquoted in EXECUTE name(...)

From: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19925: ECPG inserts host variables unquoted in EXECUTE name(...)
Date: 2026-11-21 07:02:15
Message-ID: CA+Y2BmdN7GtrUE2LYJFLGHgMFVAwf4VTxX_rp3EMAp1bOhhzMQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

Here are the patches for the report above.

v1-0001 is the NULL fix from CF 7664, unchanged from
https://postgr.es/m/CA+Y2BmfP8hkBFEK2awoAp0uobYXHmQC-C9iAZ7qs2OPfVtEQ5w@mail.gmail.com
It's included only so the series applies on master.

v1-0002 fixes the placeholder handling, for REL_15 .. master. The new
tests in prepareas.pgc pass a bytea value and the quoted literals 'cd',
'x$2' and 'a?b', each followed by an int, and an 11-value list. Without
the fix, only one of the four rows is stored, and with only the
placeholder length put back, the 11-value row is stored wrong.

v1-0003 is the docs note, for REL_15 .. master; on master, 0004 then
replaces its text. I built the docs with it on REL_15 and REL_19, and
on master with the whole series.

v1-0004 is the quoting change, for master only. The tests cover a value
containing SQL text, a value with a quote, and boolean, date and NaN
values.

On master with these patches, make -C src/interfaces/ecpg check passes
and the docs build. Without the code changes, the new tests fail. 0002
and 0003 apply unchanged to REL_15 .. REL_19 on top of the NULL fix for
each branch (the REL_15 .. 18 version is on the NULL fix thread), and
with them the ECPG tests pass on REL_15 and REL_19.

I also ran a small program against the patched library: plain strings,
quotes, booleans, dates, timestamps, intervals, NaN and Infinity are
stored as given, and numbers convert the same way as with USING. A value
the program already quoted, like 'O''Brien', is now stored with its
quotes. That and the number cases in the report are the compatibility
changes, so they would need a release note.

Attachment Content-Type Size
v1-0001-ecpg-Fix-crash-on-a-NULL-value-in-EXECUTE-with-a-.patch application/octet-stream 29.0 KB
v1-0002-ecpg-Fix-placeholder-handling-in-EXECUTE-name.patch application/octet-stream 13.6 KB
v1-0003-doc-Explain-how-ECPG-inserts-host-variables-into-.patch application/octet-stream 4.4 KB
v1-0004-ecpg-Quote-host-variable-values-in-EXECUTE-name.patch application/octet-stream 23.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Raja Sai pranav 2026-11-21 07:05:57 Re: BUG #19881: CLUSTER uses a disabled sort path when enable_sort is off
Previous Message Fujii Masao 2026-11-21 06:54:31 Re: BUG #19881: CLUSTER uses a disabled sort path when enable_sort is off