From: Daniele Varrazzo Date: Sun, 29 Aug 2021 06:15:05 +0000 (+0200) Subject: Update errors table to PostgreSQL 14 X-Git-Tag: 3.0.beta1~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e9f483c3e102d7741f0bc582ae5c2f195ef3193;p=thirdparty%2Fpsycopg.git Update errors table to PostgreSQL 14 --- diff --git a/docs/api/errors.rst b/docs/api/errors.rst index b735bb5c4..388d3870c 100644 --- a/docs/api/errors.rst +++ b/docs/api/errors.rst @@ -129,7 +129,7 @@ in the database: locked = True The exception names are generated from the PostgreSQL source code and includes -classes for every error defined by PostgreSQL in versions between 9.6 and 13. +classes for every error defined by PostgreSQL in versions between 9.6 and 14. Every class in the module is named after what referred as "condition name" `in the documentation`__, converted to CamelCase: e.g. the error 22012, ``division_by_zero`` is exposed by this module as the class `!DivisionByZero`. @@ -441,6 +441,7 @@ SQLSTATE Exception Base exception ``57P02`` `!CrashShutdown` `!OperationalError` ``57P03`` `!CannotConnectNow` `!OperationalError` ``57P04`` `!DatabaseDropped` `!OperationalError` +``57P05`` `!IdleSessionTimeout` `!OperationalError` **Class 58**: Class 58 - System Error (errors external to PostgreSQL itself) --------------------------------------------------------------------------------- ``58000`` `!SystemError` `!OperationalError` diff --git a/psycopg/psycopg/errors.py b/psycopg/psycopg/errors.py index 86d163f7e..9e25986d1 100644 --- a/psycopg/psycopg/errors.py +++ b/psycopg/psycopg/errors.py @@ -1502,6 +1502,11 @@ class DatabaseDropped(OperationalError): pass +@sqlcode("IDLE_SESSION_TIMEOUT", "57P05") +class IdleSessionTimeout(OperationalError): + pass + + # Class 58 - System Error (errors external to PostgreSQL itself) diff --git a/tools/update_errors.py b/tools/update_errors.py index bae1247ac..a9196b5dc 100755 --- a/tools/update_errors.py +++ b/tools/update_errors.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# type: ignore """ Generate per-sqlstate errors from PostgreSQL source code. @@ -7,7 +8,6 @@ The script can be run at a new PostgreSQL release to refresh the module. # Copyright (C) 2020-2021 The Psycopg Team - import os import re import sys @@ -16,7 +16,7 @@ import subprocess as sp from urllib.request import urlopen from collections import defaultdict, namedtuple -from psycopg.errors import get_base_exception # type: ignore +from psycopg.errors import get_base_exception logger = logging.getLogger() logging.basicConfig( @@ -25,7 +25,7 @@ logging.basicConfig( def main(): - classes, errors = fetch_errors(["9.6", "10", "11", "12", "13"]) + classes, errors = fetch_errors(["9.6", "10", "11", "12", "13", "14"]) fn = os.path.dirname(__file__) + "/../psycopg/psycopg/errors.py" update_file(fn, generate_module_data(classes, errors))