Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSQsh-0002Sj-65 for pgsql-sql@arkaria.postgresql.org; Fri, 22 Dec 2017 17:13:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSQsg-0006f4-OY for pgsql-sql@arkaria.postgresql.org; Fri, 22 Dec 2017 17:13:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eSQsg-0006ev-Is for pgsql-sql@lists.postgresql.org; Fri, 22 Dec 2017 17:13:10 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eSQse-0001av-EH for pgsql-sql@lists.postgresql.org; Fri, 22 Dec 2017 17:13:10 +0000 Received: from [192.168.42.103] ([82.113.98.244]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MT3QL-1eZt1P1H8v-00RoVN for ; Fri, 22 Dec 2017 18:13:07 +0100 Subject: Re: SQL conformity regarding SQLSTATE To: pgsql-sql@lists.postgresql.org References: <31999.1513697414@sss.pgh.pa.us> <11558.1513819695@sss.pgh.pa.us> <6f4d8b10-0d24-86f5-3e14-b3d362181381@purtz.de> <2414.1513875032@sss.pgh.pa.us> From: =?UTF-8?Q?J=c3=bcrgen_Purtz?= Message-ID: Date: Fri, 22 Dec 2017 18:15:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <2414.1513875032@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------7EEA57336BBFEAA58856F436" Content-Language: en-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Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7EEA57336BBFEAA58856F436 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit > I think what might make sense is to rewrite generate-errcodes-table.pl > so that it sorts the entries for itself rather than relying on the > input file to determine the order. > OK, tested for HTML and PDF output. Kind regards Jürgen Purtz --------------7EEA57336BBFEAA58856F436 Content-Type: application/x-perl; name="generate-errcodes-table.pl" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="generate-errcodes-table.pl" #!/usr/bin/perl # # Generate the errcodes-table.sgml file from errcodes.txt # Copyright (c) 2000-2017, PostgreSQL Global Development Group use warnings; use strict; # A hash to store those lines, which belong to the same class/section, # with the intention to sort them before printing my %linesInClass; print "\n"; open my $errcodes, '<', $ARGV[0] or die; while (<$errcodes>) { chomp; # Skip comments next if /^#/; next if /^\s*$/; # Emit section headers if (/^Section:/) { # print previous section generateLines(); # Remove the Section: string s/^Section: //; # Escape dashes for SGML s/-/—/; # Wrap PostgreSQL in s/PostgreSQL/PostgreSQL<\/>/g; print "\n\n"; print "\n"; print ""; print "$_\n"; print "\n"; next; } 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 lines without PL/pgSQL condition names next unless defined($condition_name); # store sqlcode and text $linesInClass{$1} = $4; } # last section generateLines(); close $errcodes; # Sort lines according to SQLCODE, generate output, and re-initialize the hash sub generateLines { foreach my $sqlstate ( sort keys %linesInClass ) { print "\n"; print "\n"; print "$sqlstate\n"; print "$linesInClass{$sqlstate}\n"; print "\n"; } undef %linesInClass; } --------------7EEA57336BBFEAA58856F436 Content-Type: text/x-patch; name="generate-errcodes-table.pl.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="generate-errcodes-table.pl.patch" commit 817d377437f2e23da0189df7e3417a5956e3053a Author: JuergenPurtz Date: Fri Dec 22 17:21:48 2017 +0100 sort SQLCODE within class/section for generated output diff --git a/doc/src/sgml/generate-errcodes-table.pl b/doc/src/sgml/generate-errcodes-table.pl index 01fc616..21779a5 100644 --- a/doc/src/sgml/generate-errcodes-table.pl +++ b/doc/src/sgml/generate-errcodes-table.pl @@ -6,6 +6,10 @@ use warnings; use strict; +# A hash to store those lines, which belong to the same class/section, +# with the intention to sort them before printing +my %linesInClass; + print "\n"; @@ -23,6 +27,9 @@ while (<$errcodes>) if (/^Section:/) { + # print previous section + generateLines(); + # Remove the Section: string s/^Section: //; @@ -49,11 +56,24 @@ while (<$errcodes>) # Skip lines without PL/pgSQL condition names next unless defined($condition_name); - print "\n"; - print "\n"; - print "$sqlstate\n"; - print "$condition_name\n"; - print "\n"; + # store sqlcode and text + $linesInClass{$1} = $4; + } +# last section +generateLines(); + close $errcodes; + +# Sort lines according to SQLCODE, generate output, and re-initialize the hash +sub generateLines { + foreach my $sqlstate ( sort keys %linesInClass ) { + print "\n"; + print "\n"; + print "$sqlstate\n"; + print "$linesInClass{$sqlstate}\n"; + print "\n"; + } + undef %linesInClass; +} --------------7EEA57336BBFEAA58856F436--