diff --git a/ChangeLog b/ChangeLog index 294d714949..9521b97e2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -100,6 +100,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 diff --git a/libraries/import.lib.php b/libraries/import.lib.php index cf6b5a7636..9bfcdf04fa 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -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( @@ -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])) { @@ -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 '