Skip to content

Commit

Permalink
chore: add TransactionTimeout error, added in PostgreSQL 17
Browse files Browse the repository at this point in the history
Url to fetch source changed from the official Postgres one to the Github
mirror because the former throttled us.
  • Loading branch information
dvarrazzo committed Oct 11, 2024
1 parent eaeeb76 commit 5283a83
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
7 changes: 6 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Current release
Future releases
---------------

What's new in psycopg 2.9.10 (unreleased)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Add support for Python 3.13.
- Drop support for Python 3.7.
- `~psycopg2.errorcodes` map and `~psycopg2.errors` classes updated to
PostgreSQL 17.


Current release
---------------

What's new in psycopg 2.9.9
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions doc/src/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

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

.. versionchanged:: 2.9.10 added errors introduced in PostgreSQL 17

This module exposes the classes psycopg raises upon receiving an error from
the database with a :sql:`SQLSTATE` value attached (available in the
`~psycopg2.Error.pgcode` attribute). The content of the module is generated
Expand Down
1 change: 1 addition & 0 deletions lib/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def lookup(code, _cache={}):
NO_ACTIVE_SQL_TRANSACTION = '25P01'
IN_FAILED_SQL_TRANSACTION = '25P02'
IDLE_IN_TRANSACTION_SESSION_TIMEOUT = '25P03'
TRANSACTION_TIMEOUT = '25P04'

# Class 26 - Invalid SQL Statement Name
INVALID_SQL_STATEMENT_NAME = '26000'
Expand Down
1 change: 1 addition & 0 deletions psycopg/sqlstate_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
{"25P01", "NoActiveSqlTransaction"},
{"25P02", "InFailedSqlTransaction"},
{"25P03", "IdleInTransactionSessionTimeout"},
{"25P04", "TransactionTimeout"},

/* Class 26 - Invalid SQL Statement Name */
{"26000", "InvalidSqlStatementName"},
Expand Down
8 changes: 4 additions & 4 deletions scripts/make_errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import re
import sys
import time
from urllib.request import urlopen
from collections import defaultdict

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

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

disambiguate(errors)

Expand Down Expand Up @@ -90,8 +90,8 @@ def parse_errors_txt(url):


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


def fetch_errors(versions):
Expand Down
7 changes: 3 additions & 4 deletions scripts/make_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def main():
os.path.dirname(__file__), "../psycopg/sqlstate_errors.h")

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

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


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


def fetch_errors(versions):
Expand Down

0 comments on commit 5283a83

Please sign in to comment.