Replace over-optimistic Assert in partitioning code with a runtime test.
Tom Lane <tgl@sss.pgh.pa.us>
Replace over-optimistic Assert in partitioning code with a runtime test. get_partition_parent felt that it could simply Assert that systable_getnext found a tuple. This is unlike any other caller of that function, and it's unsafe IMO --- in fact, the reason I noticed it was that the Assert failed. (OK, I was working with known-inconsistent catalog contents, but I wasn't expecting the DB to fall over quite that violently. The behavior in a non-assert-enabled build wouldn't be very nice, either.) Fix it to do what other callers do, namely an actual runtime-test-and-elog. Also, standardize the wording of elog messages that are complaining about unexpected failure of systable_getnext. 90% of them say "could not find tuple for <object>", so make the remainder do likewise. Many of the holdouts were using the phrasing "cache lookup failed", which is outright misleading since no catcache search is involved.
Files
| Path | Change | +/− |
|---|---|---|
| contrib/sepgsql/database.c | modified | +1 −1 |
| contrib/sepgsql/proc.c | modified | +2 −2 |
| contrib/sepgsql/relation.c | modified | +4 −4 |
| contrib/sepgsql/schema.c | modified | +1 −1 |
| src/backend/catalog/aclchk.c | modified | +2 −2 |
| src/backend/catalog/objectaddress.c | modified | +1 −1 |
| src/backend/catalog/partition.c | modified | +2 −1 |
| src/backend/commands/extension.c | modified | +5 −4 |
| src/backend/utils/adt/ruleutils.c | modified | +1 −1 |