Merge pull request #1435 from madhuracj/Bug4663
#4663 Export missing back ticks for order table name
This commit is contained in:
commit
ac6657c1fd
@ -949,7 +949,7 @@ class PMA_Util
|
||||
$quote = '"';
|
||||
break;
|
||||
default:
|
||||
(isset($GLOBALS['sql_backquotes'])) ? $quote = "`" : $quote = '';
|
||||
$quote = "`";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -773,8 +773,9 @@ class ExportSql extends ExportPlugin
|
||||
if (isset($GLOBALS['sql_drop_database'])) {
|
||||
if (! PMA_exportOutputHandler(
|
||||
'DROP DATABASE '
|
||||
. (isset($GLOBALS['sql_backquotes'])
|
||||
? PMA_Util::backquoteCompat($db_alias, $compat) : $db_alias)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$db_alias, $compat, isset($GLOBALS['sql_backquotes'])
|
||||
)
|
||||
. ';' . $crlf
|
||||
)) {
|
||||
return false;
|
||||
@ -785,8 +786,9 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
$create_query = 'CREATE DATABASE IF NOT EXISTS '
|
||||
. (isset($GLOBALS['sql_backquotes'])
|
||||
? PMA_Util::backquoteCompat($db_alias, $compat) : $db_alias);
|
||||
. PMA_Util::backquoteCompat(
|
||||
$db_alias, $compat, isset($GLOBALS['sql_backquotes'])
|
||||
);
|
||||
$collation = PMA_getDbCollation($db);
|
||||
if (PMA_DRIZZLE) {
|
||||
$create_query .= ' COLLATE ' . $collation;
|
||||
@ -807,13 +809,15 @@ class ExportSql extends ExportPlugin
|
||||
if (! PMA_exportOutputHandler($create_query)) {
|
||||
return false;
|
||||
}
|
||||
if (isset($GLOBALS['sql_backquotes'])
|
||||
&& ((isset($GLOBALS['sql_compatibility'])
|
||||
if ((isset($GLOBALS['sql_compatibility'])
|
||||
&& $GLOBALS['sql_compatibility'] == 'NONE')
|
||||
|| PMA_DRIZZLE)
|
||||
|| PMA_DRIZZLE
|
||||
) {
|
||||
$result = PMA_exportOutputHandler(
|
||||
'USE ' . PMA_Util::backquoteCompat($db_alias, $compat)
|
||||
'USE '
|
||||
. PMA_Util::backquoteCompat(
|
||||
$db_alias, $compat, isset($GLOBALS['sql_backquotes'])
|
||||
)
|
||||
. ';' . $crlf
|
||||
);
|
||||
} else {
|
||||
@ -843,9 +847,9 @@ class ExportSql extends ExportPlugin
|
||||
$head = $this->_exportComment()
|
||||
. $this->_exportComment(
|
||||
__('Database:') . ' '
|
||||
. (isset($GLOBALS['sql_backquotes'])
|
||||
? PMA_Util::backquoteCompat($db_alias, $compat)
|
||||
: '\'' . $db_alias . '\'')
|
||||
. PMA_Util::backquoteCompat(
|
||||
$db_alias, $compat, isset($GLOBALS['sql_backquotes'])
|
||||
)
|
||||
)
|
||||
. $this->_exportComment();
|
||||
return PMA_exportOutputHandler($head);
|
||||
@ -1313,19 +1317,30 @@ class ExportSql extends ExportPlugin
|
||||
. $this->_exportComment(
|
||||
__('Constraints for table')
|
||||
. ' '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
)
|
||||
. $this->_exportComment();
|
||||
}
|
||||
$sql_constraints_query .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf;
|
||||
$sql_constraints .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf;
|
||||
$sql_drop_foreign_keys .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($db_alias, $compat) . '.'
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$db_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. '.'
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf;
|
||||
}
|
||||
//if there are indexes
|
||||
@ -1357,16 +1372,22 @@ class ExportSql extends ExportPlugin
|
||||
. $this->_exportComment(
|
||||
__('Indexes for table')
|
||||
. ' '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
)
|
||||
. $this->_exportComment();
|
||||
}
|
||||
$sql_indexes_query .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf . ' ';
|
||||
|
||||
$sql_indexes .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf . ' ';
|
||||
}
|
||||
if ($update_indexes_increments && preg_match(
|
||||
@ -1393,12 +1414,16 @@ class ExportSql extends ExportPlugin
|
||||
. $this->_exportComment(
|
||||
__('AUTO_INCREMENT for table')
|
||||
. ' '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
)
|
||||
. $this->_exportComment();
|
||||
}
|
||||
$sql_auto_increments .= 'ALTER TABLE '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
)
|
||||
. $crlf;
|
||||
}
|
||||
|
||||
@ -1748,9 +1773,9 @@ class ExportSql extends ExportPlugin
|
||||
$compat = 'NONE';
|
||||
}
|
||||
|
||||
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
|
||||
? PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
: '\'' . $table_alias . '\'';
|
||||
$formatted_table_name = PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, isset($GLOBALS['sql_backquotes'])
|
||||
);
|
||||
$dump = $this->_possibleCRLF()
|
||||
. $this->_exportComment(str_repeat('-', 56))
|
||||
. $this->_possibleCRLF()
|
||||
@ -1891,9 +1916,9 @@ class ExportSql extends ExportPlugin
|
||||
$compat = 'NONE';
|
||||
}
|
||||
|
||||
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
|
||||
? PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
: '\'' . $table_alias . '\'';
|
||||
$formatted_table_name = PMA_Util::backquoteCompat(
|
||||
$table_alias, $compat, $sql_backquotes
|
||||
);
|
||||
|
||||
// Do not export data for a VIEW, unless asked to export the view as a table
|
||||
// (For a VIEW, this is called only when exporting a single VIEW)
|
||||
@ -2077,7 +2102,8 @@ class ExportSql extends ExportPlugin
|
||||
'SET IDENTITY_INSERT '
|
||||
. PMA_Util::backquoteCompat(
|
||||
$table_alias,
|
||||
$compat
|
||||
$compat,
|
||||
$sql_backquotes
|
||||
)
|
||||
. ' ON ;' . $crlf
|
||||
)) {
|
||||
@ -2217,7 +2243,7 @@ class ExportSql extends ExportPlugin
|
||||
) {
|
||||
$outputSucceeded = PMA_exportOutputHandler(
|
||||
$crlf . 'SET IDENTITY_INSERT '
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat)
|
||||
. PMA_Util::backquoteCompat($table_alias, $compat, $sql_backquotes)
|
||||
. ' OFF;' . $crlf
|
||||
);
|
||||
if (! $outputSucceeded) {
|
||||
|
||||
@ -855,7 +855,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase
|
||||
public function testExportDBHeader()
|
||||
{
|
||||
$GLOBALS['sql_compatibility'] = 'MSSQL';
|
||||
$GLOBALS['sql_backquotes'] = '';
|
||||
$GLOBALS['sql_backquotes'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
@ -881,7 +881,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertContains(
|
||||
"'testDB'",
|
||||
"testDB",
|
||||
$result
|
||||
);
|
||||
}
|
||||
@ -1694,7 +1694,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertContains(
|
||||
"-- Triggers 't&bl'\n",
|
||||
"-- Triggers t&bl\n",
|
||||
$result
|
||||
);
|
||||
|
||||
@ -1718,7 +1718,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertContains(
|
||||
"-- Structure for view 't&bl'\n",
|
||||
"-- Structure for view t&bl\n",
|
||||
$result
|
||||
);
|
||||
|
||||
@ -2028,12 +2028,12 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
$this->object->exportData('db', 'table', "\n", "err.com", "SELECT")
|
||||
$this->object->exportData('db', 'tbl', "\n", "err.com", "SELECT")
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertContains(
|
||||
"-- VIEW 'table'\n",
|
||||
"-- VIEW tbl\n",
|
||||
$result
|
||||
);
|
||||
|
||||
|
||||
@ -199,10 +199,6 @@ class PMA_QuotingSlashing_Test extends PHPUnit_Framework_TestCase
|
||||
// Test bypass quoting (used by dump functions)
|
||||
$this->assertEquals($a, PMA_Util::backquoteCompat($a, 'NONE', false));
|
||||
|
||||
// Test backquote (backquoting will be enabled only
|
||||
// if isset $GLOBALS['sql_backquotes']
|
||||
$this->assertEquals($a, PMA_Util::backquoteCompat($a, 'NONE'));
|
||||
|
||||
// Run tests in MSSQL compatibility mode
|
||||
// Test bypass quoting (used by dump functions)
|
||||
$this->assertEquals($a, PMA_Util::backquoteCompat($a, 'MSSQL', false));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user