aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-07-31 11:50:14 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-07-31 11:50:14 -0400
commitf260436459a67e320937d656b2c93604615ed1e5 (patch)
tree99d92005a8158cfeabfc3f346d4f88acd9af81ad /src
parent5c62920fa938644935418226872b360f90e74b62 (diff)
downloadpostgresql-f260436459a67e320937d656b2c93604615ed1e5.tar.gz
postgresql-f260436459a67e320937d656b2c93604615ed1e5.zip
Use elog, not Assert, to report failure to provide an outer snapshot.
As of commit 84f5c2908, executing SQL commands (via SPI or otherwise) requires having either an active Portal, or a caller-established active snapshot. We were simply Assert'ing that that's the case. But we've now had a couple different reports of people testing extensions that didn't meet this requirement, and were confused by the resulting crash. Let's convert the Assert to a test-and-elog, in hopes of making the issue clearer for extension authors. Per gripes from Liu Huailing and RekGRpth. Back-patch to v11, like the prior commit. Discussion: https://postgr.es/m/OSZPR01MB6215671E3C5956A034A080DFBEEC9@OSZPR01MB6215.jpnprd01.prod.outlook.com Discussion: https://postgr.es/m/17035-14607d308ac8643c@postgresql.org
Diffstat (limited to 'src')
-rw-r--r--src/backend/tcop/pquery.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index c9f63923543..adbaea5ca77 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -1779,7 +1779,8 @@ EnsurePortalSnapshotExists(void)
/* Otherwise, we'd better have an active Portal */
portal = ActivePortal;
- Assert(portal != NULL);
+ if (unlikely(portal == NULL))
+ elog(ERROR, "cannot execute SQL without an outer snapshot or portal");
Assert(portal->portalSnapshot == NULL);
/* Create a new snapshot and make it active */