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.
This commit is contained in:
Daniele Varrazzo 2024-10-11 02:39:20 +02:00
parent eaeeb76944
commit 5283a835dc
6 changed files with 17 additions and 9 deletions

7
NEWS
View File

@ -1,4 +1,4 @@
Current release Future releases
--------------- ---------------
What's new in psycopg 2.9.10 (unreleased) What's new in psycopg 2.9.10 (unreleased)
@ -6,8 +6,13 @@ What's new in psycopg 2.9.10 (unreleased)
- Add support for Python 3.13. - Add support for Python 3.13.
- Drop support for Python 3.7. - 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 What's new in psycopg 2.9.9
^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -18,6 +18,8 @@
.. versionchanged:: 2.9.4 added errors introduced in PostgreSQL 15 .. 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 This module exposes the classes psycopg raises upon receiving an error from
the database with a :sql:`SQLSTATE` value attached (available in the the database with a :sql:`SQLSTATE` value attached (available in the
`~psycopg2.Error.pgcode` attribute). The content of the module is generated `~psycopg2.Error.pgcode` attribute). The content of the module is generated

View File

@ -256,6 +256,7 @@ HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL = '25008'
NO_ACTIVE_SQL_TRANSACTION = '25P01' NO_ACTIVE_SQL_TRANSACTION = '25P01'
IN_FAILED_SQL_TRANSACTION = '25P02' IN_FAILED_SQL_TRANSACTION = '25P02'
IDLE_IN_TRANSACTION_SESSION_TIMEOUT = '25P03' IDLE_IN_TRANSACTION_SESSION_TIMEOUT = '25P03'
TRANSACTION_TIMEOUT = '25P04'
# Class 26 - Invalid SQL Statement Name # Class 26 - Invalid SQL Statement Name
INVALID_SQL_STATEMENT_NAME = '26000' INVALID_SQL_STATEMENT_NAME = '26000'

View File

@ -144,6 +144,7 @@
{"25P01", "NoActiveSqlTransaction"}, {"25P01", "NoActiveSqlTransaction"},
{"25P02", "InFailedSqlTransaction"}, {"25P02", "InFailedSqlTransaction"},
{"25P03", "IdleInTransactionSessionTimeout"}, {"25P03", "IdleInTransactionSessionTimeout"},
{"25P04", "TransactionTimeout"},
/* Class 26 - Invalid SQL Statement Name */ /* Class 26 - Invalid SQL Statement Name */
{"26000", "InvalidSqlStatementName"}, {"26000", "InvalidSqlStatementName"},

View File

@ -19,6 +19,7 @@ The script can be run at a new PostgreSQL release to refresh the module.
import re import re
import sys import sys
import time
from urllib.request import urlopen from urllib.request import urlopen
from collections import defaultdict from collections import defaultdict
@ -32,8 +33,7 @@ def main():
file_start = read_base_file(filename) file_start = read_base_file(filename)
# If you add a version to the list fix the docs (in errorcodes.rst) # If you add a version to the list fix the docs (in errorcodes.rst)
classes, errors = fetch_errors( classes, errors = fetch_errors("11 12 13 14 15 16 17".split())
'9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split())
disambiguate(errors) disambiguate(errors)
@ -90,8 +90,8 @@ def parse_errors_txt(url):
errors_txt_url = \ errors_txt_url = \
"http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;" \ "https://raw.githubusercontent.com/postgres/postgres/refs/heads/%s" \
"f=src/backend/utils/errcodes.txt;hb=%s" "/src/backend/utils/errcodes.txt"
def fetch_errors(versions): def fetch_errors(versions):

View File

@ -29,8 +29,7 @@ def main():
os.path.dirname(__file__), "../psycopg/sqlstate_errors.h") os.path.dirname(__file__), "../psycopg/sqlstate_errors.h")
# If you add a version to the list fix the docs (in errors.rst) # If you add a version to the list fix the docs (in errors.rst)
classes, errors = fetch_errors( classes, errors = fetch_errors("11 12 13 14 15 16 17".split())
'9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split())
f = open(filename, "w") f = open(filename, "w")
print("/*\n * Autogenerated by 'scripts/make_errors.py'.\n */\n", file=f) print("/*\n * Autogenerated by 'scripts/make_errors.py'.\n */\n", file=f)
@ -74,8 +73,8 @@ def parse_errors_txt(url):
errors_txt_url = \ errors_txt_url = \
"http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;" \ "https://raw.githubusercontent.com/postgres/postgres/refs/heads/%s" \
"f=src/backend/utils/errcodes.txt;hb=%s" "/src/backend/utils/errcodes.txt"
def fetch_errors(versions): def fetch_errors(versions):