bug #1458245 copy a db containing a VIEW
This commit is contained in:
@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2006-03-28 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* libraries/Table_class.php, /sqlparser.lib.php: bug #1458245,
|
||||
copy a db containing a VIEW
|
||||
|
||||
2006-03-26 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* sql.php: bug #1448890 Column expander doesn't work
|
||||
* libraries/tbl_properties.inc.php: bug #1458334, undefined offset
|
||||
|
@@ -541,16 +541,31 @@ class PMA_Table {
|
||||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
||||
unset($no_constraints_comments);
|
||||
$parsed_sql = PMA_SQP_parse($sql_structure);
|
||||
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
|
||||
$i = 0;
|
||||
if (empty($analyzed_sql[0]['create_table_fields'])) {
|
||||
// lem9: this is not a CREATE TABLE, so find the first VIEW
|
||||
$target_for_view = PMA_backquote($target_db);
|
||||
while (true) {
|
||||
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'VIEW') {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
unset($analyzed_sql);
|
||||
|
||||
/* nijel: Find table name in query and replace it */
|
||||
// FIXME: does not work for a VIEW
|
||||
$i = 0;
|
||||
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
||||
$i++;
|
||||
}
|
||||
|
||||
/* no need to PMA_backquote() */
|
||||
$parsed_sql[$i]['data'] = $target;
|
||||
if (isset($target_for_view)) {
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
} else {
|
||||
$parsed_sql[$i]['data'] = $target;
|
||||
}
|
||||
|
||||
/* Generate query back */
|
||||
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
|
||||
@@ -558,7 +573,6 @@ class PMA_Table {
|
||||
$drop_query = '';
|
||||
if (isset($GLOBALS['drop_if_exists'])
|
||||
&& $GLOBALS['drop_if_exists'] == 'true') {
|
||||
//TODO: put this logic into a function?
|
||||
if (PMA_Table::_isView($target_db,$target_table)) {
|
||||
$drop_query = 'DROP VIEW';
|
||||
} else {
|
||||
@@ -619,9 +633,8 @@ class PMA_Table {
|
||||
$GLOBALS['sql_query'] = '';
|
||||
}
|
||||
|
||||
// Copy the data
|
||||
//if ($result != false && ($what == 'data' || $what == 'dataonly')) {
|
||||
if ($what == 'data' || $what == 'dataonly') {
|
||||
// Copy the data unless this is a VIEW
|
||||
if (($what == 'data' || $what == 'dataonly') && ! PMA_Table::_isView($target_db,$target_table)) {
|
||||
$sql_insert_data =
|
||||
'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
|
||||
PMA_DBI_query($sql_insert_data);
|
||||
|
@@ -2210,7 +2210,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
||||
case 'alpha_variable':
|
||||
// other workaround for a problem similar to the one
|
||||
// explained below for quote_single
|
||||
if (!$in_priv_list) {
|
||||
if (!$in_priv_list && $typearr[3] != 'quote_backtick') {
|
||||
$after = ' ';
|
||||
}
|
||||
break;
|
||||
@@ -2229,10 +2229,10 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
||||
}
|
||||
break;
|
||||
case 'quote_backtick':
|
||||
if ($typearr[3] != 'punct_qualifier') {
|
||||
if ($typearr[3] != 'punct_qualifier' && $typearr[3] != 'alpha_variable') {
|
||||
$after .= ' ';
|
||||
}
|
||||
if ($typearr[1] != 'punct_qualifier') {
|
||||
if ($typearr[1] != 'punct_qualifier' && $typearr[1] != 'alpha_variable') {
|
||||
$before .= ' ';
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user