aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-11-12 15:58:37 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-11-12 15:59:01 -0500
commit677708032c4a4d37cdb2a4bd45726fc260308db7 (patch)
tree1914a5cab5690d19fb57cf64f4a54cda3cc55115 /src/backend/tcop/postgres.c
parentec5896aed3c01da24c1f335f138817e9890d68b6 (diff)
downloadpostgresql-677708032c4a4d37cdb2a4bd45726fc260308db7.tar.gz
postgresql-677708032c4a4d37cdb2a4bd45726fc260308db7.zip
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 commits a73c9dbab0165b3395dfe8a44a7dfd16166963c4 and 2e9650cbcff8c8fb0d9ef807c73a44f241822eee, 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.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 61f17bf1e9b..cc62b2cfe8b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -1546,7 +1546,9 @@ exec_bind_message(StringInfo input_message)
* snapshot active till we're done, so that plancache.c doesn't have to
* take new ones.
*/
- if (numParams > 0 || analyze_requires_snapshot(psrc->raw_parse_tree))
+ if (numParams > 0 ||
+ (psrc->raw_parse_tree &&
+ analyze_requires_snapshot(psrc->raw_parse_tree)))
{
PushActiveSnapshot(GetTransactionSnapshot());
snapshot_set = true;