Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed May 28, 2015
2 parents d58689c + cbd3809 commit e773a53
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -53,6 +53,7 @@ phpMyAdmin - ChangeLog
- bug #4918 Date field popup dialog position bug
- bug In /setup, PMA_messages is not defined
- bug #4924 Recaptcha failure
- bug #4930 Database copy doesn't work for tables with more than one FULLTEXT index

4.4.7.0 (2015-05-16)
- bug #4876 Settings issues (Favorite tables shown twice in Settings)
Expand Down
59 changes: 40 additions & 19 deletions libraries/Table.class.php
Expand Up @@ -970,33 +970,54 @@ static public function moveCopy($source_db, $source_table, $target_db,

// add indexes to the table
if (!empty($GLOBALS['sql_indexes'])) {
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_indexes']);
$i = 0;

while ($parsed_sql[$i]['type'] != $table_delimiter) {
$i++;
$index_queries = [];
$sql_indexes = $GLOBALS['sql_indexes'];
$GLOBALS['sql_indexes'] = '';

$parsed_sql = PMA_SQP_parse($sql_indexes);
$cnt = $parsed_sql['len'] - 1;
$k = 0;

for ($j = 0; $j < $cnt; $j++) {
if ($parsed_sql[$j]['type'] == 'punct_queryend') {
$index_queries[] = substr($sql_indexes, $k, $parsed_sql[$j]['pos']);
$k = $parsed_sql[$j]['pos'];
}
}

$parsed_sql[$i]['data'] = $target;
foreach ($index_queries as $index_query) {

$cnt = $parsed_sql['len'] - 1;
$parsed_sql = PMA_SQP_parse($index_query);
$i = 0;

for ($j = $i; $j < $cnt; $j++) {
$dataUpper = /*overload*/mb_strtoupper($parsed_sql[$j]['data']);
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
&& $dataUpper == 'CONSTRAINT'
) {
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
$parsed_sql[$j+1]['data'] = '';
while ($parsed_sql[$i]['type'] != $table_delimiter) {
$i++;
}

$parsed_sql[$i]['data'] = $target;

$cnt = $parsed_sql['len'] - 1;

for ($j = $i; $j < $cnt; $j++) {
$dataUpper = /*overload*/mb_strtoupper($parsed_sql[$j]['data']);
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
&& $dataUpper == 'CONSTRAINT'
) {
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
$parsed_sql[$j+1]['data'] = '';
}
}
}

$sql_index = PMA_SQP_format($parsed_sql, 'query_only');
if ($mode == 'one_table' || $mode == 'db_copy') {
$GLOBALS['dbi']->query($sql_index);
}

$GLOBALS['sql_indexes'] .= $sql_index;
}
$GLOBALS['sql_indexes'] = PMA_SQP_format(
$parsed_sql, 'query_only'
);
if ($mode == 'one_table' || $mode == 'db_copy') {
$GLOBALS['dbi']->query($GLOBALS['sql_indexes']);
}

$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_indexes'];
if ($mode == 'one_table' || $mode == 'db_copy') {
unset($GLOBALS['sql_indexes']);
Expand Down

0 comments on commit e773a53

Please sign in to comment.