mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Explicitly support the case that a plancache's raw_parse_tree is NULL.
This only happens if a client issues a Parse message with an empty query string, which is a bit odd; but since it is explicitly called out as legal by our FE/BE protocol spec, we'd probably better continue to allow it. Fix by adding tests everywhere that the raw_parse_tree field is passed to functions that don't or shouldn't accept NULL. Also make it clear in the relevant comments that NULL is an expected case. This reverts commitsa73c9dbab0
and2e9650cbcf
, which fixed specific crash symptoms by hacking things at what now seems to be the wrong end, ie the callee functions. Making the callees allow NULL is superficially more robust, but it's not always true that there is a defensible thing for the callee to do in such cases. The caller has more context and is better able to decide what the empty-query case ought to do. Per followup discussion of bug #11335. Back-patch to 9.2. The code before that is sufficiently different that it would require development of a separate patch, which doesn't seem worthwhile for what is believed to be an essentially cosmetic change.
This commit is contained in:
@ -288,17 +288,13 @@ transformStmt(ParseState *pstate, Node *parseTree)
|
||||
* Returns true if a snapshot must be set before doing parse analysis
|
||||
* on the given raw parse tree.
|
||||
*
|
||||
* Classification here should match transformStmt(); but we also have to
|
||||
* allow a NULL input (for Parse/Bind of an empty query string).
|
||||
* Classification here should match transformStmt().
|
||||
*/
|
||||
bool
|
||||
analyze_requires_snapshot(Node *parseTree)
|
||||
{
|
||||
bool result;
|
||||
|
||||
if (parseTree == NULL)
|
||||
return false;
|
||||
|
||||
switch (nodeTag(parseTree))
|
||||
{
|
||||
/*
|
||||
|
Reference in New Issue
Block a user