From 2c87a4715e4c5cbeb3f0899730904be9123d9953 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 18 Jan 2008 18:29:17 +0000 Subject: [PATCH] bug #1873110 [export] Problem exporting with a LIMIT clause --- ChangeLog | 1 + tbl_export.php | 39 ++------------------------------------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 281c24da3..d4b5b3ba7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA - bug #1862661 [GUI] Warn about rename deleting database - bug #1866041 [interface] Incorrect sorting with AS - bug #1871038 [import] Notice: undefined variable first_sql_delimiter +- bug #1873110 [export] Problem exporting with a LIMIT clause 2.11.4.0 (2008-01-12) - bug #1843428 [GUI] Space issue with DROP/DELETE/ALTER TABLE diff --git a/tbl_export.php b/tbl_export.php index 0faedcb81..d86942eeb 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -27,12 +27,12 @@ $export_page_title = $strViewDump; if (! empty($sql_query)) { // Parse query so we can work with tokens $parsed_sql = PMA_SQP_parse($sql_query); + $analyzed_sql = PMA_SQP_analyze($parsed_sql); // Need to generate WHERE clause? if (isset($primary_key)) { // Yes => rebuild query from scracts, this doesn't work with nested // selects :-( - $analyzed_sql = PMA_SQP_analyze($parsed_sql); $sql_query = 'SELECT '; if (isset($analyzed_sql[0]['queryflags']['distinct'])) { @@ -71,42 +71,7 @@ if (! empty($sql_query)) { } } else { // Just crop LIMIT clause - $inside_bracket = FALSE; - for ($i = $parsed_sql['len'] - 1; $i >= 0; $i--) { - if ($parsed_sql[$i]['type'] == 'punct_bracket_close_round') { - $inside_bracket = TRUE; - continue; - } - if ($parsed_sql[$i]['type'] == 'punct_bracket_open_round') { - $inside_bracket = FALSE; - continue; - } - if (!$inside_bracket && $parsed_sql[$i]['type'] == 'alpha_reservedWord' && strtoupper($parsed_sql[$i]['data']) == 'LIMIT') { - // We found LIMIT to remove - - $sql_query = ''; - - // Concatenate parts before - for ($j = 0; $j < $i; $j++) { - $sql_query .= $parsed_sql[$j]['data'] . ' '; - } - - // Skip LIMIT - $i++; - while ($i < $parsed_sql['len'] && - ($parsed_sql[$i]['type'] != 'alpha_reservedWord' || - ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) { - $i++; - } - - // Add remaining parts - while ($i < $parsed_sql['len']) { - $sql_query .= $parsed_sql[$i]['data'] . ' '; - $i++; - } - break; - } - } + $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; } $message = PMA_Message::success(); }