diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-08 13:11:15 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-08 13:11:26 -0500 |
commit | 6d30fb1f75a57d80f80e27770d39d88f8aa32d28 (patch) | |
tree | 056042db35fa8ad69957dd54dda3c5dcaaa62d7c /src/test/regress/regress.c | |
parent | 36ac6d0e793087153a452df6502d0ef32a780db6 (diff) | |
download | postgresql-6d30fb1f75a57d80f80e27770d39d88f8aa32d28.tar.gz postgresql-6d30fb1f75a57d80f80e27770d39d88f8aa32d28.zip |
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>
Diffstat (limited to 'src/test/regress/regress.c')
-rw-r--r-- | src/test/regress/regress.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index e7826a4513b..119a59ab073 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -523,11 +523,12 @@ ttdummy(PG_FUNCTION_ARGS) for (i = 0; i < 2; i++) { attnum[i] = SPI_fnumber(tupdesc, args[i]); - if (attnum[i] < 0) - elog(ERROR, "ttdummy (%s): there is no attribute %s", relname, args[i]); + if (attnum[i] <= 0) + elog(ERROR, "ttdummy (%s): there is no attribute %s", + relname, args[i]); if (SPI_gettypeid(tupdesc, attnum[i]) != INT4OID) - elog(ERROR, "ttdummy (%s): attributes %s and %s must be of abstime type", - relname, args[0], args[1]); + elog(ERROR, "ttdummy (%s): attribute %s must be of integer type", + relname, args[i]); } oldon = SPI_getbinval(trigtuple, tupdesc, attnum[0], &isnull); |