Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1fc0f3

Browse files
committed
Avoid Assert failure when processing empty statement in aborted xact.
exec_parse_message() wants to create a cached plan in all cases,including for empty input. The empty-input path does not havea test for being in an aborted transaction, making it possiblethat plancache.c will fail due to trying to do database lookupseven though there's no real work to do.One solution would be to throw an aborted-transaction error inthis path too, but it's not entirely clear whether the lack ofsuch an error was intentional or whether some clients might berelying on non-error behavior. Instead, let's hack plancache.cso that it treats empty statements with the same logic italready had for transaction control commands, ensuring that itcan soldier through even in an already-aborted transaction.Per bug #17983 from Alexander Lakhin. Back-patch to allsupported branches.Discussion:https://postgr.es/m/17983-da4569fcb878672e@postgresql.org
1 parent43090e1 commitd1fc0f3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

‎src/backend/utils/cache/plancache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@
7878
/*
7979
* We must skip "overhead" operations that involve database access when the
8080
* cached plan's subject statement is a transaction control command.
81+
* For the convenience of postgres.c, treat empty statements as control
82+
* commands too.
8183
*/
8284
#defineIsTransactionStmtPlan(plansource) \
83-
((plansource)->raw_parse_tree&& \
85+
((plansource)->raw_parse_tree== NULL || \
8486
IsA((plansource)->raw_parse_tree->stmt, TransactionStmt))
8587

8688
/*

‎src/test/regress/expected/psql.out

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ SELECT 3 AS x, 'Hello', 4 AS y, true AS "dirty\name" \gdesc \g
237237
3 | Hello | 4 | t
238238
(1 row)
239239

240+
-- test for server bug #17983 with empty statement in aborted transaction
241+
set search_path = default;
242+
begin;
243+
bogus;
244+
ERROR: syntax error at or near "bogus"
245+
LINE 1: bogus;
246+
^
247+
;
248+
\gdesc
249+
The command has no result, or the result has no columns.
250+
rollback;
240251
-- \gexec
241252
create temporary table gexec_test(a int, b text, c date, d float);
242253
select format('create index on gexec_test(%I)', attname)

‎src/test/regress/sql/psql.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ SELECT 1 AS x, 'Hello', 2 AS y, true AS "dirty\name"
119119
-- all on one line
120120
SELECT3AS x,'Hello',4AS y, trueAS"dirty\name" \gdesc \g
121121

122+
-- test for server bug #17983 with empty statement in aborted transaction
123+
set search_path= default;
124+
begin;
125+
bogus;
126+
;
127+
\gdesc
128+
rollback;
129+
122130
-- \gexec
123131

124132
create temporary table gexec_test(aint, btext, cdate, d float);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp