Re: [Bug Fix] ECPG: could not use set xxx to default statement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [Bug Fix] ECPG: could not use set xxx to default statement
Дата
Msg-id 22431.1550864192@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [Bug Fix] ECPG: could not use set xxx to default statement  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Ответы Re: [Bug Fix] ECPG: could not use set xxx to default statement  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> On 2/19/19 9:29 AM, Tom Lane wrote:
>> Probably, somebody who's a better Perl programmer than me
>> ought to take point on improving that.

> Agreed.

Not seeing any motion on this, here's a draft patch to make these
scripts complain about missing semicolons.  Against the current
gram.y (which contains 2 such errors, as Michael noted) you
get output like

'/usr/bin/perl' ./parse.pl . < ../../../backend/parser/gram.y > preproc.y
unterminated rule at ./parse.pl line 370, <> line 1469.
make: *** [preproc.y] Error 255
make: *** Deleting file `preproc.y'

That's not *super* friendly, but it does give you the right line number
to look at in gram.y.  We could adjust the script (and the Makefile)
further so that the message would cite the gram.y filename, but I'm not
sure if it's worth the trouble.  Thoughts?

            regards, tom lane

diff --git a/src/interfaces/ecpg/preproc/check_rules.pl b/src/interfaces/ecpg/preproc/check_rules.pl
index 1388d05..3daff88 100644
--- a/src/interfaces/ecpg/preproc/check_rules.pl
+++ b/src/interfaces/ecpg/preproc/check_rules.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # src/interfaces/ecpg/preproc/check_rules.pl
 # test parser generator for ecpg
-# call with backend parser as stdin
+# call with backend grammar as stdin
 #
 # Copyright (c) 2009-2019, PostgreSQL Global Development Group
 #
@@ -47,6 +47,7 @@ my %replace_line = (

 my $block        = '';
 my $yaccmode     = 0;
+my $in_rule      = 0;
 my $brace_indent = 0;
 my (@arr, %found);
 my $comment     = 0;
@@ -131,10 +132,13 @@ while (<$parser_fh>)
             $found{$block} = 1;
             $cc++;
             $block = '';
+            $in_rule = 0 if $arr[$fieldIndexer] eq ';';
         }
         elsif (($arr[$fieldIndexer] =~ '[A-Za-z0-9]+:')
             || $arr[ $fieldIndexer + 1 ] eq ':')
         {
+            die "unterminated rule" if $in_rule;
+            $in_rule     = 1;
             $non_term_id = $arr[$fieldIndexer];
             $non_term_id =~ tr/://d;
         }
@@ -145,6 +149,8 @@ while (<$parser_fh>)
     }
 }

+die "unterminated rule" if $in_rule;
+
 close $parser_fh;
 if ($verbose)
 {
diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl
index 6dee500..e219398 100644
--- a/src/interfaces/ecpg/preproc/parse.pl
+++ b/src/interfaces/ecpg/preproc/parse.pl
@@ -22,6 +22,7 @@ $path = "." unless $path;
 my $copymode              = 0;
 my $brace_indent          = 0;
 my $yaccmode              = 0;
+my $in_rule               = 0;
 my $header_included       = 0;
 my $feature_not_supported = 0;
 my $tokenmode             = 0;
@@ -288,6 +289,7 @@ sub main
                 @fields  = ();
                 $infield = 0;
                 $line    = '';
+                $in_rule = 0;
                 next;
             }

@@ -365,6 +367,8 @@ sub main
                 $line    = '';
                 @fields  = ();
                 $infield = 1;
+                die "unterminated rule" if $in_rule;
+                $in_rule = 1;
                 next;
             }
             elsif ($copymode)
@@ -415,6 +419,7 @@ sub main
             }
         }
     }
+    die "unterminated rule" if $in_rule;
     return;
 }


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Euler Taveira
Дата:
Сообщение: Re: Temporal Table Proposal
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Pluggable Storage - Andres's take