postgresql/src/include
Tom Lane 166d534fcd Repair bugs in GiST page splitting code for multi-column indexes.
When considering a non-last column in a multi-column GiST index,
gistsplit.c tries to improve on the split chosen by the opclass-specific
pickSplit function by considering penalties for the next column.  However,
there were two bugs in this code: it failed to recompute the union keys for
the leftmost index columns, even though these might well change after
reassigning tuples; and it included the old union keys in the recomputation
for the columns it did recompute, so that those keys couldn't get smaller
even if they should.  The first problem could result in an invalid index
in which searches wouldn't find index entries that are in fact present;
the second would make the index less efficient to search.

Both of these errors were caused by misuse of gistMakeUnionItVec, whose
API was designed in a way that just begged such errors to be made.  There
is no situation in which it's safe or useful to compute the union keys for
a subset of the index columns, and there is no caller that wants any
previous union keys to be included in the computation; so the undocumented
choice to treat the union keys as in/out rather than pure output parameters
is a waste of code as well as being dangerous.

Hence, rather than just making a minimal patch, I've changed the API of
gistMakeUnionItVec to remove the "startkey" parameter (it now always
processes all index columns) and treat the attr/isnull arrays as purely
output parameters.

In passing, also get rid of a couple of unnecessary and dangerous uses
of static variables in gistutil.c.  It's remarkable that the one in
gistMakeUnionKey hasn't given us portability troubles before now, because
in addition to posing a re-entrancy hazard, it was unsafely assuming that
a static char[] array would have at least Datum alignment.

Per investigation of a trouble report from Tomas Vondra.  (There are also
some bugs in contrib/btree_gist to be fixed, but that seems like material
for a separate patch.)  Back-patch to all supported branches.
2013-02-07 17:44:02 -05:00
..
access Repair bugs in GiST page splitting code for multi-column indexes. 2013-02-07 17:44:02 -05:00
bootstrap Update copyrights for 2013 2013-01-01 17:15:01 -05:00
catalog Fast promote mode skips checkpoint at end of recovery. 2013-01-29 00:06:15 +00:00
commands Improve concurrency of foreign key locking 2013-01-23 12:04:59 -03:00
datatype Update copyrights for 2013 2013-01-01 17:15:01 -05:00
executor Fix plpgsql's reporting of plan-time errors in possibly-simple expressions. 2013-01-30 20:02:23 -05:00
foreign Update copyrights for 2013 2013-01-01 17:15:01 -05:00
lib Update copyrights for 2013 2013-01-01 17:15:01 -05:00
libpq Update copyrights for 2013 2013-01-01 17:15:01 -05:00
mb Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodes Improve concurrency of foreign key locking 2013-01-23 12:04:59 -03:00
optimizer Update copyrights for 2013 2013-01-01 17:15:01 -05:00
parser Improve concurrency of foreign key locking 2013-01-23 12:04:59 -03:00
port Add URLs to document why DLLIMPORT is needed on Windows. 2012-11-07 15:01:25 -05:00
portability Update copyrights for 2013 2013-01-01 17:15:01 -05:00
postmaster Fix background workers for EXEC_BACKEND 2013-01-02 12:01:14 -03:00
regex Re-implement extraction of fixed prefixes from regular expressions. 2012-07-10 14:54:37 -04:00
replication Fix more issues with cascading replication and timeline switches. 2013-01-23 10:19:20 +02:00
rewrite Update copyrights for 2013 2013-01-01 17:15:01 -05:00
snowball Update copyrights for 2013 2013-01-01 17:15:01 -05:00
storage Improve concurrency of foreign key locking 2013-01-23 12:04:59 -03:00
tcop Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tsearch Update copyrights for 2013 2013-01-01 17:15:01 -05:00
utils Provide database object names as separate fields in error messages. 2013-01-29 17:08:26 -05:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
Makefile Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Move Assert() definitions to c.h 2013-02-01 17:50:04 -03:00
fmgr.h Add infrastructure for storing a VARIADIC ANY function's VARIADIC flag. 2013-01-21 20:26:15 -05:00
funcapi.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
getaddrinfo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
getopt_long.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
miscadmin.h Make sure MaxBackends is always set 2013-01-02 14:39:11 -03:00
pg_config.h.in Improve handling of ereport(ERROR) and elog(ERROR). 2013-01-13 18:40:09 -05:00
pg_config.h.win32 Improve handling of ereport(ERROR) and elog(ERROR). 2013-01-13 18:40:09 -05:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pg_trace.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pgstat.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pgtar.h Move tar function headers to pgtar.h 2013-01-02 20:34:08 +01:00
pgtime.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
port.h Use correct output device for Windows prompts. 2013-01-24 16:01:31 -05:00
postgres.h Move Assert() definitions to c.h 2013-02-01 17:50:04 -03:00
postgres_ext.h Provide database object names as separate fields in error messages. 2013-01-29 17:08:26 -05:00
postgres_fe.h Move Assert() definitions to c.h 2013-02-01 17:50:04 -03:00
rusagestub.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
windowapi.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00