detect more complex case of SELECT DISTINCT for MySQL 3
This commit is contained in:
@@ -11,6 +11,10 @@ $Source$
|
|||||||
I find it faster this way, please tell me if you prefer
|
I find it faster this way, please tell me if you prefer
|
||||||
the old dialog method and why.
|
the old dialog method and why.
|
||||||
* tbl_change.php: bug #1038401, tabbing from value to value
|
* tbl_change.php: bug #1038401, tabbing from value to value
|
||||||
|
* sql.php: detect this case:
|
||||||
|
SELECT DISTINCT x AS foo, y AS bar FROM sometable
|
||||||
|
and count rows correctly (in MySQL 3),
|
||||||
|
thanks to Matthias Pigulla (mp@webfactory.de)
|
||||||
|
|
||||||
2004-10-13 Michal Čihař <michal@cihar.com>
|
2004-10-13 Michal Čihař <michal@cihar.com>
|
||||||
* libraries/fpdf/fpdf.php: Updated to 1.52.
|
* libraries/fpdf/fpdf.php: Updated to 1.52.
|
||||||
|
15
sql.php
15
sql.php
@@ -437,13 +437,20 @@ else {
|
|||||||
} else { // n o t " j u s t b r o w s i n g "
|
} else { // n o t " j u s t b r o w s i n g "
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 40000) {
|
if (PMA_MYSQL_INT_VERSION < 40000) {
|
||||||
// TODO: detect DISTINCT in the parser
|
|
||||||
if (stristr($sql_query, 'DISTINCT')) {
|
// detect this case:
|
||||||
$count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
|
// SELECT DISTINCT x AS foo, y AS bar FROM sometable
|
||||||
|
|
||||||
|
if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
|
||||||
|
$count_what = 'DISTINCT ';
|
||||||
|
$first_expr = TRUE;
|
||||||
|
foreach($analyzed_sql[0]['select_expr'] as $part) {
|
||||||
|
$count_what .= (!$first_expr ? ', ' : '') . $part['expr'];
|
||||||
|
$first_expr = FALSE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$count_what = '*';
|
$count_what = '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
$count_query = 'SELECT COUNT(' . $count_what . ') AS count';
|
$count_query = 'SELECT COUNT(' . $count_what . ') AS count';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user