postgresql/contrib/tablefunc
Tom Lane dc9a506e68 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 08c33c426b 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
2015-01-29 20:18:46 -05:00
..
data Have crosstab variants treat NULL rowid as a category in its own right, 2007-11-10 05:00:41 +00:00
expected Handle unexpected query results, especially NULLs, safely in connectby(). 2015-01-29 20:18:46 -05:00
sql Handle unexpected query results, especially NULLs, safely in connectby(). 2015-01-29 20:18:46 -05:00
.gitignore Some more gitignore cleanups: cover contrib and PL regression test outputs. 2010-09-22 17:22:53 -04:00
Makefile Fix a few single-file (MODULES, not MODULE_big) contrib makefiles that were 2010-07-05 23:15:56 +00:00
tablefunc.c Handle unexpected query results, especially NULLs, safely in connectby(). 2015-01-29 20:18:46 -05:00
tablefunc.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
tablefunc.sql.in Add CVS version labels to all install/uninstall scripts. 2007-11-13 04:24:29 +00:00
uninstall_tablefunc.sql Add CVS version labels to all install/uninstall scripts. 2007-11-13 04:24:29 +00:00