# ----------------------------------------------------------
+# x.xxxxx xxxx-xx-xx
+# ----------------------------------------------------------
+* Properly quote absolute table names in the MySQL producer
+
+# ----------------------------------------------------------
# 0.09004 2009-02-13
# ----------------------------------------------------------
* Add support for temporary tables in Pg (nachos)
my $qt = $options->{quote_table_names} || '';
my $qf = $options->{quote_field_names} || '';
- my $table_name = $table->name;
+ my $table_name = quote_table_name($table->name, $qt);
debug("PKG: Looking at table '$table_name'\n");
#
#
my $create = '';
my $drop;
- $create .= "--\n-- Table: $qt$table_name$qt\n--\n" unless $options->{no_comments};
- $drop = qq[DROP TABLE IF EXISTS $qt$table_name$qt] if $options->{add_drop_table};
- $create .= "CREATE TABLE $qt$table_name$qt (\n";
+ $create .= "--\n-- Table: $table_name\n--\n" unless $options->{no_comments};
+ $drop = qq[DROP TABLE IF EXISTS $table_name] if $options->{add_drop_table};
+ $create .= "CREATE TABLE $table_name (\n";
#
# Fields
return $drop ? ($drop,$create) : $create;
}
+sub quote_table_name {
+ my ($table_name, $qt) = @_;
+
+ $table_name =~ s/\./$qt.$qt/g;
+
+ return "$qt$table_name$qt";
+}
+
sub generate_table_options
{
my ($table, $options) = @_;
name: idx_unique_name
thing2:
- name: thing2
+ name: some.thing2
extra:
order: 2
fields:
UNIQUE `idx_unique_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_danish_ci",
-"DROP TABLE IF EXISTS `thing2`",
-"CREATE TABLE `thing2` (
+"DROP TABLE IF EXISTS `some`.`thing2`",
+"CREATE TABLE `some`.`thing2` (
`id` integer,
`foo` integer,
`foo2` integer,