From 29a65f756c7871010ecc73828458d4d9b6a4928d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 6 Oct 2022 02:26:09 +0100 Subject: [PATCH] chore: upgrade error codes to PostgreSQL 15 --- NEWS | 2 ++ doc/src/errorcodes.rst | 2 +- doc/src/errors.rst | 6 +++++- doc/src/install.rst | 2 +- lib/errorcodes.py | 1 + psycopg/sqlstate_errors.h | 1 + scripts/make_errorcodes.py | 2 +- scripts/make_errors.py | 2 +- 8 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index e04314b8..c14250ea 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ What's new in psycopg 2.9.4 (unreleased) - Fix `register_composite()`, `register_range()` with customized search_path (:ticket:`#1487`). - Handle correctly composite types with names or in schemas requiring escape. +- `~psycopg2.errorcodes` map and `~psycopg2.errors` classes updated to + PostgreSQL 15. Current release diff --git a/doc/src/errorcodes.rst b/doc/src/errorcodes.rst index 2966efa2..4094dc5c 100644 --- a/doc/src/errorcodes.rst +++ b/doc/src/errorcodes.rst @@ -50,7 +50,7 @@ An example of the available constants defined in the module: '42P01' Constants representing all the error values defined by PostgreSQL versions -between 8.1 and 13 are included in the module. +between 8.1 and 15 are included in the module. .. autofunction:: lookup(code) diff --git a/doc/src/errors.rst b/doc/src/errors.rst index d1aed136..d6a7f4f7 100644 --- a/doc/src/errors.rst +++ b/doc/src/errors.rst @@ -14,11 +14,15 @@ .. versionchanged:: 2.8.6 added errors introduced in PostgreSQL 13 +.. versionchanged:: 2.9.2 added errors introduced in PostgreSQL 14 + +.. versionchanged:: 2.9.4 added errors introduced in PostgreSQL 15 + 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 from the PostgreSQL source code and includes classes for every error defined -by PostgreSQL in versions between 9.1 and 13. +by PostgreSQL in versions between 9.1 and 15. Every class in the module is named after what referred as "condition name" `in the documentation`__, converted to CamelCase: e.g. the error 22012, diff --git a/doc/src/install.rst b/doc/src/install.rst index 8d221374..7ac2d14f 100644 --- a/doc/src/install.rst +++ b/doc/src/install.rst @@ -132,7 +132,7 @@ The current `!psycopg2` implementation supports: NOTE: keep consistent with setup.py and the /features/ page. - Python versions from 3.6 to 3.10 -- PostgreSQL server versions from 7.4 to 14 +- PostgreSQL server versions from 7.4 to 15 - PostgreSQL client library version from 9.1 diff --git a/lib/errorcodes.py b/lib/errorcodes.py index b76eb149..aa646c46 100644 --- a/lib/errorcodes.py +++ b/lib/errorcodes.py @@ -223,6 +223,7 @@ SQL_JSON_OBJECT_NOT_FOUND = '2203C' TOO_MANY_JSON_ARRAY_ELEMENTS = '2203D' TOO_MANY_JSON_OBJECT_MEMBERS = '2203E' SQL_JSON_SCALAR_REQUIRED = '2203F' +SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE = '2203G' FLOATING_POINT_EXCEPTION = '22P01' INVALID_TEXT_REPRESENTATION = '22P02' INVALID_BINARY_REPRESENTATION = '22P03' diff --git a/psycopg/sqlstate_errors.h b/psycopg/sqlstate_errors.h index e7177274..38ad78d9 100644 --- a/psycopg/sqlstate_errors.h +++ b/psycopg/sqlstate_errors.h @@ -111,6 +111,7 @@ {"2203D", "TooManyJsonArrayElements"}, {"2203E", "TooManyJsonObjectMembers"}, {"2203F", "SqlJsonScalarRequired"}, +{"2203G", "SqlJsonItemCannotBeCastToTargetType"}, {"22P01", "FloatingPointException"}, {"22P02", "InvalidTextRepresentation"}, {"22P03", "InvalidBinaryRepresentation"}, diff --git a/scripts/make_errorcodes.py b/scripts/make_errorcodes.py index 0a7ee8d6..378ce849 100755 --- a/scripts/make_errorcodes.py +++ b/scripts/make_errorcodes.py @@ -33,7 +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']) + '9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split()) disambiguate(errors) diff --git a/scripts/make_errors.py b/scripts/make_errors.py index 7085c416..59b1b2b7 100755 --- a/scripts/make_errors.py +++ b/scripts/make_errors.py @@ -30,7 +30,7 @@ def main(): # 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']) + '9.1 9.2 9.3 9.4 9.5 9.6 10 11 12 13 14 15'.split()) f = open(filename, "w") print("/*\n * Autogenerated by 'scripts/make_errors.py'.\n */\n", file=f)