Thread: pgsql: Initialize the entryRes array between each call to triConsistent

pgsql: Initialize the entryRes array between each call to triConsistent

From
Heikki Linnakangas
Date:
Initialize the entryRes array between each call to triConsistent.

The shimTriConstistentFn, which calls the opclass's consistent function with
all combinations of TRUE/FALSE for any MAYBE argument, modifies the entryRes
array passed by the caller. Change startScanKey to re-initialize it between
each call to accommodate that.

It's actually a bad habit by shimTriConsistentFn to modify its argument. But
the only caller that doesn't already re-initialize the entryRes array was
startScanKey, and it's easy for startScanKey to do so. Add a comment to
shimTriConsistentFn about that.

Note: this does not give a free pass to opclass-provided consistent
functions to modify the entryRes argument; shimTriConsistent assumes that
they don't, even though it does it itself.

While at it, refactor startScanKey to allocate the requiredEntries and
additionalEntries after it knows exactly how large they need to be. Saves a
little bit of memory, and looks nicer anyway.

Per complaint by Tom Lane, buildfarm and the pg_trgm regression test.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6aa2bdf6a01ce099e315cb313396ca4b8415321b

Modified Files
--------------
src/backend/access/gin/ginget.c   |   40 +++++++++++++++++++++++--------------
src/backend/access/gin/ginlogic.c |    6 ++++--
2 files changed, 29 insertions(+), 17 deletions(-)