bug #1812763 [Copy] Table copy when server is in ANSI_QUOTES sql_mode
This commit is contained in:
@@ -61,6 +61,8 @@ danbarry
|
|||||||
thanks to Jeroen Vrijkorte - jv_map
|
thanks to Jeroen Vrijkorte - jv_map
|
||||||
- bug #1906980 [Export] Import of VIEWs fails if temp table exists,
|
- bug #1906980 [Export] Import of VIEWs fails if temp table exists,
|
||||||
thanks to Falk Nisius - klaf
|
thanks to Falk Nisius - klaf
|
||||||
|
- bug #1812763 [Copy] Table copy when server is in ANSI_QUOTES sql_mode
|
||||||
|
thanks to Tony Marston - tonymarston
|
||||||
|
|
||||||
2.11.5.0 (2008-03-01)
|
2.11.5.0 (2008-03-01)
|
||||||
- bug #1862661 [GUI] Warn about rename deleting database
|
- bug #1862661 [GUI] Warn about rename deleting database
|
||||||
|
@@ -598,9 +598,16 @@ class PMA_Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($analyzed_sql);
|
unset($analyzed_sql);
|
||||||
|
$server_sql_mode = PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'sql_mode'", 0, 1);
|
||||||
|
if ('ANSI_QUOTES' == $server_sql_mode) {
|
||||||
|
$table_delimiter = 'quote_double';
|
||||||
|
} else {
|
||||||
|
$table_delimiter = 'quote_backtick';
|
||||||
|
}
|
||||||
|
unset($server_sql_mode);
|
||||||
|
|
||||||
/* nijel: Find table name in query and replace it */
|
/* nijel: Find table name in query and replace it */
|
||||||
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
while ($parsed_sql[$i]['type'] != $table_delimiter) {
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +623,7 @@ class PMA_Table {
|
|||||||
$last = $parsed_sql['len'] - 1;
|
$last = $parsed_sql['len'] - 1;
|
||||||
$backquoted_source_db = PMA_backquote($source_db);
|
$backquoted_source_db = PMA_backquote($source_db);
|
||||||
for (++$i; $i <= $last; $i++) {
|
for (++$i; $i <= $last; $i++) {
|
||||||
if ($parsed_sql[$i]['type'] == 'quote_backtick' && $parsed_sql[$i]['data'] == $backquoted_source_db) {
|
if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db) {
|
||||||
$parsed_sql[$i]['data'] = $target_for_view;
|
$parsed_sql[$i]['data'] = $target_for_view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,8 +663,8 @@ class PMA_Table {
|
|||||||
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
|
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
// find the first quote_backtick, it must be the source table name
|
// find the first $table_delimiter, it must be the source table name
|
||||||
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
while ($parsed_sql[$i]['type'] != $table_delimiter) {
|
||||||
$i++;
|
$i++;
|
||||||
// maybe someday we should guard against going over limit
|
// maybe someday we should guard against going over limit
|
||||||
//if ($i == $parsed_sql['len']) {
|
//if ($i == $parsed_sql['len']) {
|
||||||
@@ -668,7 +675,7 @@ class PMA_Table {
|
|||||||
// replace it by the target table name, no need to PMA_backquote()
|
// replace it by the target table name, no need to PMA_backquote()
|
||||||
$parsed_sql[$i]['data'] = $target;
|
$parsed_sql[$i]['data'] = $target;
|
||||||
|
|
||||||
// now we must remove all quote_backtick that follow a CONSTRAINT
|
// now we must remove all $table_delimiter that follow a CONSTRAINT
|
||||||
// keyword, because a constraint name must be unique in a db
|
// keyword, because a constraint name must be unique in a db
|
||||||
|
|
||||||
$cnt = $parsed_sql['len'] - 1;
|
$cnt = $parsed_sql['len'] - 1;
|
||||||
@@ -676,7 +683,7 @@ class PMA_Table {
|
|||||||
for ($j = $i; $j < $cnt; $j++) {
|
for ($j = $i; $j < $cnt; $j++) {
|
||||||
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
|
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
|
||||||
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT') {
|
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT') {
|
||||||
if ($parsed_sql[$j+1]['type'] == 'quote_backtick') {
|
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
|
||||||
$parsed_sql[$j+1]['data'] = '';
|
$parsed_sql[$j+1]['data'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user