]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1497042 - Enclose table names in CREATE queries
authorSébastien Santoro <dereckson@espace-win.org>
Thu, 31 Jan 2019 01:50:01 +0000 (20:50 -0500)
committerDylan William Hardison <dylan@hardison.net>
Thu, 31 Jan 2019 01:50:01 +0000 (20:50 -0500)
Bugzilla/DB/Schema/Mysql.pm

index b5bebad305f2d4fdbae09252b97008b5f24af6e4..0af73cc8f0f12a5f2a5d0aaea0bb2eb7e3c0e279 100644 (file)
@@ -135,8 +135,12 @@ sub _get_create_table_ddl {
 
   my $charset = Bugzilla->dbh->bz_db_is_utf8 ? "CHARACTER SET utf8" : '';
   my $type = grep($_ eq $table, MYISAM_TABLES) ? 'MYISAM' : 'InnoDB';
-  return (
-    $self->SUPER::_get_create_table_ddl($table) . " ENGINE = $type $charset");
+
+  my $ddl = $self->SUPER::_get_create_table_ddl($table);
+  $ddl =~ s/CREATE TABLE (.*) \(/CREATE TABLE `$1` (/;
+  $ddl .= " ENGINE = $type $charset";
+
+  return $ddl;
 
 }    #eosub--_get_create_table_ddl
 
@@ -151,7 +155,7 @@ sub _get_create_index_ddl {
   my $sql = "CREATE ";
   $sql .= "$index_type "
     if ($index_type eq 'UNIQUE' || $index_type eq 'FULLTEXT');
-  $sql .= "INDEX \`$index_name\` ON $table_name \("
+  $sql .= "INDEX \`$index_name\` ON \`$table_name\` \("
     . join(", ", @$index_fields) . "\)";
 
   return ($sql);