]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: add errors defined in PostgreSQL 15
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 6 Oct 2022 01:47:46 +0000 (02:47 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 20 Oct 2022 19:21:02 +0000 (21:21 +0200)
docs/api/errors.rst
docs/news.rst
psycopg/psycopg/errors.py
psycopg/psycopg/postgres.py
psycopg_c/psycopg_c/_psycopg/oids.pxd
tools/update_errors.py
tools/update_oids.py

index cd1f3c6b3d435104231fd8f3498f79a07cc02623..c0bc5b2678552ab7b1ec8de9c79b02b927de8fd2 100644 (file)
@@ -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.
index bfc968b4cc058b2ec521d402d2b043c08e9603fe..e1ac84d9fbd3ac79955afc04a4d7d07fd143d2d2 100644 (file)
@@ -7,6 +7,15 @@
 ``psycopg`` release notes
 =========================
 
+Future releases
+---------------
+
+Psycopg 3.1.4 (unreleased)
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Include :ref:`error classes <sqlstate-exceptions>` defined in PostgreSQL 15.
+
+
 Current release
 ---------------
 
index cfb27ee3755693e9b830a3aa00eddeea883b9367..65f001703ddd65013b52f182d95e18778b84ceeb 100644 (file)
@@ -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
index 0a6bdc4d8c4a87a0cf2f56e6fb4f111f929ca974..792a9c8dc0cd5a47fb3c6cae006098d13b60489d 100644 (file)
@@ -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"),
index 1a53bb731df67fda4e85a6152814bb3cc39a18f4..2a864c4a1de03d386b6e6a0f3cb64121f058b8b8 100644 (file)
@@ -11,7 +11,7 @@ cdef enum:
 
     # autogenerated: start
 
-    # Generated from PostgreSQL 14.0
+    # Generated from PostgreSQL 15.0
 
     ACLITEM_OID = 1033
     BIT_OID = 1560
index 638471c611c2eb933b53d8f189225c393ebf1a32..638d3520f706d7556ab26f5a46b11e0502e6624c 100755 (executable)
@@ -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))
index a2dbe743ba9c23c4f8c5d553da0eac9b626a4abc..cdae2e55e882fe8a0af94a0cde752551bafaa1cc 100755 (executable)
@@ -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