quoting and escaping for SQLite, MySQL, PostgreSQL, SQLServer and
Oracle (RT#90700, RT#31034)
* Add support for ALTER TABLE ... ADD CONSTRAINT to Oracle parser
+ * Add trigger support to Oracle parser (RT#62927)
0.11020 2014-09-02
our $GRAMMAR = <<'END_OF_GRAMMAR';
-{ my ( %tables, %indices, %constraints, $table_order, @table_comments, %views, $view_order, %procedures, $proc_order ) }
+{ my ( %tables, %indices, %constraints, $table_order, @table_comments, %views, $view_order, %procedures, $proc_order, %triggers, $trigger_order ) }
#
# The "eofile" rule makes the parser fail if any "statement" rule
constraints => \%constraints,
views => \%views,
procedures => \%procedures,
+ triggers => \%triggers,
};
}
$return = "$item[2]($arg_list)";
}
+create : /create/i /or replace/i /trigger/i table_name not_end m#^/$#im
+ {
+ @table_comments = ();
+ my $trigger_name = $item[4];
+ # Hack to strip owner from trigger name
+ $trigger_name =~ s#.*\.##;
+ my $owner = '';
+ my $action = "$item[1] $item[2] $item[3] $item[4] $item[5]";
+
+ $triggers{ $trigger_name }{'order'} = ++$trigger_order;
+ $triggers{ $trigger_name }{'name'} = $trigger_name;
+ $triggers{ $trigger_name }{'owner'} = $owner;
+ $triggers{ $trigger_name }{'action'} = $action;
+ }
+
create : /create/i /or replace/i /procedure/i table_name not_end m#^/$#im
{
@table_comments = ();
);
}
+ my @triggers = sort {
+ $result->{triggers}->{ $a }->{'order'} <=> $result->{triggers}->{ $b }->{'order'}
+ } keys %{ $result->{triggers} };
+ foreach my $trigger_name (@triggers) {
+ $schema->add_trigger(
+ name => $trigger_name,
+ action => $result->{triggers}->{$trigger_name}->{action},
+ );
+ }
+
return 1;
}