1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

supported possiblity of item substitute (fixed bug) in setup_fields

more efficient reference creation
fixed table_name of Field in temporary table


mysql-test/r/subselect.result:
  test of 2 references bugs
mysql-test/t/subselect.test:
  test of 2 references bugs
sql/field.h:
  fixed layout
  fixed table name of fields of temporary table (derived table)
sql/item.cc:
  more efficient reference creation
sql/sql_base.cc:
  fixed layout
  supported possiblity of item substitute (fixed bug)
This commit is contained in:
unknown
2002-11-25 01:38:56 +02:00
parent 06e647472f
commit b5b19a7877
5 changed files with 23 additions and 6 deletions

View File

@ -27,6 +27,9 @@ SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
1
SELECT (SELECT 1), a;
Unknown column 'a' in 'field list'
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
a
1
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
@ -308,3 +311,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1
2 SUBSELECT Select tables optimized away
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
1
1
drop table t1;

View File

@ -12,6 +12,7 @@ EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
-- error 1054
SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
@ -197,3 +198,7 @@ EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1
EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
drop table t1;

View File

@ -129,7 +129,9 @@ public:
tmp->table= new_table;
tmp->key_start= tmp->part_of_key= tmp->part_of_sortkey= 0;
tmp->unireg_check=Field::NONE;
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | ZEROFILL_FLAG | ENUM_FLAG | SET_FLAG);
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
ZEROFILL_FLAG | ENUM_FLAG | SET_FLAG);
tmp->table_name= new_table->table_name;
tmp->reset_fields();
}
return tmp;

View File

@ -487,7 +487,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
else if (refer != (Item **)not_found_item)
{
Item_ref *r;
*ref= r= new Item_ref((char *)db_name, (char *)table_name,
*ref= r= new Item_ref(refer, (char *)table_name,
(char *)field_name);
if (!r)
return 1;

View File

@ -2079,6 +2079,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
{
if (item->fix_fields(thd, tables, it.ref()))
DBUG_RETURN(-1); /* purecov: inspected */
item= *(it.ref()); //Item can be chenged in fix fields
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
sum_func_list)
item->split_sum_func(*sum_func_list);