Parse PG 10 error codes from final version

This commit is contained in:
Daniele Varrazzo 2017-10-19 02:16:27 +01:00
parent 582fd95986
commit f1461d2d7e
2 changed files with 13 additions and 8 deletions

View File

@ -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 10 beta 1 are included in the module.
between 8.1 and 10 are included in the module.
.. autofunction:: lookup(code)

View File

@ -32,10 +32,10 @@ def main():
filename = sys.argv[1]
file_start = read_base_file(filename)
# If you add a version to the list fix the docs (errorcodes.rst, err.rst)
# If you add a version to the list fix the docs (in errorcodes.rst)
classes, errors = fetch_errors(
['8.1', '8.2', '8.3', '8.4', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5',
'9.6', '10 b1'])
'9.6', '10'])
f = open(filename, "w")
for line in file_start:
@ -146,13 +146,18 @@ def fetch_errors(versions):
if tver < (9, 1):
c1, e1 = parse_errors_sgml(errors_sgml_url % version)
else:
# TODO: move to 10 stable when released.
if version == '10 b1':
tag = 'REL_10_BETA1'
else:
tag = 'REL%s_STABLE' % version.replace('.', '_')
tag = '%s%s_STABLE' % (
(tver[0] >= 10 and 'REL_' or 'REL'),
version.replace('.', '_'))
c1, e1 = parse_errors_txt(errors_txt_url % tag)
classes.update(c1)
# TODO: this error was added in PG 10 beta 1 but dropped in the
# final release. It doesn't harm leaving it in the file. Check if it
# will be added back in PG 11.
# https://github.com/postgres/postgres/commit/28e0727076
errors['55']['55P04'] = 'UNSAFE_NEW_ENUM_VALUE_USAGE'
for c, cerrs in e1.iteritems():
errors[c].update(cerrs)