~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/generate-errcodes-table.pl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# Generate the errcodes-table.sgml file from errcodes.txt
 
4
# Copyright (c) 2000-2011, PostgreSQL Global Development Group
 
5
 
 
6
use warnings;
 
7
use strict;
 
8
 
 
9
print "<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
 
10
 
 
11
open my $errcodes, $ARGV[0] or die;
 
12
 
 
13
while (<$errcodes>) {
 
14
    chomp;
 
15
 
 
16
    # Skip comments
 
17
    next if /^#/;
 
18
    next if /^\s*$/;
 
19
 
 
20
    # Emit section headers
 
21
    if (/^Section:/) {
 
22
 
 
23
        # Remove the Section: string
 
24
        s/^Section: //;
 
25
        # Escape dashes for SGML
 
26
        s/-/&mdash;/;
 
27
        # Wrap PostgreSQL in <productname/>
 
28
        s/PostgreSQL/<productname>PostgreSQL<\/>/g;
 
29
 
 
30
        print "\n\n";
 
31
        print "<row>\n";
 
32
        print "<entry spanname=\"span13\">";
 
33
        print "<emphasis role=\"bold\">$_</></entry>\n";
 
34
        print "</row>\n";
 
35
 
 
36
        next;
 
37
    }
 
38
 
 
39
    die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
 
40
 
 
41
    (my $sqlstate,
 
42
     my $type,
 
43
     my $errcode_macro,
 
44
     my $condition_name) = ($1, $2, $3, $4);
 
45
 
 
46
    # Skip lines without PL/pgSQL condition names
 
47
    next unless defined($condition_name);
 
48
 
 
49
    my $meaning = $condition_name;
 
50
    # Remove underscores
 
51
    $meaning =~ s/_/ /g;
 
52
    # And capitalize
 
53
    $meaning =~ tr/[a-z]/[A-Z]/;
 
54
 
 
55
    print "\n";
 
56
    print "<row>\n";
 
57
    print "<entry><literal>$sqlstate</literal></entry>\n";
 
58
    print "<entry>$meaning</entry>\n";
 
59
    print "<entry>$condition_name</entry>\n";
 
60
    print "</row>\n";
 
61
}
 
62
 
 
63
close $errcodes;