pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Handle unexpected query results, especially NULLs, safely in con 6+ messages / 1 participants [nested] [flat]
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/37507962c3d2123b0f21c50d6172fd0b1e059fe7 Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 32 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 +++ contrib/tablefunc/tablefunc.c | 163 +++++++++++++++++------------- 3 files changed, 138 insertions(+), 73 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/202621d0471b56c3355af1f2134cf868a6f9b4bd Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 31 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 ++++ contrib/tablefunc/tablefunc.c | 152 ++++++++++++++---------------- 3 files changed, 116 insertions(+), 83 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/53ae2469233a7b017407ac11851aa27c3c294f0f Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 31 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 ++++ contrib/tablefunc/tablefunc.c | 152 ++++++++++++++---------------- 3 files changed, 116 insertions(+), 83 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/66cc746809057601fee992f3ddb85ea7eabd7f4a Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 31 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 ++++ contrib/tablefunc/tablefunc.c | 152 ++++++++++++++---------------- 3 files changed, 116 insertions(+), 83 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/290c2daad947c8493782055fd71896af7b7d1d8e Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 31 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 ++++ contrib/tablefunc/tablefunc.c | 152 ++++++++++++++---------------- 3 files changed, 116 insertions(+), 83 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Handle unexpected query results, especially NULLs, safely in con @ 2015-01-30 01:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2015-01-30 01:19 UTC (permalink / raw) To: pgsql-committers Handle unexpected query results, especially NULLs, safely in connectby(). connectby() didn't adequately check that the constructed SQL query returns what it's expected to; in fact, since commit 08c33c426bfebb32 it wasn't checking that at all. This could result in a null-pointer-dereference crash if the constructed query returns only one column instead of the expected two. Less excitingly, it could also result in surprising data conversion failures if the constructed query returned values that were not I/O-conversion-compatible with the types specified by the query calling connectby(). In all branches, insist that the query return at least two columns; this seems like a minimal sanity check that can't break any reasonable use-cases. In HEAD, insist that the constructed query return the types specified by the outer query, including checking for typmod incompatibility, which the code never did even before it got broken. This is to hide the fact that the implementation does a conversion to text and back; someday we might want to improve that. In back branches, leave that alone, since adding a type check in a minor release is more likely to break things than make people happy. Type inconsistencies will continue to work so long as the actual type and declared type are I/O representation compatible, and otherwise will fail the same way they used to. Also, in all branches, be on guard for NULL results from the constructed query, which formerly would cause null-pointer dereference crashes. We now print the row with the NULL but don't recurse down from it. In passing, get rid of the rather pointless idea that build_tuplestore_recursively() should return the same tuplestore that's passed to it. Michael Paquier, adjusted somewhat by me Branch ------ REL9_0_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/dc9a506e68f7d2e5a3c23fadb6143c03f99ecee1 Modified Files -------------- contrib/tablefunc/expected/tablefunc.out | 31 ++++++ contrib/tablefunc/sql/tablefunc.sql | 16 ++++ contrib/tablefunc/tablefunc.c | 152 ++++++++++++++---------------- 3 files changed, 116 insertions(+), 83 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2015-01-30 01:19 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con Tom Lane <tgl@sss.pgh.pa.us> 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con Tom Lane <tgl@sss.pgh.pa.us> 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con Tom Lane <tgl@sss.pgh.pa.us> 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con Tom Lane <tgl@sss.pgh.pa.us> 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con Tom Lane <tgl@sss.pgh.pa.us> 2015-01-30 01:19 pgsql: Handle unexpected query results, especially NULLs, safely in con 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