From 5283a835dc57f0a8419957a867dbb41594904176 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 11 Oct 2024 02:39:20 +0200 Subject: [PATCH] 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. --- NEWS | 7 ++++++- doc/src/errors.rst | 2 ++ lib/errorcodes.py | 1 + psycopg/sqlstate_errors.h | 1 + scripts/make_errorcodes.py | 8 ++++---- scripts/make_errors.py | 7 +++---- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 4940a91d..e62ebfe1 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Current release +Future releases --------------- 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. - 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/src/errors.rst b/doc/src/errors.rst index d6a7f4f7..6b934a16 100644 --- a/doc/src/errors.rst +++ b/doc/src/errors.rst @@ -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 diff --git a/lib/errorcodes.py b/lib/errorcodes.py index aa646c46..0bc9625e 100644 --- a/lib/errorcodes.py +++ b/lib/errorcodes.py @@ -256,6 +256,7 @@ HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL = '25008' 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' diff --git a/psycopg/sqlstate_errors.h b/psycopg/sqlstate_errors.h index 38ad78d9..f413a089 100644 --- a/psycopg/sqlstate_errors.h +++ b/psycopg/sqlstate_errors.h @@ -144,6 +144,7 @@ {"25P01", "NoActiveSqlTransaction"}, {"25P02", "InFailedSqlTransaction"}, {"25P03", "IdleInTransactionSessionTimeout"}, +{"25P04", "TransactionTimeout"}, /* Class 26 - Invalid SQL Statement Name */ {"26000", "InvalidSqlStatementName"}, diff --git a/scripts/make_errorcodes.py b/scripts/make_errorcodes.py index 378ce849..19eefa2c 100755 --- a/scripts/make_errorcodes.py +++ b/scripts/make_errorcodes.py @@ -19,6 +19,7 @@ The script can be run at a new PostgreSQL release to refresh the module. import re import sys +import time from urllib.request import urlopen from collections import defaultdict @@ -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) @@ -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): diff --git a/scripts/make_errors.py b/scripts/make_errors.py index 59b1b2b7..d231c3ad 100755 --- a/scripts/make_errors.py +++ b/scripts/make_errors.py @@ -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) @@ -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):