summaryrefslogtreecommitdiff
path: root/src/backend/partitioning
diff options
context:
space:
mode:
authorDaniel Gustafsson2023-03-25 21:49:33 +0000
committerDaniel Gustafsson2023-03-25 21:49:33 +0000
commitd435f15fff3cf3cf5d6cfcfd63e21acc0f737829 (patch)
tree9be0836e44c3b6809bf2f6910e9fd4a45ef1f217 /src/backend/partitioning
parente33967b13bbc6e4e1c1b5e9ecd1c45148cffcc53 (diff)
Add SysCacheGetAttrNotNull for guaranteed not-null attrs
When extracting an attr from a cached tuple in the syscache with SysCacheGetAttr the isnull parameter must be checked in case the attr cannot be NULL. For cases when this is known beforehand, a wrapper is introduced which perform the errorhandling internally on behalf of the caller, invoking an elog in case of a NULL attr. Reviewed-by: Tom Lane <[email protected]> Reviewed-by: Peter Eisentraut <[email protected]> Reviewed-by: David Rowley <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/partitioning')
-rw-r--r--src/backend/partitioning/partbounds.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index a69c1d1e77d..cf1156b8427 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -4311,19 +4311,14 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
Oid inhrelid = inhoids[k];
HeapTuple tuple;
Datum datum;
- bool isnull;
PartitionBoundSpec *bspec;
tuple = SearchSysCache1(RELOID, inhrelid);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
- datum = SysCacheGetAttr(RELOID, tuple,
- Anum_pg_class_relpartbound,
- &isnull);
- if (isnull)
- elog(ERROR, "null relpartbound for relation %u", inhrelid);
-
+ datum = SysCacheGetAttrNotNull(RELOID, tuple,
+ Anum_pg_class_relpartbound);
bspec = (PartitionBoundSpec *)
stringToNode(TextDatumGetCString(datum));
if (!IsA(bspec, PartitionBoundSpec))