diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-11-12 16:58:00 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-11-12 16:58:08 -0500 |
commit | 112caf9039f4c8fb286bb610461ced8253313e9f (patch) | |
tree | dcc753fae6352024b7ef25c997d5ae97acf09425 | |
parent | c5e8ea978d88ea4aa731516836e14d54c50cc957 (diff) | |
download | postgresql-112caf9039f4c8fb286bb610461ced8253313e9f.tar.gz postgresql-112caf9039f4c8fb286bb610461ced8253313e9f.zip |
Finish reverting commit 0a52d378b.
Apply the solution adopted in commit dcb7d3caf (ie, explicitly
don't call memcmp for a zero-length comparison) to func_get_detail()
as well, removing one other place where we were passing an
uninitialized array to a parse_func.c entry point.
Discussion: https://postgr.es/m/MN2PR18MB2927F24692485D754794F01BE3740@MN2PR18MB2927.namprd18.prod.outlook.com
Discussion: https://postgr.es/m/MN2PR18MB2927F6873DF2774A505AC298E3740@MN2PR18MB2927.namprd18.prod.outlook.com
-rw-r--r-- | src/backend/parser/parse_func.c | 7 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 3 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 9d9efc2cc24..d9c6dc19018 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -1397,9 +1397,6 @@ func_get_detail(List *funcname, FuncCandidateList raw_candidates; FuncCandidateList best_candidate; - /* Passing NULL for argtypes is no longer allowed */ - Assert(argtypes); - /* initialize output arguments to silence compiler warnings */ *funcid = InvalidOid; *rettype = InvalidOid; @@ -1423,7 +1420,9 @@ func_get_detail(List *funcname, best_candidate != NULL; best_candidate = best_candidate->next) { - if (memcmp(argtypes, best_candidate->args, nargs * sizeof(Oid)) == 0) + /* if nargs==0, argtypes can be null; don't pass that to memcmp */ + if (nargs == 0 || + memcmp(argtypes, best_candidate->args, nargs * sizeof(Oid)) == 0) break; } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index c1de869c521..4c83cae5e92 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -833,7 +833,6 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) char *tgname; char *tgoldtable; char *tgnewtable; - Oid argtypes[1]; /* dummy */ Datum value; bool isnull; @@ -1045,7 +1044,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) appendStringInfo(&buf, "EXECUTE FUNCTION %s(", generate_function_name(trigrec->tgfoid, 0, - NIL, argtypes, + NIL, NULL, false, NULL, EXPR_KIND_NONE)); if (trigrec->tgnargs > 0) |