diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php index 0b468fefc0..467b3d5416 100644 --- a/libraries/replication.inc.php +++ b/libraries/replication.inc.php @@ -304,126 +304,4 @@ function PMA_replication_master_replicated_dbs($link = null) return $link; } -/** - * This function provides synchronization of structure and data - * between two mysql servers. - * - * @param string $db name of database, which should be synchronized - * @param mixed $src_link link of source server, - * note: if the server is current PMA server, use null - * @param mixed $trg_link link of target server, - * note: if the server is current PMA server, use null - * @param bool $data if true, then data will be copied as well - * - * @return void - * - * @todo improve code sharing between the function and synchronization - */ - -function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true) -{ - $src_db = $trg_db = $db; - - $src_tables = PMA_DBI_get_tables($src_db, $src_link); - - $trg_tables = PMA_DBI_get_tables($trg_db, $trg_link); - - /** - * initializing arrays to save table names - */ - $source_tables_uncommon = array(); - $target_tables_uncommon = array(); - $matching_tables = array(); - $matching_tables_num = 0; - - /** - * Criterion for matching tables is just their names. - * Finding the uncommon tables for the source database - * BY comparing the matching tables with all the tables in the source database - */ - PMA_getMatchingTables($trg_tables, $src_tables, $matching_tables, $source_tables_uncommon); - - /** - * Finding the uncommon tables for the target database - * BY comparing the matching tables with all the tables in the target database - */ - PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, $target_tables_uncommon); - - /** - * - * Comparing Data In the Matching Tables - * It is assumed that the matching tables are structurally - * and typely exactly the same - */ - $fields_num = array(); - $matching_tables_fields = array(); - $matching_tables_keys = array(); - $insert_array = array(array(array())); - $update_array = array(array(array())); - $delete_array = array(); - $row_count = array(); - $uncommon_tables_fields = array(); - $matching_tables_num = sizeof($matching_tables); - - for ($i = 0; $i < sizeof($matching_tables); $i++) { - PMA_dataDiffInTables( - $src_db, $trg_db, $src_link, $trg_link, $matching_tables, - $matching_tables_fields, $update_array, $insert_array, - $delete_array, $fields_num, $i, $matching_tables_keys - ); - } - for ($j = 0; $j < sizeof($source_tables_uncommon); $j++) { - PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $j, $row_count); - } - - /** - * INTEGRATION OF STRUCTURE DIFFERENCE CODE - * - */ - $source_columns = array(); - $target_columns = array(); - $alter_str_array = array(array()); - $add_column_array = array(array()); - $uncommon_columns = array(); - $target_tables_keys = array(); - $source_indexes = array(); - $target_indexes = array(); - $add_indexes_array = array(); - $alter_indexes_array = array(); - $remove_indexes_array = array(); - $criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment'); - - for ($counter = 0; $counter < $matching_tables_num; $counter++) { - PMA_structureDiffInTables( - $src_db, $trg_db, $src_link, $trg_link, $matching_tables, - $source_columns, $target_columns, $alter_str_array, $add_column_array, - $uncommon_columns, $criteria, $target_tables_keys, $counter - ); - - PMA_indexesDiffInTables( - $src_db, $trg_db, $src_link, $trg_link, $matching_tables, - $source_indexes, $target_indexes, $add_indexes_array, - $alter_indexes_array, $remove_indexes_array, $counter - ); - } - - /** - * Generating Create Table query for all the non-matching tables present - * in Source but not in Target and populating tables. - */ - for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) { - if (isset($source_tables_uncommon[$q])) { - PMA_createTargetTables( - $src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, - $q, $uncommon_tables_fields, false - ); - } - if (isset($row_count[$q]) && $data) { - PMA_populateTargetTables( - $src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, - $q, $uncommon_tables_fields, false - ); - } - } -} ?>