diff options
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execMain.c | 2 | ||||
-rw-r--r-- | src/backend/executor/functions.c | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index b2e2df87733..2cf6dad7685 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -195,6 +195,8 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags) palloc0(nParamExec * sizeof(ParamExecData)); } + /* We now require all callers to provide sourceText */ + Assert(queryDesc->sourceText != NULL); estate->es_sourceText = queryDesc->sourceText; /* diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 642683843ed..39580f7d577 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -667,6 +667,15 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK) procedureTuple, Anum_pg_proc_prosrc, &isNull); + if (isNull) + elog(ERROR, "null prosrc for function %u", foid); + fcache->src = TextDatumGetCString(tmp); + + /* If we have prosqlbody, pay attention to that not prosrc. */ + tmp = SysCacheGetAttr(PROCOID, + procedureTuple, + Anum_pg_proc_prosqlbody, + &isNull); /* * Parse and rewrite the queries in the function text. Use sublists to @@ -678,18 +687,11 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK) * plancache.c. */ queryTree_list = NIL; - if (isNull) + if (!isNull) { Node *n; List *stored_query_list; - tmp = SysCacheGetAttr(PROCOID, - procedureTuple, - Anum_pg_proc_prosqlbody, - &isNull); - if (isNull) - elog(ERROR, "null prosrc and prosqlbody for function %u", foid); - n = stringToNode(TextDatumGetCString(tmp)); if (IsA(n, List)) stored_query_list = linitial_node(List, castNode(List, n)); @@ -710,8 +712,6 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK) { List *raw_parsetree_list; - fcache->src = TextDatumGetCString(tmp); - raw_parsetree_list = pg_parse_query(fcache->src); foreach(lc, raw_parsetree_list) |