Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/QA_4_4' into QA_4_4
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Mar 29, 2015
2 parents 5beb561 + b28ae18 commit 5b2c00f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -85,6 +85,7 @@ explanation
- bug #4802 Changelog page is not working
- bug #4815 Infinite calls to index.php
- bug #4820 Invalid links to dev.mysql.com
- bug #4718 simulate query fails, but actual query does not

4.3.12.0 (2015-03-14)
- bug #4746 Right-aligned columns have left-aligned header
Expand Down
33 changes: 24 additions & 9 deletions libraries/import.lib.php
Expand Up @@ -1484,11 +1484,12 @@ function PMA_getMatchedRows($analyzed_sql_results = array())
function PMA_getSimulatedUpdateQuery($analyzed_sql_results)
{
$where_clause = '';
$extra_where_clause = '';
$extra_where_clause = array();
$target_cols = array();

$prev_term = '';
$i = 0;
$in_function = 0;
foreach ($analyzed_sql_results['parsed_sql'] as $key => $term) {
if (! isset($get_set_expr)
&& preg_match(
Expand All @@ -1508,19 +1509,33 @@ function PMA_getSimulatedUpdateQuery($analyzed_sql_results)
) {
break;
}
if(!$in_function){
if ($term['type'] == 'punct_listsep') {
$extra_where_clause[] = ' OR ';
} else if ($term['type'] == 'punct') {
$extra_where_clause[] = ' <> ';
} else if($term['type'] == 'alpha_functionName') {
array_pop($extra_where_clause);
array_pop($extra_where_clause);
} else {
$extra_where_clause[] = $term['data'];
}
}
else if($term['type'] == 'punct_bracket_close_round') {
$in_function--;
}

if ($term['type'] == 'punct_listsep') {
$extra_where_clause .= ' OR ';
} else if ($term['type'] == 'punct') {
$extra_where_clause .= ' <> ';
} else {
$extra_where_clause .= $term['data'];
if($term['type'] == 'alpha_functionName') {
$in_function++;
}

// Get columns in SET expression.
if ($prev_term != 'punct') {
if ($term['type'] != 'punct_listsep'
&& $term['type'] != 'punct'
&& $term['type'] != 'punct_bracket_open_round'
&& $term['type'] != 'punct_bracket_close_round'
&& !$in_function
&& isset($term['data'])
) {
if (isset($target_cols[$i])) {
Expand All @@ -1544,8 +1559,8 @@ function PMA_getSimulatedUpdateQuery($analyzed_sql_results)

// Get WHERE clause.
$where_clause .= $analyzed_sql_results['analyzed_sql'][0]['where_clause'];
if (empty($where_clause) && empty($extra_where_clause)) {
$where_clause = '1';
if (empty($where_clause)) {
$where_clause = (!empty($extra_where_clause) && $extra_where_clause[0]) ? implode(' ',$extra_where_clause) : '1';
}

$matched_row_query = 'SELECT '
Expand Down

0 comments on commit 5b2c00f

Please sign in to comment.