1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Undo decision to allow pg_proc.prosrc to be NULL.

Commit e717a9a18 changed the longstanding rule that prosrc is NOT NULL
because when a SQL-language function is written in SQL-standard style,
we don't currently have anything useful to put there.  This seems a poor
decision though, as it could easily have negative impacts on external
PLs (opening them to crashes they didn't use to have, for instance).
SQL-function-related code can just as easily test "is prosqlbody not
null" as "is prosrc null", so there's no real gain there either.
Hence, revert the NOT NULL marking removal and adjust related logic.

For now, we just put an empty string into prosrc for SQL-standard
functions.  Maybe we'll have a better idea later, although the
history of things like pg_attrdef.adsrc suggests that it's not
easy to maintain a string equivalent of a node tree.

This also adds an assertion that queryDesc->sourceText != NULL
to standard_ExecutorStart.  We'd been silently relying on that
for awhile, so let's make it less silent.

Also fix some overlooked documentation and test cases.

Discussion: https://postgr.es/m/2197698.1617984583@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2021-04-15 17:17:20 -04:00
parent 3157cbe974
commit 1111b2668d
15 changed files with 125 additions and 95 deletions

View File

@ -958,8 +958,17 @@ interpret_AS_clause(Oid languageOid, const char *languageName,
*sql_body_out = (Node *) q;
}
/*
* We must put something in prosrc. For the moment, just record an
* empty string. It might be useful to store the original text of the
* CREATE FUNCTION statement --- but to make actual use of that in
* error reports, we'd also have to adjust readfuncs.c to not throw
* away node location fields when reading prosqlbody.
*/
*prosrc_str_p = pstrdup("");
/* But we definitely don't need probin. */
*probin_str_p = NULL;
*prosrc_str_p = NULL;
}
else
{