diff --git a/ChangeLog b/ChangeLog index bca0aaf46..2d44ad7b7 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2003-06-25 Marc Delisle * scripts/create-release.sh: typo, bzip should be bzip2 + * libraries/sqlparser.lib.php3, tbl_properties_export.php3: + bug 760648 export SELECT DISTINCT results 2003-06-25 Michal Cihar * libraries/sqlparser.lib.php3: Fixed XSS problem. diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 7864e49a7..316fc534b 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -711,6 +711,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { * * ['queryflags']['need_confirm'] = 1; if the query needs confirmation * ['queryflags']['select_from'] = 1; if this is a real SELECT...FROM + * ['queryflags']['distinct'] = 1; for a DISTINCT * * lem9: query clauses * ------------- @@ -1213,6 +1214,9 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $in_select_expr = TRUE; $select_expr_clause = ''; } + if ($upper_data == 'DISTINCT') { + $subresult['queryflags']['distinct'] = 1; + } // if this is a real SELECT...FROM if ($upper_data == 'FROM' && isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1) { diff --git a/tbl_properties_export.php3 b/tbl_properties_export.php3 index 6c4700c06..3f1b4f0bc 100755 --- a/tbl_properties_export.php3 +++ b/tbl_properties_export.php3 @@ -27,7 +27,13 @@ if (isset($sql_query)) { $parsed_sql = PMA_SQP_parse($sql_query); $analyzed_sql = PMA_SQP_analyze($parsed_sql); - $sql_query = 'SELECT ' . $analyzed_sql[0]['select_expr_clause']; + $sql_query = 'SELECT '; + + if (isset($analyzed_sql[0]['queryflags']['distinct'])) { + $sql_query .= ' DISTINCT '; + } + + $sql_query .= $analyzed_sql[0]['select_expr_clause']; if (!empty($analyzed_sql[0]['from_clause'])) { $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];