From: Daniele Varrazzo Date: Sun, 11 May 2025 20:48:26 +0000 (+0200) Subject: chore: add PostgreSQL 18 exceptions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c77018dc27277b035ccae2918c65f7f2b903115;p=thirdparty%2Fpsycopg.git chore: add PostgreSQL 18 exceptions NOMERGE: re-run the script when we are closer to release, fix versionadded in errors.py. --- diff --git a/docs/api/errors.rst b/docs/api/errors.rst index 10301867f..69c543de4 100644 --- a/docs/api/errors.rst +++ b/docs/api/errors.rst @@ -241,6 +241,9 @@ SQLSTATE Exception Base exception --------------------------------------------------------------------------------- ``0Z000`` `!DiagnosticsException` `!DatabaseError` ``0Z002`` `!StackedDiagnosticsAccessedWithoutActiveHandler` `!DatabaseError` +**Class 10** - XQuery Error +--------------------------------------------------------------------------------- +``10608`` `!InvalidArgumentForXquery` `!ProgrammingError` **Class 20** - Case Not Found --------------------------------------------------------------------------------- ``20000`` `!CaseNotFound` `!ProgrammingError` @@ -487,6 +490,7 @@ SQLSTATE Exception Base exception ``58030`` `!IoError` `!OperationalError` ``58P01`` `!UndefinedFile` `!OperationalError` ``58P02`` `!DuplicateFile` `!OperationalError` +``58P03`` `!FileNameTooLong` `!OperationalError` **Class 72** - Snapshot Failure --------------------------------------------------------------------------------- ``72000`` `!SnapshotTooOld` `!DatabaseError` @@ -544,3 +548,7 @@ SQLSTATE Exception Base exception .. versionadded:: 3.2.3 Exception `!TransactionTimeout`, introduced in PostgreSQL 17. + +.. versionadded:: NOMERGE + Exception `!InvalidArgumentForXquery`, `FileNameTooLong`, introduced in + PostgreSQL 18. diff --git a/psycopg/psycopg/errors.py b/psycopg/psycopg/errors.py index fe410fa67..f5e0396d1 100644 --- a/psycopg/psycopg/errors.py +++ b/psycopg/psycopg/errors.py @@ -578,6 +578,7 @@ def get_base_exception(sqlstate: str) -> type[Error]: _base_exc_map = { "08": OperationalError, # Connection Exception "0A": NotSupportedError, # Feature Not Supported + "10": ProgrammingError, # XQuery Error "20": ProgrammingError, # Case Not Foud "21": ProgrammingError, # Cardinality Violation "22": DataError, # Data Exception @@ -727,6 +728,13 @@ class StackedDiagnosticsAccessedWithoutActiveHandler(DatabaseError, pass +# Class 10 - XQuery Error + +class InvalidArgumentForXquery(ProgrammingError, + code='10608', name='INVALID_ARGUMENT_FOR_XQUERY'): + pass + + # Class 20 - Case Not Found class CaseNotFound(ProgrammingError, @@ -1580,6 +1588,10 @@ class DuplicateFile(OperationalError, code='58P02', name='DUPLICATE_FILE'): pass +class FileNameTooLong(OperationalError, + code='58P03', name='FILE_NAME_TOO_LONG'): + pass + # Class 72 - Snapshot Failure diff --git a/tools/update_errors.py b/tools/update_errors.py index 3e5ad6731..8019acf80 100755 --- a/tools/update_errors.py +++ b/tools/update_errors.py @@ -25,7 +25,7 @@ Error = namedtuple("Error", "sqlstate errlabel clsname basename") def main(): # Note: add "master" for a preview - classes, errors = fetch_errors("9.6 10 11 12 13 14 15 16 17".split()) + classes, errors = fetch_errors("9.6 10 11 12 13 14 15 16 17 18".split()) fn = os.path.dirname(__file__) + "/../psycopg/psycopg/errors.py" update_file(fn, generate_module_data(classes, errors))