diff --git a/ChangeLog b/ChangeLog index a5da6e53f..5744401ce 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ $Source$ 2005-06-18 Marc Delisle * 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 * tbl_properties.inc.php: visually bind the Add x fields dialog to its diff --git a/db_operations.php b/db_operations.php index 355b132da..0c7866594 100644 --- a/db_operations.php +++ b/db_operations.php @@ -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; } diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 76e3051f3..4c3faed83 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -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'])) {