Skip to content

Commit 5283a83

Browse files
committed
chore: add TransactionTimeout error, added in PostgreSQL 17
Url to fetch source changed from the official Postgres one to the Github mirror because the former throttled us.
1 parent eaeeb76 commit 5283a83

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

NEWS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
Current release
1+
Future releases
22
---------------
33

44
What's new in psycopg 2.9.10 (unreleased)
55
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
- Add support for Python 3.13.
88
- Drop support for Python 3.7.
9+
- `~psycopg2.errorcodes` map and `~psycopg2.errors` classes updated to
10+
PostgreSQL 17.
11+
912

13+
Current release
14+
---------------
1015

1116
What's new in psycopg 2.9.9
1217
^^^^^^^^^^^^^^^^^^^^^^^^^^^

doc/src/errors.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
.. versionchanged:: 2.9.4 added errors introduced in PostgreSQL 15
2020

21+
.. versionchanged:: 2.9.10 added errors introduced in PostgreSQL 17
22+
2123
This module exposes the classes psycopg raises upon receiving an error from
2224
the database with a :sql:`SQLSTATE` value attached (available in the
2325
`~psycopg2.Error.pgcode` attribute). The content of the module is generated

lib/errorcodes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def lookup(code, _cache={}):
256256
NO_ACTIVE_SQL_TRANSACTION = '25P01'
257257
IN_FAILED_SQL_TRANSACTION = '25P02'
258258
IDLE_IN_TRANSACTION_SESSION_TIMEOUT = '25P03'
259+
TRANSACTION_TIMEOUT = '25P04'
259260

260261
# Class 26 - Invalid SQL Statement Name
261262
INVALID_SQL_STATEMENT_NAME = '26000'

psycopg/sqlstate_errors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
{"25P01", "NoActiveSqlTransaction"},
145145
{"25P02", "InFailedSqlTransaction"},
146146
{"25P03", "IdleInTransactionSessionTimeout"},
147+
{"25P04", "TransactionTimeout"},
147148

148149
/* Class 26 - Invalid SQL Statement Name */
149150
{"26000", "InvalidSqlStatementName"},

scripts/make_errorcodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import re
2121
import sys
22+
import time
2223
from urllib.request import urlopen
2324
from collections import defaultdict
2425

@@ -32,8 +33,7 @@ def main():
3233

3334
file_start = read_base_file(filename)
3435
# If you add a version to the list fix the docs (in errorcodes.rst)
35-
classes, errors = fetch_errors(
36-
'9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split())
36+
classes, errors = fetch_errors("11 12 13 14 15 16 17".split())
3737

3838
disambiguate(errors)
3939

@@ -90,8 +90,8 @@ def parse_errors_txt(url):
9090

9191

9292
errors_txt_url = \
93-
"http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;" \
94-
"f=src/backend/utils/errcodes.txt;hb=%s"
93+
"https://raw.githubusercontent.com/postgres/postgres/refs/heads/%s" \
94+
"/src/backend/utils/errcodes.txt"
9595

9696

9797
def fetch_errors(versions):

scripts/make_errors.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def main():
2929
os.path.dirname(__file__), "../psycopg/sqlstate_errors.h")
3030

3131
# If you add a version to the list fix the docs (in errors.rst)
32-
classes, errors = fetch_errors(
33-
'9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split())
32+
classes, errors = fetch_errors("11 12 13 14 15 16 17".split())
3433

3534
f = open(filename, "w")
3635
print("/*\n * Autogenerated by 'scripts/make_errors.py'.\n */\n", file=f)
@@ -74,8 +73,8 @@ def parse_errors_txt(url):
7473

7574

7675
errors_txt_url = \
77-
"http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;" \
78-
"f=src/backend/utils/errcodes.txt;hb=%s"
76+
"https://raw.githubusercontent.com/postgres/postgres/refs/heads/%s" \
77+
"/src/backend/utils/errcodes.txt"
7978

8079

8180
def fetch_errors(versions):

0 commit comments

Comments
 (0)