At update of non-LP_NORMAL TID, fail instead of corrupting page header.
[pgsql.git] / doc / src / sgml / generate-errcodes-table.pl
blobd939eec3f4a8e7b668c2fd97a85cb6054556fe7d
1 #!/usr/bin/perl
3 # Generate the errcodes-table.sgml file from errcodes.txt
4 # Copyright (c) 2000-2025, PostgreSQL Global Development Group
6 use strict;
7 use warnings FATAL => 'all';
9 print
10 "<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
12 open my $errcodes, '<', $ARGV[0] or die;
14 while (<$errcodes>)
16 chomp;
18 # Skip comments
19 next if /^#/;
20 next if /^\s*$/;
22 # Emit section headers
23 if (/^Section:/)
26 # Remove the Section: string
27 s/^Section: //;
29 # Escape dashes for SGML
30 s/-/&mdash;/;
32 # Wrap PostgreSQL in <productname/>
33 s/PostgreSQL/<productname>PostgreSQL<\/productname>/g;
35 print "\n\n";
36 print "<row>\n";
37 print "<entry spanname=\"span12\">";
38 print "<emphasis role=\"bold\">$_</emphasis></entry>\n";
39 print "</row>\n";
41 next;
44 die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
46 (my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
47 ($1, $2, $3, $4);
49 # Skip lines without PL/pgSQL condition names
50 next unless defined($condition_name);
52 print "\n";
53 print "<row>\n";
54 print "<entry><literal>$sqlstate</literal></entry>\n";
55 print "<entry><symbol>$condition_name</symbol></entry>\n";
56 print "</row>\n";
59 close $errcodes;