From: Daniele Varrazzo Date: Thu, 6 Oct 2022 01:47:46 +0000 (+0100) Subject: chore: add errors defined in PostgreSQL 15 X-Git-Tag: 3.1.4~6^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=273aec42a84aea9e7291da4ea5d0bc5c0b917800;p=thirdparty%2Fpsycopg.git chore: add errors defined in PostgreSQL 15 --- diff --git a/docs/api/errors.rst b/docs/api/errors.rst index cd1f3c6b3..c0bc5b267 100644 --- a/docs/api/errors.rst +++ b/docs/api/errors.rst @@ -305,6 +305,7 @@ SQLSTATE Exception Base exception ``2203D`` `!TooManyJsonArrayElements` `!DataError` ``2203E`` `!TooManyJsonObjectMembers` `!DataError` ``2203F`` `!SqlJsonScalarRequired` `!DataError` +``2203G`` `!SqlJsonItemCannotBeCastToTargetType` `!DataError` ``22P01`` `!FloatingPointException` `!DataError` ``22P02`` `!InvalidTextRepresentation` `!DataError` ``22P03`` `!InvalidBinaryRepresentation` `!DataError` @@ -531,3 +532,7 @@ SQLSTATE Exception Base exception ========= ================================================== ==================== .. autogenerated: end + +.. versionadded:: 3.1.4 + Exception `!SqlJsonItemCannotBeCastToTargetType`, introduced in PostgreSQL + 15. diff --git a/docs/news.rst b/docs/news.rst index bfc968b4c..e1ac84d9f 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -7,6 +7,15 @@ ``psycopg`` release notes ========================= +Future releases +--------------- + +Psycopg 3.1.4 (unreleased) +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Include :ref:`error classes ` defined in PostgreSQL 15. + + Current release --------------- diff --git a/psycopg/psycopg/errors.py b/psycopg/psycopg/errors.py index cfb27ee37..65f001703 100644 --- a/psycopg/psycopg/errors.py +++ b/psycopg/psycopg/errors.py @@ -773,6 +773,10 @@ class SqlJsonScalarRequired(DataError, code='2203F', name='SQL_JSON_SCALAR_REQUIRED'): pass +class SqlJsonItemCannotBeCastToTargetType(DataError, + code='2203G', name='SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE'): + pass + class FloatingPointException(DataError, code='22P01', name='FLOATING_POINT_EXCEPTION'): pass diff --git a/psycopg/psycopg/postgres.py b/psycopg/psycopg/postgres.py index 0a6bdc4d8..792a9c8dc 100644 --- a/psycopg/psycopg/postgres.py +++ b/psycopg/psycopg/postgres.py @@ -18,7 +18,7 @@ adapters = AdaptersMap(types=types) for t in [ TypeInfo('"char"', 18, 1002), # autogenerated: start - # Generated from PostgreSQL 14.0 + # Generated from PostgreSQL 15.0 TypeInfo("aclitem", 1033, 1034), TypeInfo("bit", 1560, 1561), TypeInfo("bool", 16, 1000, regtype="boolean"), diff --git a/psycopg_c/psycopg_c/_psycopg/oids.pxd b/psycopg_c/psycopg_c/_psycopg/oids.pxd index 1a53bb731..2a864c4a1 100644 --- a/psycopg_c/psycopg_c/_psycopg/oids.pxd +++ b/psycopg_c/psycopg_c/_psycopg/oids.pxd @@ -11,7 +11,7 @@ cdef enum: # autogenerated: start - # Generated from PostgreSQL 14.0 + # Generated from PostgreSQL 15.0 ACLITEM_OID = 1033 BIT_OID = 1560 diff --git a/tools/update_errors.py b/tools/update_errors.py index 638471c61..638d3520f 100755 --- a/tools/update_errors.py +++ b/tools/update_errors.py @@ -22,7 +22,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(mess def main(): - classes, errors = fetch_errors(["9.6", "10", "11", "12", "13", "14"]) + classes, errors = fetch_errors("9.6 10 11 12 13 14 15".split()) fn = os.path.dirname(__file__) + "/../psycopg/psycopg/errors.py" update_file(fn, generate_module_data(classes, errors)) diff --git a/tools/update_oids.py b/tools/update_oids.py index a2dbe743b..cdae2e55e 100755 --- a/tools/update_oids.py +++ b/tools/update_oids.py @@ -4,6 +4,14 @@ Update the maps of builtin types and names. This script updates some of the files in psycopg source code with data read from a database catalog. + +Hint: use docker to upgrade types from a new version in isolation. Run: + + docker run --rm -p 11111:5432 --name pg -e POSTGRES_PASSWORD=password postgres:TAG + +with a specified version tag, and then query it using: + + %(prog)s "host=localhost port=11111 user=postgres password=password" """ import re @@ -197,7 +205,9 @@ def update_file(fn: Path, new: List[str]) -> None: def parse_cmdline() -> argparse.Namespace: - parser = argparse.ArgumentParser(description=__doc__) + parser = argparse.ArgumentParser( + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter + ) parser.add_argument("dsn", help="where to connect to") opt = parser.parse_args() return opt