]> granicus.if.org Git - postgresql/commit
Second try at fixing numeric data passed through an ECPG SQLDA.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Nov 2018 16:27:30 +0000 (11:27 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Nov 2018 16:27:30 +0000 (11:27 -0500)
commit4618fdd674128ad62096619d449f248b0ecc3ed7
tree81389bdd7010dfba4339d2c757d3c917288a23f2
parent464dc037ffe7496040fe783a4447c5ce09864100
Second try at fixing numeric data passed through an ECPG SQLDA.

In commit ecfd55795, I removed sqlda.c's checks for ndigits != 0 on the
grounds that we should duplicate the state of the numeric value's digit
buffer even when all the digits are zeroes.  However, that still isn't
quite right, because another possible state of the digit buffer is
buf == digits == NULL (this occurs for a NaN).  As the code now stands,
it'll invoke memcpy with a NULL source address and zero bytecount,
which we know a few platforms crash on.  Hence, reinstate the no-copy
short-circuit, but make it test specifically for buf != NULL rather than
some other condition.  In hindsight, the ndigits test (added by commit
f2ae9f9c3) was almost certainly meant to fix the NaN case not the
all-zeroes case as the associated thread alleged.

As before, back-patch to all supported versions.

Discussion: https://postgr.es/m/1803D792815FC24D871C00D17AE95905C71161@g01jpexmbkw24
src/interfaces/ecpg/ecpglib/sqlda.c
src/interfaces/ecpg/test/expected/sql-sqlda.c
src/interfaces/ecpg/test/expected/sql-sqlda.stderr
src/interfaces/ecpg/test/expected/sql-sqlda.stdout
src/interfaces/ecpg/test/sql/sqlda.pgc