diff --git a/ChangeLog b/ChangeLog index 206d34439b..8b84fb4057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -61,6 +61,7 @@ phpMyAdmin - ChangeLog - issue #11799 Backslashes in comments are being interpreted as escape characters - issue #11909 Can't insert row into table that contains generated column - issue #11677 sql-parser and php-gettext collide. +- issue #11920 Can't disable backquotes in export 4.5.4.1 (2016-01-29) - issue #11892 Error with PMA 4.4.15.3 diff --git a/libraries/plugins/export/ExportSql.php b/libraries/plugins/export/ExportSql.php index 5d5c97ac50..08710064c9 100644 --- a/libraries/plugins/export/ExportSql.php +++ b/libraries/plugins/export/ExportSql.php @@ -1548,6 +1548,12 @@ class ExportSql extends ExportPlugin // analysis. if (!$view) { + if (empty($sql_backquotes)) { + // Option "Enclose table and column names with backquotes" + // was checked. + Context::$MODE |= Context::NO_ENCLOSING_QUOTES; + } + // Using appropriate quotes. if (($compat === 'MSSQL') || ($sql_backquotes === '"')) { Context::$MODE |= Context::ANSI_QUOTES; diff --git a/libraries/sql-parser/src/Context.php b/libraries/sql-parser/src/Context.php index 7637953ab5..a62fa16b9e 100644 --- a/libraries/sql-parser/src/Context.php +++ b/libraries/sql-parser/src/Context.php @@ -190,6 +190,13 @@ abstract class Context // https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sqlmode_strict_trans_tables const STRICT_TRANS_TABLES = 1048576; + // Custom modes. + + // The table and column names and any other field that must be escaped will + // not be. + // Reserved keywords are being escaped regardless this mode is used or not. + const NO_ENCLOSING_QUOTES = 1073741824; + /* * Combination SQL Modes * https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sql-mode-combo @@ -520,9 +527,16 @@ abstract class Context return $str; } + if ((static::$MODE & Context::NO_ENCLOSING_QUOTES) + && (!static::isKeyword($str, true)) + ) { + return $str; + } + if (static::$MODE & Context::ANSI_QUOTES) { $quote = '"'; } + return $quote . str_replace($quote, $quote . $quote, $str) . $quote; } }