Skip to content

Commit

Permalink
execbuilder: change error message to match PostgreSQL
Browse files Browse the repository at this point in the history
Release note (sql change): Change the following error message:

```
statement error cannot execute FOR UPDATE in a read-only transaction
```

to this to match PostgreSQL:

```
statement error cannot execute SELECT FOR UPDATE in a read-only transaction
```
  • Loading branch information
michae2 committed Oct 7, 2023
1 parent bcbe369 commit 4cef6e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/logictest/testdata/logic_test/prepare
Expand Up @@ -1301,7 +1301,7 @@ PREPARE a1 AS SELECT * FROM t3 FOR UPDATE
statement ok
BEGIN READ ONLY

statement error cannot execute FOR UPDATE in a read-only transaction
statement error cannot execute SELECT FOR UPDATE in a read-only transaction
EXECUTE a1

statement ok
Expand All @@ -1316,7 +1316,7 @@ PREPARE a1 AS SELECT * FROM t3 FOR NO KEY UPDATE
statement ok
BEGIN READ ONLY

statement error cannot execute FOR NO KEY UPDATE in a read-only transaction
statement error cannot execute SELECT FOR NO KEY UPDATE in a read-only transaction
EXECUTE a1

statement ok
Expand All @@ -1331,7 +1331,7 @@ PREPARE a1 AS SELECT * FROM t3 FOR SHARE
statement ok
BEGIN READ ONLY

statement error cannot execute FOR SHARE in a read-only transaction
statement error cannot execute SELECT FOR SHARE in a read-only transaction
EXECUTE a1

statement ok
Expand All @@ -1346,7 +1346,7 @@ PREPARE a1 AS SELECT * FROM t3 FOR KEY SHARE
statement ok
BEGIN READ ONLY

statement error cannot execute FOR KEY SHARE in a read-only transaction
statement error cannot execute SELECT FOR KEY SHARE in a read-only transaction
EXECUTE a1

statement ok
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/logictest/testdata/logic_test/select_for_update
Expand Up @@ -409,7 +409,7 @@ user root
statement ok
BEGIN READ ONLY

statement error cannot execute FOR UPDATE in a read-only transaction
statement error cannot execute SELECT FOR UPDATE in a read-only transaction
SELECT * FROM t FOR UPDATE

statement ok
Expand All @@ -418,7 +418,7 @@ ROLLBACK
statement ok
BEGIN READ ONLY

statement error cannot execute FOR NO KEY UPDATE in a read-only transaction
statement error cannot execute SELECT FOR NO KEY UPDATE in a read-only transaction
SELECT * FROM t FOR NO KEY UPDATE

statement ok
Expand All @@ -428,7 +428,7 @@ statement ok
BEGIN READ ONLY

skipif config local-mixed-22.2-23.1
statement error cannot execute FOR SHARE in a read-only transaction
statement error cannot execute SELECT FOR SHARE in a read-only transaction
SELECT * FROM t FOR SHARE

statement ok
Expand All @@ -438,7 +438,7 @@ statement ok
BEGIN READ ONLY

skipif config local-mixed-22.2-23.1
statement error cannot execute FOR KEY SHARE in a read-only transaction
statement error cannot execute SELECT FOR KEY SHARE in a read-only transaction
SELECT * FROM t FOR KEY SHARE

statement ok
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/relational.go
Expand Up @@ -2911,7 +2911,7 @@ func (b *Builder) buildLocking(locking opt.Locking) (opt.Locking, error) {
// Raise error if row-level locking is part of a read-only transaction.
if b.evalCtx.TxnReadOnly {
return opt.Locking{}, pgerror.Newf(pgcode.ReadOnlySQLTransaction,
"cannot execute %s in a read-only transaction", locking.Strength.String(),
"cannot execute SELECT %s in a read-only transaction", locking.Strength.String(),
)
}
if locking.Form == tree.LockPredicate {
Expand Down

0 comments on commit 4cef6e7

Please sign in to comment.