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' '42P01'
Constants representing all the error values defined by PostgreSQL versions 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) .. autofunction:: lookup(code)

View File

@ -32,10 +32,10 @@ def main():
filename = sys.argv[1] filename = sys.argv[1]
file_start = read_base_file(filename) 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( classes, errors = fetch_errors(
['8.1', '8.2', '8.3', '8.4', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5', ['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") f = open(filename, "w")
for line in file_start: for line in file_start:
@ -146,13 +146,18 @@ def fetch_errors(versions):
if tver < (9, 1): if tver < (9, 1):
c1, e1 = parse_errors_sgml(errors_sgml_url % version) c1, e1 = parse_errors_sgml(errors_sgml_url % version)
else: else:
# TODO: move to 10 stable when released. tag = '%s%s_STABLE' % (
if version == '10 b1': (tver[0] >= 10 and 'REL_' or 'REL'),
tag = 'REL_10_BETA1' version.replace('.', '_'))
else:
tag = 'REL%s_STABLE' % version.replace('.', '_')
c1, e1 = parse_errors_txt(errors_txt_url % tag) c1, e1 = parse_errors_txt(errors_txt_url % tag)
classes.update(c1) 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(): for c, cerrs in e1.iteritems():
errors[c].update(cerrs) errors[c].update(cerrs)