DROP VIEW choice also for a db copy operation
This commit is contained in:
@@ -6,7 +6,8 @@ $Id$
|
|||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
2006-03-25 Marc Delisle <lem9@users.sourceforge.net>
|
2006-03-25 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* libraries/display_export.lib.php libraries/export/sql.php:
|
* db_operations.php, libraries/Table.class.php,
|
||||||
|
libraries/display_export.lib.php libraries/export/sql.php:
|
||||||
bug #1401864, DROP VIEW instead of DROP TABLE
|
bug #1401864, DROP VIEW instead of DROP TABLE
|
||||||
|
|
||||||
2006-03-23 Marc Delisle <lem9@users.sourceforge.net>
|
2006-03-23 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
|
@@ -234,6 +234,11 @@ if (!$is_information_schema) {
|
|||||||
.' alt="" width="16" height="16" />';
|
.' alt="" width="16" height="16" />';
|
||||||
}
|
}
|
||||||
echo $strDBCopy . ':';
|
echo $strDBCopy . ':';
|
||||||
|
if (PMA_MYSQL_INT_VERSION >= 50000) {
|
||||||
|
$drop_clause = 'DROP TABLE / DROP VIEW';
|
||||||
|
} else {
|
||||||
|
$drop_clause = 'DROP TABLE';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</legend>
|
</legend>
|
||||||
<input type="text" name="newname" size="30" class="textfield" value="" /><br />
|
<input type="text" name="newname" size="30" class="textfield" value="" /><br />
|
||||||
@@ -254,7 +259,7 @@ if (!$is_information_schema) {
|
|||||||
<?php echo $strCreateDatabaseBeforeCopying; ?></label><br />
|
<?php echo $strCreateDatabaseBeforeCopying; ?></label><br />
|
||||||
<input type="checkbox" name="drop_if_exists" value="true"
|
<input type="checkbox" name="drop_if_exists" value="true"
|
||||||
id="checkbox_drop" style="vertical-align: middle" />
|
id="checkbox_drop" style="vertical-align: middle" />
|
||||||
<label for="checkbox_drop"><?php echo sprintf($strAddClause, 'DROP TABLE'); ?></label><br />
|
<label for="checkbox_drop"><?php echo sprintf($strAddClause, $drop_clause); ?></label><br />
|
||||||
<input type="checkbox" name="sql_auto_increment" value="1"
|
<input type="checkbox" name="sql_auto_increment" value="1"
|
||||||
id="checkbox_auto_increment" style="vertical-align: middle" />
|
id="checkbox_auto_increment" style="vertical-align: middle" />
|
||||||
<label for="checkbox_auto_increment">
|
<label for="checkbox_auto_increment">
|
||||||
@@ -264,6 +269,8 @@ if (!$is_information_schema) {
|
|||||||
<label for="checkbox_constraints">
|
<label for="checkbox_constraints">
|
||||||
<?php echo $strAddConstraints; ?></label><br />
|
<?php echo $strAddConstraints; ?></label><br />
|
||||||
<?php
|
<?php
|
||||||
|
unset($drop_clause);
|
||||||
|
|
||||||
if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new'])
|
if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new'])
|
||||||
&& $_COOKIE['pma_switch_to_new'] == 'true') {
|
&& $_COOKIE['pma_switch_to_new'] == 'true') {
|
||||||
$pma_switch_to_new = 'true';
|
$pma_switch_to_new = 'true';
|
||||||
|
@@ -540,10 +540,10 @@ class PMA_Table {
|
|||||||
$no_constraints_comments = true;
|
$no_constraints_comments = true;
|
||||||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
||||||
unset($no_constraints_comments);
|
unset($no_constraints_comments);
|
||||||
|
|
||||||
$parsed_sql = PMA_SQP_parse($sql_structure);
|
$parsed_sql = PMA_SQP_parse($sql_structure);
|
||||||
|
|
||||||
/* nijel: Find table name in query and replace it */
|
/* nijel: Find table name in query and replace it */
|
||||||
|
// FIXME: does not work for a VIEW
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
||||||
$i++;
|
$i++;
|
||||||
@@ -558,7 +558,13 @@ class PMA_Table {
|
|||||||
$drop_query = '';
|
$drop_query = '';
|
||||||
if (isset($GLOBALS['drop_if_exists'])
|
if (isset($GLOBALS['drop_if_exists'])
|
||||||
&& $GLOBALS['drop_if_exists'] == 'true') {
|
&& $GLOBALS['drop_if_exists'] == 'true') {
|
||||||
$drop_query = 'DROP TABLE IF EXISTS '
|
//TODO: put this logic into a function?
|
||||||
|
if (PMA_Table::_isView($target_db,$target_table)) {
|
||||||
|
$drop_query = 'DROP VIEW';
|
||||||
|
} else {
|
||||||
|
$drop_query = 'DROP TABLE';
|
||||||
|
}
|
||||||
|
$drop_query .= ' IF EXISTS '
|
||||||
. PMA_backquote($target_db) . '.'
|
. PMA_backquote($target_db) . '.'
|
||||||
. PMA_backquote($target_table);
|
. PMA_backquote($target_table);
|
||||||
PMA_DBI_query($drop_query);
|
PMA_DBI_query($drop_query);
|
||||||
@@ -632,8 +638,13 @@ class PMA_Table {
|
|||||||
// moving table from replicated one to not replicated one
|
// moving table from replicated one to not replicated one
|
||||||
PMA_DBI_select_db($source_db);
|
PMA_DBI_select_db($source_db);
|
||||||
|
|
||||||
$sql_drop_table = 'DROP TABLE ' . $source;
|
if (PMA_Table::_isView($source_db,$source)) {
|
||||||
PMA_DBI_query($sql_drop_table);
|
$sql_drop_query = 'DROP VIEW';
|
||||||
|
} else {
|
||||||
|
$sql_drop_query = 'DROP TABLE';
|
||||||
|
}
|
||||||
|
$sql_drop_query .= ' ' . $source;
|
||||||
|
PMA_DBI_query($sql_drop_query);
|
||||||
|
|
||||||
// garvin: Move old entries from PMA-DBs to new table
|
// garvin: Move old entries from PMA-DBs to new table
|
||||||
if ($GLOBALS['cfgRelation']['commwork']) {
|
if ($GLOBALS['cfgRelation']['commwork']) {
|
||||||
@@ -648,13 +659,6 @@ class PMA_Table {
|
|||||||
|
|
||||||
// garvin: updating bookmarks is not possible since only a single table is moved,
|
// garvin: updating bookmarks is not possible since only a single table is moved,
|
||||||
// and not the whole DB.
|
// and not the whole DB.
|
||||||
// if ($GLOBALS['cfgRelation']['bookmarkwork']) {
|
|
||||||
// $remove_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['bookmark'])
|
|
||||||
// . ' SET dbase = \'' . PMA_sqlAddslashes($target_db) . '\''
|
|
||||||
// . ' WHERE dbase = \'' . PMA_sqlAddslashes($source_db) . '\'';
|
|
||||||
// $rmv_rs = PMA_query_as_cu($remove_query);
|
|
||||||
// unset($rmv_query);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ($GLOBALS['cfgRelation']['displaywork']) {
|
if ($GLOBALS['cfgRelation']['displaywork']) {
|
||||||
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info'])
|
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info'])
|
||||||
@@ -716,7 +720,7 @@ class PMA_Table {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_table . ';';
|
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
|
||||||
} else {
|
} else {
|
||||||
// garvin: Create new entries as duplicates from old PMA DBs
|
// garvin: Create new entries as duplicates from old PMA DBs
|
||||||
if ($what != 'dataonly' && !isset($maintain_relations)) {
|
if ($what != 'dataonly' && !isset($maintain_relations)) {
|
||||||
|
@@ -337,6 +337,7 @@ $PMA_SQPdata_reserved_word = array (
|
|||||||
'DAY_HOUR',
|
'DAY_HOUR',
|
||||||
'DAY_MINUTE',
|
'DAY_MINUTE',
|
||||||
'DAY_SECOND',
|
'DAY_SECOND',
|
||||||
|
'DEFINER',
|
||||||
'DELAYED',
|
'DELAYED',
|
||||||
'DELAY_KEY_WRITE',
|
'DELAY_KEY_WRITE',
|
||||||
'DELETE',
|
'DELETE',
|
||||||
@@ -563,7 +564,7 @@ $PMA_SQPdata_reserved_word = array (
|
|||||||
'YEAR_MONTH'
|
'YEAR_MONTH'
|
||||||
);
|
);
|
||||||
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
|
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
|
||||||
$PMA_SQPdata_reserved_word_cnt = 272;
|
$PMA_SQPdata_reserved_word_cnt = 273;
|
||||||
|
|
||||||
// words forbidden to be used as column or table name,
|
// words forbidden to be used as column or table name,
|
||||||
// as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
|
// as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
|
||||||
|
Reference in New Issue
Block a user