Fix some legacy code to stop warning on newer perls
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / PostgreSQL.pm
index e14a101..a80021e 100644 (file)
@@ -121,9 +121,6 @@ $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
 $::RD_WARN   = 1; # Enable warnings. This will warn on unused rules &c.
 $::RD_HINT   = 1; # Give out hints to help fix problems.
 
-my $parser; # should we do this?  There's no programmic way to 
-            # change the grammar, so I think this is safe.
-
 $GRAMMAR = q!
 
 { my ( %tables, @views, $table_order, $field_order, @table_comments) }
@@ -155,8 +152,11 @@ statement : create
   | select
   | copy
   | readin_symbol
+  | commit
   | <error>
 
+commit : /commit/i ';'
+
 connect : /^\s*\\\connect.*\n/
 
 set : /set/i /[^;]*/ ';'
@@ -613,9 +613,9 @@ pg_data_type :
             $return = { type => 'bytea' };
         }
     |
-    /(timestamptz|timestamp)(?:\(\d\))?( with(out)? time zone)?/i
+    /(timestamptz|timestamp)(?:\(\d\))?( with(?:out)? time zone)?/i
         { 
-            $return = { type => 'timestamp' };
+            $return = { type => 'timestamp' . ($2||'') };
         }
     |
     /text/i
@@ -663,7 +663,7 @@ table_constraint : comment(s?) constraint_name(?) table_constraint_type deferrab
             deferred         => $item{'deferred'},
             reference_table  => $desc->{'reference_table'},
             reference_fields => $desc->{'reference_fields'},
-            match_type       => $desc->{'match_type'}[0],
+            match_type       => $desc->{'match_type'},
             on_delete        => $desc->{'on_delete'} || $desc->{'on_delete_do'},
             on_update        => $desc->{'on_update'} || $desc->{'on_update_do'},
             comments         => [ @comments ],
@@ -721,9 +721,7 @@ deferrable : not(?) /deferrable/i
 
 deferred : /initially/i /(deferred|immediate)/i { $item[2] }
 
-match_type : /match full/i { 'match_full' }
-    |
-    /match partial/i { 'match_partial' }
+match_type : /match/i /partial|full|simple/i { $item[2] }
 
 key_action : key_delete 
     |
@@ -1013,7 +1011,7 @@ VALUE   : /[-+]?\.?\d+(?:[eE]\d+)?/
 # -------------------------------------------------------------------
 sub parse {
     my ( $translator, $data ) = @_;
-    $parser ||= Parse::RecDescent->new($GRAMMAR);
+    my $parser = Parse::RecDescent->new($GRAMMAR);
 
     $::RD_TRACE  = $translator->trace ? 1 : undef;
     $DEBUG       = $translator->debug;