3
# Generate the spiexceptions.h header from errcodes.txt
4
# Copyright (c) 2000-2011, PostgreSQL Global Development Group
9
print "/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
10
print "/* there is deliberately not an #ifndef SPIEXCEPTIONS_H here */\n";
12
open my $errcodes, $ARGV[0] or die;
21
# Skip section headers
24
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
29
my $condition_name) = ($1, $2, $3, $4);
32
next unless $type eq 'E';
34
# Skip lines without PL/pgSQL condition names
35
next unless defined($condition_name);
37
# Change some_error_condition to SomeErrorCondition
38
$condition_name =~ s/([a-z])([^_]*)(?:_|$)/\u$1$2/g;
40
print "{ \"spiexceptions.$condition_name\", " .
41
"\"$condition_name\", $errcode_macro },\n";