bug #1873110 [export] Problem exporting with a LIMIT clause

This commit is contained in:
Marc Delisle
2008-01-18 18:29:17 +00:00
parent 6b53e86f60
commit 2c87a4715e
2 changed files with 3 additions and 37 deletions

View File

@@ -39,6 +39,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
- bug #1862661 [GUI] Warn about rename deleting database - bug #1862661 [GUI] Warn about rename deleting database
- bug #1866041 [interface] Incorrect sorting with AS - bug #1866041 [interface] Incorrect sorting with AS
- bug #1871038 [import] Notice: undefined variable first_sql_delimiter - 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) 2.11.4.0 (2008-01-12)
- bug #1843428 [GUI] Space issue with DROP/DELETE/ALTER TABLE - bug #1843428 [GUI] Space issue with DROP/DELETE/ALTER TABLE

View File

@@ -27,12 +27,12 @@ $export_page_title = $strViewDump;
if (! empty($sql_query)) { if (! empty($sql_query)) {
// Parse query so we can work with tokens // Parse query so we can work with tokens
$parsed_sql = PMA_SQP_parse($sql_query); $parsed_sql = PMA_SQP_parse($sql_query);
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
// Need to generate WHERE clause? // Need to generate WHERE clause?
if (isset($primary_key)) { if (isset($primary_key)) {
// Yes => rebuild query from scracts, this doesn't work with nested // Yes => rebuild query from scracts, this doesn't work with nested
// selects :-( // selects :-(
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
$sql_query = 'SELECT '; $sql_query = 'SELECT ';
if (isset($analyzed_sql[0]['queryflags']['distinct'])) { if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
@@ -71,42 +71,7 @@ if (! empty($sql_query)) {
} }
} else { } else {
// Just crop LIMIT clause // Just crop LIMIT clause
$inside_bracket = FALSE; $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
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;
}
}
} }
$message = PMA_Message::success(); $message = PMA_Message::success();
} }