bug #1221359, Copying a db containing a MERGE table

This commit is contained in:
Marc Delisle
2005-06-18 13:06:42 +00:00
parent 34d03eac93
commit 18a96d81d4
3 changed files with 37 additions and 3 deletions

View File

@@ -8,6 +8,8 @@ $Source$
2005-06-18 Marc Delisle <lem9@users.sourceforge.net>
* libraries/sqlparser.lib.php: bug 1221602, undefined variable when trying
to use a reserved word as an identifier
* db_operations.php, libraries/database_interface.lib.php:
bug #1221359, Copying a db containing a MERGE table
2005-06-12 Marc Delisle <lem9@users.sourceforge.net>
* tbl_properties.inc.php: visually bind the Add x fields dialog to its

View File

@@ -34,11 +34,33 @@ if (isset($db) &&
$sql_query = $local_query;
PMA_DBI_query($local_query);
}
$tables = PMA_DBI_get_tables($db);
foreach ($tables as $table) {
$tables_full = PMA_DBI_get_tables_full($db);
foreach ($tables_full as $table => $tmp) {
$back = $sql_query;
$sql_query = '';
PMA_table_move_copy($db, $table, $newname, $table, isset($what) ? $what : 'data', $move);
// value of $what for this table only
$this_what = $what;
if (!isset($tables_full[$table]['Engine'])) {
$tables_full[$table]['Engine'] = $tables_full[$table]['Type'];
}
// do not copy the data from a Merge table
// note: on the calling FORM, 'data' means 'structure and data'
if ($tables_full[$table]['Engine'] == 'MRG_MyISAM') {
if ($this_what == 'data') {
$this_what = 'structure';
}
if ($this_what == 'dataonly') {
$this_what = 'nocopy';
}
}
if ($this_what != 'nocopy') {
PMA_table_move_copy($db, $table, $newname, $table, isset($this_what) ? $this_what : 'data', $move);
}
$sql_query = $back . $sql_query;
}

View File

@@ -69,6 +69,16 @@ function PMA_DBI_get_tables($database, $link = NULL) {
return $tables;
}
function PMA_DBI_get_tables_full($database, $link = NULL) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($database) . ';', NULL, PMA_DBI_QUERY_STORE);
$tables = array();
while ($row = PMA_DBI_fetch_assoc($result)) {
$tables[$row['Name']] = $row;
}
PMA_DBI_free_result($result);
return $tables;
}
function PMA_DBI_get_fields($database, $table, $link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {