Fix handling of backquotes (bug #1497239).
This commit is contained in:
@@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2006-05-30 Michal Čihař <michal@cihar.com>
|
||||||
|
* libraries/export/sql.php: Fix handling of backquotes (bug #1497239).
|
||||||
|
|
||||||
2006-05-29 Michal Čihař <michal@cihar.com>
|
2006-05-29 Michal Čihař <michal@cihar.com>
|
||||||
* lang/galician: Update, thanks to Xosé Calvo - xosecalvo.
|
* lang/galician: Update, thanks to Xosé Calvo - xosecalvo.
|
||||||
* lang/japanese: Update, thanks to Ishigaki Kenichi - tcool.
|
* lang/japanese: Update, thanks to Ishigaki Kenichi - tcool.
|
||||||
|
@@ -67,7 +67,7 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['sql']['options'][] =
|
$plugin_list['sql']['options'][] =
|
||||||
array('type' => 'bool', 'name' => 'auto_increment', 'text' => 'strAddAutoIncrement');
|
array('type' => 'bool', 'name' => 'auto_increment', 'text' => 'strAddAutoIncrement');
|
||||||
$plugin_list['sql']['options'][] =
|
$plugin_list['sql']['options'][] =
|
||||||
array('type' => 'bool', 'name' => 'use_backquotes', 'text' => 'strUseBackquotes');
|
array('type' => 'bool', 'name' => 'backquotes', 'text' => 'strUseBackquotes');
|
||||||
|
|
||||||
/* MIME stuff etc. */
|
/* MIME stuff etc. */
|
||||||
$plugin_list['sql']['options'][] =
|
$plugin_list['sql']['options'][] =
|
||||||
@@ -123,8 +123,8 @@ $GLOBALS['comment_marker'] = '-- ';
|
|||||||
/**
|
/**
|
||||||
* Avoids undefined variables, use NULL so isset() returns false
|
* Avoids undefined variables, use NULL so isset() returns false
|
||||||
*/
|
*/
|
||||||
if ( ! isset( $sql_use_backquotes ) ) {
|
if ( ! isset( $sql_backquotes ) ) {
|
||||||
$sql_use_backquotes = null;
|
$sql_backquotes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,11 +224,11 @@ function PMA_exportDBCreate($db)
|
|||||||
{
|
{
|
||||||
global $crlf;
|
global $crlf;
|
||||||
if (isset($GLOBALS['sql_drop_database'])) {
|
if (isset($GLOBALS['sql_drop_database'])) {
|
||||||
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
|
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : $db);
|
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db);
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40101) {
|
if (PMA_MYSQL_INT_VERSION >= 40101) {
|
||||||
$collation = PMA_getDbCollation($db);
|
$collation = PMA_getDbCollation($db);
|
||||||
if (strpos($collation, '_')) {
|
if (strpos($collation, '_')) {
|
||||||
@@ -241,7 +241,7 @@ function PMA_exportDBCreate($db)
|
|||||||
if (!PMA_exportOutputHandler($create_query)) {
|
if (!PMA_exportOutputHandler($create_query)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['sql_use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
|
if (isset($GLOBALS['sql_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
|
||||||
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
|
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
|
||||||
}
|
}
|
||||||
return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
|
return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
|
||||||
@@ -260,7 +260,7 @@ function PMA_exportDBHeader($db)
|
|||||||
{
|
{
|
||||||
global $crlf;
|
global $crlf;
|
||||||
$head = $GLOBALS['comment_marker'] . $crlf
|
$head = $GLOBALS['comment_marker'] . $crlf
|
||||||
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
|
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
|
||||||
. $GLOBALS['comment_marker'] . $crlf;
|
. $GLOBALS['comment_marker'] . $crlf;
|
||||||
return PMA_exportOutputHandler($head);
|
return PMA_exportOutputHandler($head);
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ function PMA_exportDBFooter($db)
|
|||||||
function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
||||||
{
|
{
|
||||||
global $sql_drop;
|
global $sql_drop;
|
||||||
global $sql_use_backquotes;
|
global $sql_backquotes;
|
||||||
global $cfgRelation;
|
global $cfgRelation;
|
||||||
global $sql_constraints;
|
global $sql_constraints;
|
||||||
|
|
||||||
@@ -347,13 +347,13 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
} else {
|
} else {
|
||||||
$drop_clause = 'DROP TABLE';
|
$drop_clause = 'DROP TABLE';
|
||||||
}
|
}
|
||||||
$schema_create .= $drop_clause . ' IF EXISTS ' . PMA_backquote($table, $sql_use_backquotes) . ';' . $crlf;
|
$schema_create .= $drop_clause . ' IF EXISTS ' . PMA_backquote($table, $sql_backquotes) . ';' . $crlf;
|
||||||
unset($drop_clause);
|
unset($drop_clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steve Alberty's patch for complete table dump,
|
// Steve Alberty's patch for complete table dump,
|
||||||
// Whether to quote table and fields names or not
|
// Whether to quote table and fields names or not
|
||||||
if ($sql_use_backquotes) {
|
if ($sql_backquotes) {
|
||||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||||
} else {
|
} else {
|
||||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||||
@@ -467,7 +467,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comments = false, $do_mime = false)
|
function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comments = false, $do_mime = false)
|
||||||
{
|
{
|
||||||
global $cfgRelation;
|
global $cfgRelation;
|
||||||
global $sql_use_backquotes;
|
global $sql_backquotes;
|
||||||
global $sql_constraints;
|
global $sql_constraints;
|
||||||
|
|
||||||
$schema_create = '';
|
$schema_create = '';
|
||||||
@@ -502,32 +502,32 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
|
|||||||
|
|
||||||
if (isset($comments_map) && count($comments_map) > 0) {
|
if (isset($comments_map) && count($comments_map) > 0) {
|
||||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||||
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
|
||||||
foreach ($comments_map AS $comment_field => $comment) {
|
foreach ($comments_map AS $comment_field => $comment) {
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $sql_use_backquotes) . $crlf
|
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $sql_backquotes) . $crlf
|
||||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $sql_use_backquotes) . $crlf;
|
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $sql_backquotes) . $crlf;
|
||||||
}
|
}
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($mime_map) && count($mime_map) > 0) {
|
if (isset($mime_map) && count($mime_map) > 0) {
|
||||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||||
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
|
||||||
@reset($mime_map);
|
@reset($mime_map);
|
||||||
foreach ($mime_map AS $mime_field => $mime) {
|
foreach ($mime_map AS $mime_field => $mime) {
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $sql_use_backquotes) . $crlf
|
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $sql_backquotes) . $crlf
|
||||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $sql_use_backquotes) . $crlf;
|
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $sql_backquotes) . $crlf;
|
||||||
}
|
}
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($have_rel) {
|
if ($have_rel) {
|
||||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||||
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
|
||||||
foreach ($res_rel AS $rel_field => $rel) {
|
foreach ($res_rel AS $rel_field => $rel) {
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $sql_use_backquotes) . $crlf
|
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $sql_backquotes) . $crlf
|
||||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $sql_use_backquotes)
|
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $sql_backquotes)
|
||||||
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_use_backquotes) . $crlf;
|
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_backquotes) . $crlf;
|
||||||
}
|
}
|
||||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
|
|||||||
*/
|
*/
|
||||||
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
|
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
|
||||||
{
|
{
|
||||||
$formatted_table_name = (isset($GLOBALS['sql_use_backquotes']))
|
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
|
||||||
? PMA_backquote($table)
|
? PMA_backquote($table)
|
||||||
: '\'' . $table . '\'';
|
: '\'' . $table . '\'';
|
||||||
$dump = $crlf
|
$dump = $crlf
|
||||||
@@ -593,11 +593,11 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
|
|||||||
*/
|
*/
|
||||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||||
{
|
{
|
||||||
global $sql_use_backquotes;
|
global $sql_backquotes;
|
||||||
global $rows_cnt;
|
global $rows_cnt;
|
||||||
global $current_row;
|
global $current_row;
|
||||||
|
|
||||||
$formatted_table_name = (isset($GLOBALS['sql_use_backquotes']))
|
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
|
||||||
? PMA_backquote($table)
|
? PMA_backquote($table)
|
||||||
: '\'' . $table . '\'';
|
: '\'' . $table . '\'';
|
||||||
$head = $crlf
|
$head = $crlf
|
||||||
@@ -629,9 +629,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
|||||||
|
|
||||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||||
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
|
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
|
||||||
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $sql_use_backquotes);
|
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $sql_backquotes);
|
||||||
} else {
|
} else {
|
||||||
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $sql_use_backquotes);
|
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $sql_backquotes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +641,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
|||||||
if (isset($GLOBALS['sql_ignore'])) {
|
if (isset($GLOBALS['sql_ignore'])) {
|
||||||
$schema_insert .= 'IGNORE ';
|
$schema_insert .= 'IGNORE ';
|
||||||
}
|
}
|
||||||
$schema_insert .= PMA_backquote($table, $sql_use_backquotes) . ' SET ';
|
$schema_insert .= PMA_backquote($table, $sql_backquotes) . ' SET ';
|
||||||
} else {
|
} else {
|
||||||
// insert or replace
|
// insert or replace
|
||||||
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'REPLACE') {
|
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'REPLACE') {
|
||||||
@@ -665,10 +665,10 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
|||||||
// scheme for inserting fields
|
// scheme for inserting fields
|
||||||
if (isset($GLOBALS['sql_columns'])) {
|
if (isset($GLOBALS['sql_columns'])) {
|
||||||
$fields = implode(', ', $field_set);
|
$fields = implode(', ', $field_set);
|
||||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_use_backquotes)
|
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_backquotes)
|
||||||
. ' (' . $fields . ') VALUES ';
|
. ' (' . $fields . ') VALUES ';
|
||||||
} else {
|
} else {
|
||||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_use_backquotes)
|
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_backquotes)
|
||||||
. ' VALUES ';
|
. ' VALUES ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user