Make SPI_fnumber() reject dropped columns.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 6d30fb1f75a57d80f80e27770d39d88f8aa32d28
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2016-11-08T18:11:26Z
Releases: 10.0
Make SPI_fnumber() reject dropped columns.

There's basically no scenario where it's sensible for this to match
dropped columns, so put a test for dropped-ness into SPI_fnumber()
itself, and excise the test from the small number of callers that
were paying attention to the case.  (Most weren't :-(.)

In passing, normalize tests at call sites: always reject attnum <= 0
if we're disallowing system columns.  Previously there was a mixture
of "< 0" and "<= 0" tests.  This makes no practical difference since
SPI_fnumber() never returns 0, but I'm feeling pedantic today.

Also, in the places that are actually live user-facing code and not
legacy cruft, distinguish "column not found" from "can't handle
system column".

Per discussion with Jim Nasby; thi supersedes his original patch
that just changed the behavior at one call site.

Discussion: <b2de8258-c4c0-1cb8-7b97-e8538e5c975c@BlueTreble.com>

Files

PathChange+/−
contrib/spi/autoinc.c modified +1 −1
contrib/spi/insert_username.c modified +1 −1
contrib/spi/moddatetime.c modified +2 −2
contrib/spi/refint.c modified +3 −2
contrib/spi/timetravel.c modified +2 −2
doc/src/sgml/spi.sgml modified +1 −1
src/backend/executor/spi.c modified +2 −1
src/backend/utils/adt/tsvector_op.c modified +1 −0
src/pl/plperl/plperl.c modified +6 −1
src/pl/tcl/pltcl.c modified +1 −10
src/test/regress/regress.c modified +5 −4

Documentation touched