| connect
| update
| set
+ | select
+ | copy
+ | readin_symbol
| <error>
connect : /^\s*\\\connect.*\n/
}
}
+revoke : /revoke/i WORD(s /,/) /on/i SCHEMA(?) schema_name /from/i name_with_opt_quotes(s /,/) ';'
+ { 1 }
+
grant : /grant/i WORD(s /,/) /on/i TABLE(?) table_name /to/i name_with_opt_quotes(s /,/) ';'
{
my $table_info = $item{'table_name'};
}
}
+grant : /grant/i WORD(s /,/) /on/i SCHEMA(?) schema_name /to/i name_with_opt_quotes(s /,/) ';'
+ { 1 }
+
drop : /drop/i /[^;]*/ ';'
string :
schema_qualification : name_with_opt_quotes '.'
+schema_name : name_with_opt_quotes
+
field_name : name_with_opt_quotes
name_with_opt_quotes : double_quote(?) NAME double_quote(?) { $item[2] }
alter : alter_table table_name /owner/i /to/i NAME ';'
{ 1 }
+alter : alter_sequence NAME /owned/i /by/i column_name ';'
+ { 1 }
+
storage_type : /(plain|external|extended|main)/i
alter_default_val : SET default_val
alter_table : ALTER TABLE ONLY(?)
+alter_sequence : ALTER SEQUENCE
+
drop_column : DROP COLUMN(?)
alter_column : ALTER COLUMN(?)
restrict_or_cascade : /restrict/i |
/cascade/i
+# Handle functions that can be called
+select : SELECT select_function ';'
+ { 1 }
+
+# Read the setval function but don't do anything with it because this parser
+# isn't handling sequences
+select_function : schema_qualification(?) /setval/i '(' VALUE /,/ VALUE /,/ /(true|false)/i ')'
+ { 1 }
+
+# Skipping all COPY commands
+copy : COPY WORD /[^;]+/ ';' { 1 }
+ { 1 }
+
+# The "\." allows reading in from STDIN but this isn't needed for schema
+# creation, so it is skipped.
+readin_symbol : '\.'
+ {1}
+
#
# End basically useless stuff. - ky
#
TABLE : /table/i
+SCHEMA : /schema/i
+
SEMICOLON : /\s*;\n?/
+SEQUENCE : /sequence/i
+
+SELECT : /select/i
+
+COPY : /copy/i
+
INTEGER : /\d+/
WORD : /\w+/
: $max_id_length;
$basename = substr( $basename, 0, $max_name )
if length( $basename ) > $max_name;
+ $basename =~ s/\./_/g;
my $name = $type ? "${type}_$basename" : $basename;
if ( $basename ne $basename_orig and $critical ) {
# strip any field size qualifiers as SQLite doesn't like these
my @fields = map { s/\(\d+\)$//; $_ } $index->fields;
+ (my $index_table_name = $index->table->name) =~ s/^.+?\.//; # table name may not specify schema
+ warn "removing schema name from '" . $index->table->name . "' to make '$index_table_name'\n" if $WARN;
my $index_def =
- "CREATE ${type}INDEX $name ON " . $index->table->name .
- ' (' . join( ', ', @fields ) . ')';
+ "CREATE ${type]INDEX $name on " . $index_table_name .
+ ' (' . join( ', ', @fields ) . ');';
return $index_def;
}
my $name = $c->name;
$name = mk_name($c->table->name, $name);
my @fields = $c->fields;
+ (my $index_table_name = $c->table->name) =~ s/^.+?\.//; # table name may not specify schema
+ warn "removing schema name from '" . $c->table->name . "' to make '$index_table_name'\n" if $WARN;
my $c_def =
- "CREATE UNIQUE INDEX $name ON " . $c->table->name .
- ' (' . join( ', ', @fields ) . ')';
+ "CREATE UNIQUE INDEX $name on " . $index_table_name .
+ ' (' . join( ', ', @fields ) . ');';
return $c_def;
}