mirror of https://github.com/postgres/postgres
We don't really want to encourage people to write numeric SQLSTATEs in programs; that's unreadable and error-prone. Copy plpgsql's infrastructure for converting between SQLSTATEs and exception names shown in Appendix A, and modify examples in tests and documentation to do it that way.pull/11/head
parent
fb8d2a7f57
commit
cd37bb7859
@ -0,0 +1,40 @@ |
||||
#!/usr/bin/perl |
||||
# |
||||
# Generate the pltclerrcodes.h header from errcodes.txt |
||||
# Copyright (c) 2000-2016, PostgreSQL Global Development Group |
||||
|
||||
use warnings; |
||||
use strict; |
||||
|
||||
print |
||||
"/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n"; |
||||
print "/* there is deliberately not an #ifndef PLTCLERRCODES_H here */\n"; |
||||
|
||||
open my $errcodes, $ARGV[0] or die; |
||||
|
||||
while (<$errcodes>) |
||||
{ |
||||
chomp; |
||||
|
||||
# Skip comments |
||||
next if /^#/; |
||||
next if /^\s*$/; |
||||
|
||||
# Skip section headers |
||||
next if /^Section:/; |
||||
|
||||
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 non-errors |
||||
next unless $type eq 'E'; |
||||
|
||||
# Skip lines without PL/pgSQL condition names |
||||
next unless defined($condition_name); |
||||
|
||||
print "{\n\t\"$condition_name\", $errcode_macro\n},\n\n"; |
||||
} |
||||
|
||||
close $errcodes; |
||||
Loading…
Reference in new issue