From cc56e0966718fbf1dc56b37f9a8c151b15722a7f Mon Sep 17 00:00:00 2001 From: Andrea Vallorani Date: Wed, 18 Mar 2015 19:41:35 +0100 Subject: [PATCH 1/2] Bug #4718 simulate query fails It is not an elegant solution, but it seems functional. It avoids all the errors caused by the presence of functions in the query. The $extra_where_clause variable was valorized but never appended to the WHERE clause. (I think that was a mistake) Signed-off-by: Andrea Vallorani --- libraries/import.lib.php | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 355dbd1c8b..833088d8ef 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -1487,11 +1487,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( @@ -1511,19 +1512,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])) { @@ -1547,8 +1562,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 ' From adfd70d2901b41da7c05c9dfd22e9e930301b007 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 29 Mar 2015 07:55:06 -0400 Subject: [PATCH 2/2] ChangeLog entry Signed-off-by: Marc Delisle --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 2f50eafe1e..bd45c32931 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ phpMyAdmin - ChangeLog - 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