diff options
| author | Tom Lane | 2022-09-27 15:47:12 +0000 |
|---|---|---|
| committer | Tom Lane | 2022-09-27 15:47:12 +0000 |
| commit | 385366426511399a91da327c0f04765bbcfd5322 (patch) | |
| tree | bb6851d6157032806a9df6ab23a4242b548bb378 /src/pl | |
| parent | 4148c8b3daf95ca308f055e103f6ee82e25b8f99 (diff) | |
Introduce GUC_NO_RESET flag.
Previously, the transaction-property GUCs such as transaction_isolation
could be reset after starting a transaction, because we marked them
as GUC_NO_RESET_ALL but still allowed a targeted RESET. That leads to
assertion failures or worse, because those properties aren't supposed
to change after we've acquired a transaction snapshot.
There are some NO_RESET_ALL variables for which RESET is okay, so
we can't just redefine the semantics of that flag. Instead introduce
a separate GUC_NO_RESET flag. Mark "seed", as well as the transaction
property GUCs, as GUC_NO_RESET.
We have to disallow GUC_ACTION_SAVE as well as straight RESET, because
otherwise a function having a "SET transaction_isolation" clause can
still break things: the end-of-function restore action is equivalent
to a RESET.
No back-patch, as it's conceivable that someone is doing something
this patch will forbid (like resetting one of these GUCs at transaction
start, or "CREATE FUNCTION ... SET transaction_read_only = 1") and not
running into problems with it today. Given how long we've had this
issue and not noticed, the side effects in non-assert builds can't be
too serious.
Per bug #17385 from Andrew Bille.
Masahiko Sawada
Discussion: https://postgr.es/m/17385-9ee529fb091f0ce5@postgresql.org
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/expected/plpgsql_transaction.out | 5 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/sql/plpgsql_transaction.sql | 3 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/pl/plpgsql/src/expected/plpgsql_transaction.out b/src/pl/plpgsql/src/expected/plpgsql_transaction.out index 254e5b7a70..adff10fa6d 100644 --- a/src/pl/plpgsql/src/expected/plpgsql_transaction.out +++ b/src/pl/plpgsql/src/expected/plpgsql_transaction.out @@ -576,8 +576,7 @@ BEGIN PERFORM 1; RAISE INFO '%', current_setting('transaction_isolation'); COMMIT; - SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; - RESET TRANSACTION ISOLATION LEVEL; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; PERFORM 1; RAISE INFO '%', current_setting('transaction_isolation'); COMMIT; @@ -585,7 +584,7 @@ END; $$; INFO: read committed INFO: repeatable read -INFO: read committed +INFO: serializable -- error cases DO LANGUAGE plpgsql $$ BEGIN diff --git a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql index 8d76d00daa..c73fca7e03 100644 --- a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql +++ b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql @@ -481,8 +481,7 @@ BEGIN PERFORM 1; RAISE INFO '%', current_setting('transaction_isolation'); COMMIT; - SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; - RESET TRANSACTION ISOLATION LEVEL; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; PERFORM 1; RAISE INFO '%', current_setting('transaction_isolation'); COMMIT; |
