diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 13:44:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 13:44:03 +0000 |
commit | 293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch) | |
tree | fc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /doc/src/sgml/generate-errcodes-table.pl | |
parent | Initial commit. (diff) | |
download | postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip |
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/src/sgml/generate-errcodes-table.pl')
-rw-r--r-- | doc/src/sgml/generate-errcodes-table.pl | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/src/sgml/generate-errcodes-table.pl b/doc/src/sgml/generate-errcodes-table.pl new file mode 100644 index 0000000..51f22bd --- /dev/null +++ b/doc/src/sgml/generate-errcodes-table.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# +# Generate the errcodes-table.sgml file from errcodes.txt +# Copyright (c) 2000-2023, PostgreSQL Global Development Group + +use strict; +use warnings; + +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<\/productname>/g; + + print "\n\n"; + print "<row>\n"; + print "<entry spanname=\"span12\">"; + print "<emphasis role=\"bold\">$_</emphasis></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); + + print "\n"; + print "<row>\n"; + print "<entry><literal>$sqlstate</literal></entry>\n"; + print "<entry><symbol>$condition_name</symbol></entry>\n"; + print "</row>\n"; +} + +close $errcodes; |