Skip to content

Commit 13848cf

Browse files
committed
sql: use PG error code for txn errors
Release note: None
1 parent dc28e19 commit 13848cf

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pkg/sql/exec_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,8 @@ var overrideAlterPrimaryRegionInSuperRegion = settings.RegisterBoolSetting(
739739
false,
740740
).WithPublic()
741741

742-
var errNoTransactionInProgress = errors.New("there is no transaction in progress")
743-
var errTransactionInProgress = errors.New("there is already a transaction in progress")
742+
var errNoTransactionInProgress = pgerror.New(pgcode.NoActiveSQLTransaction, "there is no transaction in progress")
743+
var errTransactionInProgress = pgerror.New(pgcode.ActiveSQLTransaction, "there is already a transaction in progress")
744744

745745
const sqlTxnName string = "sql txn"
746746
const metricsSampleInterval = 10 * time.Second

pkg/sql/logictest/testdata/logic_test/txn

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ x y
142142
statement ok
143143
BEGIN TRANSACTION
144144

145-
statement error there is already a transaction in progress
145+
statement error pgcode 25001 there is already a transaction in progress
146146
BEGIN TRANSACTION
147147

148148
statement ok
@@ -156,10 +156,10 @@ BEGIN TRANSACTION
156156
statement ok
157157
UPDATE kv SET v = 'b' WHERE k in ('a')
158158

159-
statement error there is already a transaction in progress
159+
statement error pgcode 25001 there is already a transaction in progress
160160
BEGIN TRANSACTION
161161

162-
statement error current transaction is aborted, commands ignored until end of transaction block
162+
statement error pgcode 25P02 current transaction is aborted, commands ignored until end of transaction block
163163
SELECT * FROM kv
164164

165165
statement ok
@@ -176,15 +176,15 @@ BEGIN; END
176176

177177
# COMMIT/ROLLBACK without a transaction are errors.
178178

179-
statement error there is no transaction in progress
179+
statement error pgcode 25P01 there is no transaction in progress
180180
COMMIT TRANSACTION
181181

182-
statement error there is no transaction in progress
182+
statement error pgcode 25P01 there is no transaction in progress
183183
ROLLBACK TRANSACTION
184184

185185
# Set isolation level without a transaction is an error.
186186

187-
statement error there is no transaction in progress
187+
statement error pgcode 25P01 there is no transaction in progress
188188
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
189189

190190
statement ok
@@ -393,7 +393,7 @@ COMMIT
393393

394394
# User priority.
395395

396-
statement error there is no transaction in progress
396+
statement error pgcode 25P01 there is no transaction in progress
397397
SET TRANSACTION PRIORITY LOW
398398

399399
statement ok

pkg/sql/pgwire/testdata/pgtest/implicit_txn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ErrorResponse
5959
ReadyForQuery
6060
----
6161
{"Type":"BindComplete"}
62-
{"Type":"ErrorResponse","Code":"XXUUU"}
62+
{"Type":"ErrorResponse","Code":"25001"}
6363
{"Type":"ReadyForQuery","TxStatus":"E"}
6464

6565
send

0 commit comments

Comments
 (0)