mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +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:
1
doc/src/sgml/.gitignore
vendored
1
doc/src/sgml/.gitignore
vendored
@ -16,6 +16,7 @@
|
||||
# GENERATED_SGML
|
||||
/features-supported.sgml
|
||||
/features-unsupported.sgml
|
||||
/errcodes-table.sgml
|
||||
/version.sgml
|
||||
/bookindex.sgml
|
||||
/HTML.index
|
||||
|
@ -52,7 +52,7 @@ override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
|
||||
|
||||
|
||||
GENERATED_SGML = bookindex.sgml version.sgml \
|
||||
features-supported.sgml features-unsupported.sgml
|
||||
features-supported.sgml features-unsupported.sgml errcodes-table.sgml
|
||||
|
||||
ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
|
||||
|
||||
@ -136,6 +136,8 @@ features-supported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.
|
||||
features-unsupported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
|
||||
$(PERL) $(srcdir)/mk_feature_tables.pl NO $^ > $@
|
||||
|
||||
errcodes-table.sgml: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes-table.pl
|
||||
$(PERL) $(srcdir)/generate-errcodes-table.pl $< > $@
|
||||
|
||||
##
|
||||
## Print
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -164,6 +164,8 @@
|
||||
<!entity features-supported SYSTEM "features-supported.sgml">
|
||||
<!entity features-unsupported SYSTEM "features-unsupported.sgml">
|
||||
|
||||
<!entity errcodes-table SYSTEM "errcodes-table.sgml">
|
||||
|
||||
<!-- back matter -->
|
||||
<!entity biblio SYSTEM "biblio.sgml">
|
||||
<!entity bookindex SYSTEM "bookindex.sgml">
|
||||
|
63
doc/src/sgml/generate-errcodes-table.pl
Normal file
63
doc/src/sgml/generate-errcodes-table.pl
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Generate the errcodes-table.sgml file 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";
|
||||
|
||||
open my $errcodes, $ARGV[0] or die;
|
||||
|
||||
while (<$errcodes>) {
|
||||
chomp;
|
||||
|
||||
# Skip comments
|
||||
next if /^#/;
|
||||
next if /^\s*$/;
|
||||
|
||||
# Emit section headers
|
||||
if (/^Section:/) {
|
||||
|
||||
# Remove the Section: string
|
||||
s/^Section: //;
|
||||
# Escape dashes for SGML
|
||||
s/-/—/;
|
||||
# Wrap PostgreSQL in <productname/>
|
||||
s/PostgreSQL/<productname>PostgreSQL<\/>/g;
|
||||
|
||||
print "\n\n";
|
||||
print "<row>\n";
|
||||
print "<entry spanname=\"span13\">";
|
||||
print "<emphasis role=\"bold\">$_</></entry>\n";
|
||||
print "</row>\n";
|
||||
|
||||
next;
|
||||
}
|
||||
|
||||
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
|
||||
|
||||
(my $sqlstate,
|
||||
my $type,
|
||||
my $errcode_macro,
|
||||
my $condition_name) = ($1, $2, $3, $4);
|
||||
|
||||
# Skip lines without PL/pgSQL condition names
|
||||
next unless defined($condition_name);
|
||||
|
||||
my $meaning = $condition_name;
|
||||
# Remove underscores
|
||||
$meaning =~ s/_/ /g;
|
||||
# And capitalize
|
||||
$meaning =~ tr/[a-z]/[A-Z]/;
|
||||
|
||||
print "\n";
|
||||
print "<row>\n";
|
||||
print "<entry><literal>$sqlstate</literal></entry>\n";
|
||||
print "<entry>$meaning</entry>\n";
|
||||
print "<entry>$condition_name</entry>\n";
|
||||
print "</row>\n";
|
||||
}
|
||||
|
||||
close $errcodes;
|
Reference in New Issue
Block a user