mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge rurik.mysql.com:/home/igor/dev/mysql-5.0-0
into rurik.mysql.com:/home/igor/dev/mysql-5.1-0
This commit is contained in:
@ -2475,3 +2475,32 @@ alias1 alias2
|
|||||||
5 5
|
5 5
|
||||||
drop view v2, v1;
|
drop view v2, v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
CREATE TABLE t1 (a int PRIMARY KEY, b int);
|
||||||
|
INSERT INTO t1 VALUES (2,20), (3,10), (1,10), (0,30), (5,10);
|
||||||
|
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||||
|
SELECT MAX(a) FROM t1;
|
||||||
|
MAX(a)
|
||||||
|
5
|
||||||
|
SELECT MAX(a) FROM v1;
|
||||||
|
MAX(a)
|
||||||
|
5
|
||||||
|
EXPLAIN SELECT MAX(a) FROM t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||||
|
EXPLAIN SELECT MAX(a) FROM v1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||||
|
SELECT MIN(a) FROM t1;
|
||||||
|
MIN(a)
|
||||||
|
0
|
||||||
|
SELECT MIN(a) FROM v1;
|
||||||
|
MIN(a)
|
||||||
|
0
|
||||||
|
EXPLAIN SELECT MIN(a) FROM t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||||
|
EXPLAIN SELECT MIN(a) FROM v1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -2343,3 +2343,27 @@ order by v2.receipt_id;
|
|||||||
|
|
||||||
drop view v2, v1;
|
drop view v2, v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug#16016: MIN/MAX optimization for views
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a int PRIMARY KEY, b int);
|
||||||
|
INSERT INTO t1 VALUES (2,20), (3,10), (1,10), (0,30), (5,10);
|
||||||
|
|
||||||
|
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||||
|
|
||||||
|
SELECT MAX(a) FROM t1;
|
||||||
|
SELECT MAX(a) FROM v1;
|
||||||
|
|
||||||
|
EXPLAIN SELECT MAX(a) FROM t1;
|
||||||
|
EXPLAIN SELECT MAX(a) FROM v1;
|
||||||
|
|
||||||
|
SELECT MIN(a) FROM t1;
|
||||||
|
SELECT MIN(a) FROM v1;
|
||||||
|
|
||||||
|
EXPLAIN SELECT MIN(a) FROM t1;
|
||||||
|
EXPLAIN SELECT MIN(a) FROM v1;
|
||||||
|
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -180,14 +180,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
|||||||
indexes to find the key.
|
indexes to find the key.
|
||||||
*/
|
*/
|
||||||
Item *expr=item_sum->args[0];
|
Item *expr=item_sum->args[0];
|
||||||
if (expr->type() == Item::FIELD_ITEM)
|
if (expr->real_item()->type() == Item::FIELD_ITEM)
|
||||||
{
|
{
|
||||||
byte key_buff[MAX_KEY_LENGTH];
|
byte key_buff[MAX_KEY_LENGTH];
|
||||||
TABLE_REF ref;
|
TABLE_REF ref;
|
||||||
uint range_fl, prefix_len;
|
uint range_fl, prefix_len;
|
||||||
|
|
||||||
ref.key_buff= key_buff;
|
ref.key_buff= key_buff;
|
||||||
Item_field *item_field= ((Item_field*) expr);
|
Item_field *item_field= (Item_field*) (expr->real_item());
|
||||||
TABLE *table= item_field->field->table;
|
TABLE *table= item_field->field->table;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -267,14 +267,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
|
|||||||
indexes to find the key.
|
indexes to find the key.
|
||||||
*/
|
*/
|
||||||
Item *expr=item_sum->args[0];
|
Item *expr=item_sum->args[0];
|
||||||
if (expr->type() == Item::FIELD_ITEM)
|
if (expr->real_item()->type() == Item::FIELD_ITEM)
|
||||||
{
|
{
|
||||||
byte key_buff[MAX_KEY_LENGTH];
|
byte key_buff[MAX_KEY_LENGTH];
|
||||||
TABLE_REF ref;
|
TABLE_REF ref;
|
||||||
uint range_fl, prefix_len;
|
uint range_fl, prefix_len;
|
||||||
|
|
||||||
ref.key_buff= key_buff;
|
ref.key_buff= key_buff;
|
||||||
Item_field *item_field= ((Item_field*) expr);
|
Item_field *item_field= (Item_field*) (expr->real_item());
|
||||||
TABLE *table= item_field->field->table;
|
TABLE *table= item_field->field->table;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user