You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate-errcodes-table.pl 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/perl
  2. #
  3. # Generate the errcodes-table.sgml file from errcodes.txt
  4. # Copyright (c) 2000-2019, PostgreSQL Global Development Group
  5. use warnings;
  6. use strict;
  7. print
  8. "<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
  9. open my $errcodes, '<', $ARGV[0] or die;
  10. while (<$errcodes>)
  11. {
  12. chomp;
  13. # Skip comments
  14. next if /^#/;
  15. next if /^\s*$/;
  16. # Emit section headers
  17. if (/^Section:/)
  18. {
  19. # Remove the Section: string
  20. s/^Section: //;
  21. # Escape dashes for SGML
  22. s/-/&mdash;/;
  23. # Wrap PostgreSQL in <productname/>
  24. s/PostgreSQL/<productname>PostgreSQL<\/productname>/g;
  25. print "\n\n";
  26. print "<row>\n";
  27. print "<entry spanname=\"span12\">";
  28. print "<emphasis role=\"bold\">$_</emphasis></entry>\n";
  29. print "</row>\n";
  30. next;
  31. }
  32. die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
  33. (my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
  34. ($1, $2, $3, $4);
  35. # Skip lines without PL/pgSQL condition names
  36. next unless defined($condition_name);
  37. print "\n";
  38. print "<row>\n";
  39. print "<entry><literal>$sqlstate</literal></entry>\n";
  40. print "<entry><symbol>$condition_name</symbol></entry>\n";
  41. print "</row>\n";
  42. }
  43. close $errcodes;