Remove pg_regex_collation
[pgsql.git] / src / pl / plpython / generate-spiexceptions.pl
blobf0c5142be3c60f5eeb49d09a36a57806d0156899
1 #!/usr/bin/perl
3 # Generate the spiexceptions.h header from errcodes.txt
4 # Copyright (c) 2000-2024, 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";
11 print "/* there is deliberately not an #ifndef SPIEXCEPTIONS_H here */\n";
13 open my $errcodes, '<', $ARGV[0] or die;
15 while (<$errcodes>)
17 chomp;
19 # Skip comments
20 next if /^#/;
21 next if /^\s*$/;
23 # Skip section headers
24 next if /^Section:/;
26 die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
28 (my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
29 ($1, $2, $3, $4);
31 # Skip non-errors
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 "\n{\n\t\"spiexceptions.$condition_name\", "
41 . "\"$condition_name\", $errcode_macro\n},\n";
44 close $errcodes;