mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Manual merge
mysql-test/r/select_found.result: Auto merged
This commit is contained in:
@ -246,3 +246,11 @@ SELECT FOUND_ROWS();
|
|||||||
FOUND_ROWS()
|
FOUND_ROWS()
|
||||||
0
|
0
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a int, b int);
|
||||||
|
INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;
|
||||||
|
a
|
||||||
|
a
|
||||||
|
SELECT FOUND_ROWS();
|
||||||
|
FOUND_ROWS()
|
||||||
|
1
|
||||||
|
@ -166,3 +166,12 @@ INSERT INTO t1 VALUES (0), (0), (1), (2);
|
|||||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
|
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
|
||||||
SELECT FOUND_ROWS();
|
SELECT FOUND_ROWS();
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #7945: group by + distinct with constant expression + limit
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a int, b int);
|
||||||
|
INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;
|
||||||
|
SELECT FOUND_ROWS();
|
||||||
|
@ -4473,9 +4473,15 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
|
|||||||
x = used key parts (1 <= x <= c)
|
x = used key parts (1 <= x <= c)
|
||||||
*/
|
*/
|
||||||
double rec_per_key;
|
double rec_per_key;
|
||||||
|
#if 0
|
||||||
if (!(rec_per_key=(double)
|
if (!(rec_per_key=(double)
|
||||||
keyinfo->rec_per_key[keyinfo->key_parts-1]))
|
keyinfo->rec_per_key[keyinfo->key_parts-1]))
|
||||||
rec_per_key=(double) s->records/rec+1;
|
rec_per_key=(double) s->records/rec+1;
|
||||||
|
#else
|
||||||
|
rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ?
|
||||||
|
(double) keyinfo->rec_per_key[keyinfo->key_parts-1] :
|
||||||
|
(double) s->records/rec+1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!s->records)
|
if (!s->records)
|
||||||
tmp=0;
|
tmp=0;
|
||||||
@ -10765,13 +10771,14 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
|
|||||||
field_count++;
|
field_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!field_count)
|
if (!field_count && !(join->select_options & OPTION_FOUND_ROWS))
|
||||||
{ // only const items
|
{ // only const items with no OPTION_FOUND_ROWS
|
||||||
join->unit->select_limit_cnt= 1; // Only send first row
|
join->unit->select_limit_cnt= 1; // Only send first row
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
Field **first_field=entry->field+entry->s->fields - field_count;
|
Field **first_field=entry->field+entry->s->fields - field_count;
|
||||||
offset=entry->field[entry->s->fields - field_count]->offset();
|
offset= field_count ?
|
||||||
|
entry->field[entry->s->fields - field_count]->offset() : 0;
|
||||||
reclength=entry->s->reclength-offset;
|
reclength=entry->s->reclength-offset;
|
||||||
|
|
||||||
free_io_cache(entry); // Safety
|
free_io_cache(entry); // Safety
|
||||||
|
Reference in New Issue
Block a user