aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-11-23 13:10:03 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-11-23 13:10:03 -0300
commitfe051291550ab88267ce3104e9833925bf757393 (patch)
treeeca62a323b9f977212a18d807b43f3acf9f756a5 /src
parent68b1a4877ef54f5ee6e05c64876655dd13d2c73b (diff)
downloadpostgresql-fe051291550ab88267ce3104e9833925bf757393.tar.gz
postgresql-fe051291550ab88267ce3104e9833925bf757393.zip
Make some sanity-check elogs more verbose
A few sanity checks in funcapi.c were not mentioning all the possible clauses for failure, confusing developers who fat-fingered catalog data additions. Make the errors more detailed to avoid wasting time in pinpointing mistakes. Per complaint from Craig Ringer. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAMsr+YH7Kd87A3cU5m_wKo46HPQ46zFv5wesFNL0YWxkGhGv3g@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/fmgr/funcapi.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index b9efa772915..9696c88f241 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -1123,7 +1123,7 @@ get_func_arg_info(HeapTuple procTup,
numargs < 0 ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != OIDOID)
- elog(ERROR, "proallargtypes is not a 1-D Oid array");
+ elog(ERROR, "proallargtypes is not a 1-D Oid array or it contains nulls");
Assert(numargs >= procStruct->pronargs);
*p_argtypes = (Oid *) palloc(numargs * sizeof(Oid));
memcpy(*p_argtypes, ARR_DATA_PTR(arr),
@@ -1170,7 +1170,8 @@ get_func_arg_info(HeapTuple procTup,
ARR_DIMS(arr)[0] != numargs ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != CHAROID)
- elog(ERROR, "proargmodes is not a 1-D char array");
+ elog(ERROR, "proargmodes is not a 1-D char array of length %d or it contains nulls",
+ numargs);
*p_argmodes = (char *) palloc(numargs * sizeof(char));
memcpy(*p_argmodes, ARR_DATA_PTR(arr),
numargs * sizeof(char));
@@ -1210,7 +1211,7 @@ get_func_trftypes(HeapTuple procTup,
nelems < 0 ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != OIDOID)
- elog(ERROR, "protrftypes is not a 1-D Oid array");
+ elog(ERROR, "protrftypes is not a 1-D Oid array or it contains nulls");
Assert(nelems >= ((Form_pg_proc) GETSTRUCT(procTup))->pronargs);
*p_trftypes = (Oid *) palloc(nelems * sizeof(Oid));
memcpy(*p_trftypes, ARR_DATA_PTR(arr),
@@ -1261,7 +1262,7 @@ get_func_input_arg_names(char prokind,
if (ARR_NDIM(arr) != 1 ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
- elog(ERROR, "proargnames is not a 1-D text array");
+ elog(ERROR, "proargnames is not a 1-D text array or it contains nulls");
deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &numargs);
if (proargmodes != PointerGetDatum(NULL))
@@ -1271,7 +1272,8 @@ get_func_input_arg_names(char prokind,
ARR_DIMS(arr)[0] != numargs ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != CHAROID)
- elog(ERROR, "proargmodes is not a 1-D char array");
+ elog(ERROR, "proargmodes is not a 1-D char array of length %d or it contains nulls",
+ numargs);
argmodes = (char *) ARR_DATA_PTR(arr);
}
else
@@ -1368,14 +1370,15 @@ get_func_result_name(Oid functionId)
numargs < 0 ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != CHAROID)
- elog(ERROR, "proargmodes is not a 1-D char array");
+ elog(ERROR, "proargmodes is not a 1-D char array or it contains nulls");
argmodes = (char *) ARR_DATA_PTR(arr);
arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_DIMS(arr)[0] != numargs ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
- elog(ERROR, "proargnames is not a 1-D text array");
+ elog(ERROR, "proargnames is not a 1-D text array of length %d or it contains nulls",
+ numargs);
deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &nargnames);
Assert(nargnames == numargs);
@@ -1506,14 +1509,15 @@ build_function_result_tupdesc_d(char prokind,
numargs < 0 ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != OIDOID)
- elog(ERROR, "proallargtypes is not a 1-D Oid array");
+ elog(ERROR, "proallargtypes is not a 1-D Oid array or it contains nulls");
argtypes = (Oid *) ARR_DATA_PTR(arr);
arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_DIMS(arr)[0] != numargs ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != CHAROID)
- elog(ERROR, "proargmodes is not a 1-D char array");
+ elog(ERROR, "proargmodes is not a 1-D char array of length %d or it contains nulls",
+ numargs);
argmodes = (char *) ARR_DATA_PTR(arr);
if (proargnames != PointerGetDatum(NULL))
{
@@ -1522,7 +1526,8 @@ build_function_result_tupdesc_d(char prokind,
ARR_DIMS(arr)[0] != numargs ||
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
- elog(ERROR, "proargnames is not a 1-D text array");
+ elog(ERROR, "proargnames is not a 1-D text array of length %d or it contains nulls",
+ numargs);
deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &nargnames);
Assert(nargnames == numargs);