2011-02-04 04:32:49 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# Generate the errcodes-table.sgml file from errcodes.txt
|
2016-01-02 19:33:40 +01:00
|
|
|
# Copyright (c) 2000-2016, PostgreSQL Global Development Group
|
2011-02-04 04:32:49 +01:00
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
print
|
|
|
|
"<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
|
2011-02-04 04:32:49 +01:00
|
|
|
|
|
|
|
open my $errcodes, $ARGV[0] or die;
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
while (<$errcodes>)
|
|
|
|
{
|
|
|
|
chomp;
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# Skip comments
|
|
|
|
next if /^#/;
|
|
|
|
next if /^\s*$/;
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# Emit section headers
|
|
|
|
if (/^Section:/)
|
|
|
|
{
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# Remove the Section: string
|
|
|
|
s/^Section: //;
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# Escape dashes for SGML
|
|
|
|
s/-/—/;
|
|
|
|
|
|
|
|
# Wrap PostgreSQL in <productname/>
|
|
|
|
s/PostgreSQL/<productname>PostgreSQL<\/>/g;
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
print "\n\n";
|
|
|
|
print "<row>\n";
|
|
|
|
print "<entry spanname=\"span12\">";
|
|
|
|
print "<emphasis role=\"bold\">$_</></entry>\n";
|
|
|
|
print "</row>\n";
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
next;
|
|
|
|
}
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
(my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
|
|
|
|
($1, $2, $3, $4);
|
2011-02-04 04:32:49 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
# Skip lines without PL/pgSQL condition names
|
|
|
|
next unless defined($condition_name);
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
print "<row>\n";
|
|
|
|
print "<entry><literal>$sqlstate</literal></entry>\n";
|
|
|
|
print "<entry><symbol>$condition_name</symbol></entry>\n";
|
|
|
|
print "</row>\n";
|
2011-02-04 04:32:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
close $errcodes;
|