From deeb5156b996e27668435f8284f91350c0427896 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 2 Nov 2019 14:41:59 +0100 Subject: [PATCH 1/2] Fix #12241 Remove alias removal In former versions, export on queries was available only for queries with one single table. This is not true anymore, so we should keep the aliases. Signed-off-by: Hugues Peccatte --- tbl_export.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tbl_export.php b/tbl_export.php index de533e8324..f9ea9b0e1f 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -96,28 +96,6 @@ if (! empty($sql_query)) { $parser->list, $replaces ); - - // Removing the aliases by finding the alias followed by a dot. - $tokens = PhpMyAdmin\SqlParser\Lexer::getTokens($sql_query); - foreach ($aliases as $alias => $table) { - $tokens = PhpMyAdmin\SqlParser\Utils\Tokens::replaceTokens( - $tokens, - array( - array( - 'value_str' => $alias, - ), - array( - 'type' => PhpMyAdmin\SqlParser\Token::TYPE_OPERATOR, - 'value_str' => '.', - ) - ), - array( - new PhpMyAdmin\SqlParser\Token($table), - new PhpMyAdmin\SqlParser\Token('.',PhpMyAdmin\SqlParser\Token::TYPE_OPERATOR) - ) - ); - } - $sql_query = PhpMyAdmin\SqlParser\TokensList::build($tokens); } echo PhpMyAdmin\Util::getMessage(PhpMyAdmin\Message::success()); From 11d8af138f03bbd27c76c263137deb3efdfe47b0 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 2 Nov 2019 14:52:06 +0100 Subject: [PATCH 2/2] Fix #15316 CROSS JOIN clause is removed on export Signed-off-by: Hugues Peccatte --- tbl_export.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tbl_export.php b/tbl_export.php index f9ea9b0e1f..a56554577c 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -53,33 +53,6 @@ if (! empty($sql_query)) { if ((!empty($parser->statements[0])) && ($parser->statements[0] instanceof PhpMyAdmin\SqlParser\Statements\SelectStatement) ) { - - // Finding aliases and removing them, but we keep track of them to be - // able to replace them in select expression too. - $aliases = array(); - foreach ($parser->statements[0]->from as $from) { - if ((!empty($from->table)) && (!empty($from->alias))) { - $aliases[$from->alias] = $from->table; - // We remove the alias of the table because they are going to - // be replaced anyway. - $from->alias = null; - $from->expr = null; // Force rebuild. - } - } - - // Rebuilding the SELECT and FROM clauses. - if (count($parser->statements[0]->from) > 0 - && count($parser->statements[0]->union) === 0 - ) { - $replaces = array( - array( - 'FROM', 'FROM ' . PhpMyAdmin\SqlParser\Components\ExpressionArray::build( - $parser->statements[0]->from - ), - ), - ); - } - // Checking if the WHERE clause has to be replaced. if ((!empty($where_clause)) && (is_array($where_clause))) { $replaces[] = array(