1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-17 01:02:17 +03:00

Avoid maintaining three separate copies of the error codes list.

src/pl/plpgsql/src/plerrcodes.h, src/include/utils/errcodes.h, and a
big chunk of errcodes.sgml are now automatically generated from a single
file, src/backend/utils/errcodes.txt.

Jan Urbański, reviewed by Tom Lane.
This commit is contained in:
Robert Haas
2011-02-03 22:32:49 -05:00
parent 7212c77d0c
commit ddfe26f644
20 changed files with 646 additions and 2848 deletions

View File

@@ -0,0 +1,41 @@
#!/usr/bin/perl
#
# Generate the errcodes.h header from errcodes.txt
# Copyright (c) 2000-2011, PostgreSQL Global Development Group
use warnings;
use strict;
print "/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print "/* there is deliberately not an #ifndef ERRCODES_H here */\n";
open my $errcodes, $ARGV[0] or die;
while (<$errcodes>) {
chomp;
# Skip comments
next if /^#/;
next if /^\s*$/;
# Emit a comment for each section header
if (/^Section:(.*)/) {
my $header = $1;
$header =~ s/^\s+//;
print "\n/* $header */\n";
next;
}
die "unable to parse errcodes.txt" unless /^([^\s]{5})\s+[EWS]\s+([^\s]+)/;
(my $sqlstate, my $errcode_macro) = ($1, $2);
# Split the sqlstate letters
$sqlstate = join ",", split "", $sqlstate;
# And quote them
$sqlstate =~ s/([^,])/'$1'/g;
print "#define $errcode_macro MAKE_SQLSTATE($sqlstate)\n";
}
close $errcodes;