summaryrefslogtreecommitdiff
path: root/src/backend/utils/fmgr/funcapi.c
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/utils/fmgr/funcapi.c
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/utils/fmgr/funcapi.c')
-rw-r--r--src/backend/utils/fmgr/funcapi.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index 217835d590b..24683bb608e 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -1602,7 +1602,6 @@ get_func_result_name(Oid functionId)
HeapTuple procTuple;
Datum proargmodes;
Datum proargnames;
- bool isnull;
ArrayType *arr;
int numargs;
char *argmodes;
@@ -1623,14 +1622,10 @@ get_func_result_name(Oid functionId)
else
{
/* Get the data out of the tuple */
- proargmodes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargmodes,
- &isnull);
- Assert(!isnull);
- proargnames = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargnames,
- &isnull);
- Assert(!isnull);
+ proargmodes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargmodes);
+ proargnames = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargnames);
/*
* We expect the arrays to be 1-D arrays of the right types; verify
@@ -1717,14 +1712,10 @@ build_function_result_tupdesc_t(HeapTuple procTuple)
return NULL;
/* Get the data out of the tuple */
- proallargtypes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proallargtypes,
- &isnull);
- Assert(!isnull);
- proargmodes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargmodes,
- &isnull);
- Assert(!isnull);
+ proallargtypes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proallargtypes);
+ proargmodes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargmodes);
proargnames = SysCacheGetAttr(PROCOID, procTuple,
Anum_pg_proc_proargnames,
&isnull);