]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Errors and builtin oids updated to PostgreSQL 13
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 9 Nov 2020 23:45:07 +0000 (23:45 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 10 Nov 2020 01:40:07 +0000 (01:40 +0000)
psycopg3/psycopg3/errors.py
psycopg3/psycopg3/oids.py
tools/update_errors.py

index db610f69858c7d02e3334005da779bd1a9568876..e59528df174a3d919173b534e3bd7009af7fb13f 100644 (file)
@@ -697,6 +697,11 @@ class DuplicateJsonObjectKeyValue(DataError):
     pass
 
 
+@sqlcode("22031")
+class InvalidArgumentForSqlJsonDatetimeFunction(DataError):
+    pass
+
+
 @sqlcode("22032")
 class InvalidJsonText(DataError):
     pass
index 99c5f75136d9471ce5a34653d512e6f738d6a6ae..394f5ccc8869734a2dcf585e734cb2533a92801c 100644 (file)
@@ -85,15 +85,21 @@ class TypesRegistry:
 
 builtins = TypesRegistry()
 
+# In order to update the registry, just execute this file, using the PG*
+# env vars to point to a running PostgreSQL instance of the desired version.
 for r in [
     # fmt: off
     # autogenerated: start
 
-    # Generated from PostgreSQL 12.2
+    # Generated from PostgreSQL 13.0
 
     ('aclitem', 1033, 1034, 'aclitem', ','),
     ('any', 2276, 0, '"any"', ','),
     ('anyarray', 2277, 0, 'anyarray', ','),
+    ('anycompatible', 5077, 0, 'anycompatible', ','),
+    ('anycompatiblearray', 5078, 0, 'anycompatiblearray', ','),
+    ('anycompatiblenonarray', 5079, 0, 'anycompatiblenonarray', ','),
+    ('anycompatiblerange', 5080, 0, 'anycompatiblerange', ','),
     ('anyelement', 2283, 0, 'anyelement', ','),
     ('anyenum', 3500, 0, 'anyenum', ','),
     ('anynonarray', 2776, 0, 'anynonarray', ','),
@@ -136,7 +142,6 @@ for r in [
     ('numrange', 3906, 3907, 'numrange', ','),
     ('oid', 26, 1028, 'oid', ','),
     ('oidvector', 30, 1013, 'oidvector', ','),
-    ('opaque', 2282, 0, 'opaque', ','),
     ('path', 602, 1019, 'path', ','),
     ('point', 600, 1017, 'point', ','),
     ('polygon', 604, 1027, 'polygon', ','),
@@ -160,6 +165,7 @@ for r in [
     ('varchar', 1043, 1015, 'character varying', ','),
     ('void', 2278, 0, 'void', ','),
     ('xid', 28, 1011, 'xid', ','),
+    ('xid8', 5069, 271, 'xid8', ','),
     ('xml', 142, 143, 'xml', ','),
     # autogenerated: end
     # fmt: on
index 83b8b9aee3ab87241ff639d3d94e35ff50d0f07b..4ec60f18044d14dc0e8076db82abc2d372c96162 100755 (executable)
@@ -10,15 +10,22 @@ The script can be run at a new PostgreSQL release to refresh the module.
 import os
 import re
 import sys
+import logging
+import subprocess as sp
 from urllib.request import urlopen
 from collections import defaultdict
 
 from psycopg3.errors import get_base_exception
 
+logger = logging.getLogger()
+logging.basicConfig(
+    level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s"
+)
+
 
 def main():
 
-    fn = os.path.dirname(__file__) + "/../psycopg3/errors.py"
+    fn = os.path.dirname(__file__) + "/../psycopg3/psycopg3/errors.py"
 
     with open(fn, "r") as f:
         lines = f.read().splitlines()
@@ -29,13 +36,16 @@ def main():
         if re.match(r"\s*#\s*autogenerated:\s+(start|end)", line)
     ]
 
-    classes, errors = fetch_errors(["9.5", "9.6", "10", "11", "12"])
+    classes, errors = fetch_errors(["9.5", "9.6", "10", "11", "12", "13"])
     lines[istart + 1 : iend] = generate_module_data(classes, errors)
 
     with open(fn, "w") as f:
         for line in lines:
             f.write(line + "\n")
 
+    logger.info("running black on the resulting module")
+    sp.check_call(["black", fn])
+
 
 def parse_errors_txt(url):
     classes = {}
@@ -85,7 +95,7 @@ def fetch_errors(versions):
     errors = defaultdict(dict)
 
     for version in versions:
-        print(version, file=sys.stderr)
+        logger.info("fetching errors from version %s", version)
         tver = tuple(map(int, version.split()[0].split(".")))
         tag = "%s%s_STABLE" % (
             (tver[0] >= 10 and "REL_" or "REL"),