Commit d75c649b authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

Merge abarkov@build.mysql.com:/home/bk/mysql-4.1

into bar.mysql.r18.ru:/usr/home/bar/mysql-4.1
parents 44c0ca61 fbe49f0c
......@@ -53,6 +53,8 @@ jcole@sarvik.tfr.cafe.ee
jcole@tetra.spaceapes.com
jorge@linux.jorge.mysql.com
kaj@work.mysql.com
konstantin@mysql.com
kostja@oak.local
lenz@kallisto.mysql.com
lenz@mysql.com
miguel@hegel.(none)
......
This diff is collapsed.
......@@ -374,22 +374,23 @@ drop database mysqltest;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
create table t1 (a char(1) not null);
insert into t1 values("");
create table t1 (a char(1) not null collate koi8r_general_ci);
insert into t1 values(_koi8r"");
set CHARACTER SET koi8r;
select * from t1;
a
set CHARACTER SET cp1251_koi8;
select * from t1;
a
set CHARACTER SET DEFAULT;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
Qcache_queries_in_cache 2
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 5
Qcache_hits 4
drop table t1;
create database if not exists mysqltest;
create table mysqltest.t1 (i int not null);
......@@ -415,7 +416,7 @@ Variable_name Value
Qcache_queries_in_cache 2
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 7
Qcache_hits 6
drop database mysqltest;
drop table t1;
create table t1 (i int not null);
......@@ -429,7 +430,7 @@ FOUND_ROWS()
4
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 7
Qcache_hits 6
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
......@@ -441,7 +442,7 @@ FOUND_ROWS()
1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 7
Qcache_hits 6
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
......@@ -454,7 +455,7 @@ FOUND_ROWS()
4
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 8
Qcache_hits 7
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
......@@ -466,7 +467,7 @@ FOUND_ROWS()
1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 9
Qcache_hits 8
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
......@@ -535,7 +536,7 @@ a
3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 12
Qcache_hits 11
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
......@@ -552,7 +553,7 @@ a
3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 13
Qcache_hits 12
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
......@@ -561,6 +562,15 @@ set GLOBAL query_cache_min_res_unit=default;
show global variables like "query_cache_min_res_unit";
Variable_name Value
query_cache_min_res_unit 4096
create table t1 (a int not null);
insert into t1 values (1);
select "aaa" from t1;
aaa
aaa
select "AAA" from t1;
AAA
AAA
drop table t1;
create table t1 (a int);
set GLOBAL query_cache_size=1000;
show global variables like "query_cache_size";
......
......@@ -1225,16 +1225,17 @@ a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 an
2 2
1 2
drop table t1,t2,t3;
create table t1 (a char(10) character set koi8r collate koi8r_bin);
create table t2 select (select a from t1);
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`(select a from t1)` char(10) character set koi8r collate koi8r_bin default NULL
) TYPE=MyISAM CHARSET=latin1
create table t1 (s1 int);
create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
select * from t1 where exists (select s1 from t2 having max(t2.s1)=t1.s1);
s1
drop table t1,t2;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1);
ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
create table t1 (s1 int);
create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
ERROR 42S02: Unknown table 'x' in field list
DROP TABLE t1, t2;
......@@ -17,6 +17,7 @@ CREATE TABLE t1 (
) TYPE=MyISAM;
# two-level entry, second-level tree with depth 2
--disable_query_log
let $1=260;
while ($1)
{
......@@ -39,6 +40,7 @@ while ($1)
eval insert t1 (a) values ('aaayyy');
dec $1;
}
--enable_query_log
# converting to two-level
repair table t1 quick;
......
......@@ -260,8 +260,9 @@ show status like "Qcache_queries_in_cache";
#
# Charset convertion (cp1251_koi8 always present)
#
create table t1 (a char(1) not null);
insert into t1 values("");
create table t1 (a char(1) not null collate koi8r_general_ci);
insert into t1 values(_koi8r"");
set CHARACTER SET koi8r;
select * from t1;
set CHARACTER SET cp1251_koi8;
select * from t1;
......@@ -368,6 +369,15 @@ drop table t2;
set GLOBAL query_cache_min_res_unit=default;
show global variables like "query_cache_min_res_unit";
#
# Case sensitive test
#
create table t1 (a int not null);
insert into t1 values (1);
select "aaa" from t1;
select "AAA" from t1;
drop table t1;
#
# Test of query cache resizing
#
......
......@@ -807,6 +807,7 @@ INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "
INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
drop table t1;
#
# alloc_group_fields() working
#
......@@ -819,13 +820,24 @@ insert into t3 values (3,3), (2,2), (1,1);
select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
drop table t1,t2,t3;
create table t1 (a char(10) character set koi8r collate koi8r_bin);
create table t2 select (select a from t1);
show create table t2;
#
# aggregate functions in HAVING test
#
create table t1 (s1 int);
create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
select * from t1 where exists (select s1 from t2 having max(t2.s1)=t1.s1);
drop table t1,t2;
#
# update subquery with wrong field (to force name resolving
# in UPDATE name space)
#
create table t1 (s1 int);
create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
-- error 1109
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
DROP TABLE t1, t2;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
--error 1265
SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1);
......@@ -49,15 +49,19 @@ Item::Item():
THD *thd= current_thd;
next= thd->free_list; // Put in free list
thd->free_list= this;
loop_id= 0;
/*
Item constructor can be called during execution other tnen SQL_COM
command => we should check thd->lex.current_select on zero (thd->lex
can be uninitialised)
*/
if (thd->lex.current_select &&
thd->lex.current_select->parsing_place == SELECT_LEX_NODE::SELECT_LIST)
thd->lex.current_select->select_items++;
if (thd->lex.current_select)
{
SELECT_LEX_NODE::enum_parsing_place place=
thd->lex.current_select->parsing_place;
if (place == SELECT_LEX_NODE::SELECT_LIST ||
place == SELECT_LEX_NODE::IN_HAVING)
thd->lex.current_select->select_n_having_items++;
}
}
/*
......@@ -66,7 +70,6 @@ Item::Item():
tables
*/
Item::Item(THD *thd, Item &item):
loop_id(0),
str_value(item.str_value),
name(item.name),
max_length(item.max_length),
......@@ -867,7 +870,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
sl= sl->outer_select())
{
table_list= (last= sl)->get_table_list();
if (sl->insert_select && table_list)
if (sl->resolve_mode == SELECT_LEX::INSERT_MODE && table_list)
{
// it is primary INSERT st_select_lex => skip first table resolving
table_list= table_list->next;
......@@ -876,7 +879,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
table_list, &where,
0)) != not_found_field)
break;
if ((refer= find_item_in_list(this, sl->item_list, &counter,
if (sl->resolve_mode == SELECT_LEX::SELECT_MODE &&
(refer= find_item_in_list(this, sl->item_list, &counter,
REPORT_EXCEPT_NOT_FOUND)) !=
(Item **) not_found_item)
break;
......@@ -1353,13 +1357,15 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
SELECT_LEX *last=0;
for ( ; sl ; sl= sl->outer_select())
{
if ((ref= find_item_in_list(this, (last= sl)->item_list,
last= sl;
if (sl->resolve_mode == SELECT_LEX::SELECT_MODE &&
(ref= find_item_in_list(this, sl->item_list,
&counter,
REPORT_EXCEPT_NOT_FOUND)) !=
(Item **)not_found_item)
break;
table_list= sl->get_table_list();
if (sl->insert_select && table_list)
if (sl->resolve_mode == SELECT_LEX::INSERT_MODE && table_list)
{
// it is primary INSERT st_select_lex => skip first table resolving
table_list= table_list->next;
......
......@@ -83,7 +83,6 @@ class DTCollation {
};
class Item {
uint loop_id; /* Used to find selfrefering loops */
Item(const Item &); /* Prevent use of these */
void operator=(Item &);
public:
......
......@@ -508,7 +508,7 @@ void Item_in_subselect::single_value_transformer(THD *thd,
{
sl->item_list.push_back(item);
setup_ref_array(thd, &sl->ref_pointer_array,
1 + sl->select_items +
1 + sl->select_n_having_items +
sl->order_list.elements + sl->group_list.elements);
// To prevent crash on Item_ref_null_helper destruction in case of error
sl->ref_pointer_array[0]= 0;
......
......@@ -3221,8 +3221,17 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if (thd->slave_thread && table_rules_on && !tables_ok(0, tables))
if (thd->slave_thread && table_rules_on)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
account in tests.
*/
tables[0].updating=tables[1].updating=tables[2].updating=tables[3].updating=1;
if (!tables_ok(0, tables))
DBUG_RETURN(1);
tables[0].updating=tables[1].updating=tables[2].updating=tables[3].updating=0;
}
#endif
if (open_and_lock_tables(thd, tables))
......
......@@ -1422,10 +1422,10 @@ ulong Query_cache::init_cache()
DUMP(this);
VOID(hash_init(&queries,system_charset_info,def_query_hash_size, 0, 0,
VOID(hash_init(&queries, &my_charset_bin, def_query_hash_size, 0, 0,
query_cache_query_get_key, 0, 0));
#ifndef FN_NO_CASE_SENCE
VOID(hash_init(&tables,system_charset_info,def_table_hash_size, 0, 0,
VOID(hash_init(&tables, &my_charset_bin, def_table_hash_size, 0, 0,
query_cache_table_get_key, 0, 0));
#else
// windows, OS/2 or other case insensitive file names work around
......
......@@ -126,7 +126,8 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
item_list= select_cursor->item_list;
select_cursor->with_wild= 0;
if (setup_ref_array(thd, &select_cursor->ref_pointer_array,
(item_list.elements + select_cursor->select_items +
(item_list.elements +
select_cursor->select_n_having_items +
select_cursor->order_list.elements +
select_cursor->group_list.elements)) ||
setup_fields(thd, select_cursor->ref_pointer_array, first_table,
......
......@@ -959,7 +959,7 @@ void st_select_lex_node::init_select()
order_list.next= (byte**) &order_list.first;
select_limit= HA_POS_ERROR;
offset_limit= 0;
select_items= 0;
select_n_having_items= 0;
with_sum_func= 0;
parsing_place= SELECT_LEX_NODE::NO_MATTER;
}
......@@ -986,7 +986,8 @@ void st_select_lex::init_query()
join= 0;
where= 0;
olap= UNSPECIFIED_OLAP_TYPE;
insert_select= having_fix_field= 0;
having_fix_field= 0;
resolve_mode= NOMATTER_MODE;
with_wild= 0;
}
......
......@@ -205,8 +205,12 @@ class st_select_lex_node {
ha_rows select_limit, offset_limit; /* LIMIT clause parameters */
// Arrays of pointers to top elements of all_fields list
Item **ref_pointer_array;
uint select_items; /* number of items in select_list */
/*
number of items in select_list and HAVING clause used to get number
bigger then can be number of entries that will be added to all item
list during split_sum_func
*/
uint select_n_having_items;
uint cond_count; /* number of arguments of and/or/xor in where/having */
enum_parsing_place parsing_place; /* where we are parsing expression */
bool with_sum_func; /* sum function indicator */
......@@ -360,14 +364,27 @@ class st_select_lex: public st_select_lex_node
bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */
/* TRUE when having fix field called in processing of this SELECT */
bool having_fix_field;
/*
TRUE for primary st_select_lex structure of simple INSERT/REPLACE
SELECT for SELECT command st_select_lex. Used to privent scaning
item_list of non-SELECT st_select_lex (no sense find to finding
reference in it (all should be in tables, it is dangerouse due
to order of fix_fields calling for non-SELECTs commands (item list
can be not fix_fieldsd)). This value will be assigned for
primary select (sql_yac.yy) and for any subquery and
UNION SELECT (sql_parse.cc mysql_new_select())
INSERT for primary st_select_lex structure of simple INSERT/REPLACE
(used for name resolution, see Item_fiels & Item_ref fix_fields,
FALSE for INSERT/REPLACE ... SELECT, because it's
st_select_lex->table_list will be preprocessed (first table removed)
before passing to handle_select)
NOMATTER for other
*/
bool insert_select;
enum {NOMATTER_MODE, SELECT_MODE, INSERT_MODE} resolve_mode;
void init_query();
void init_select();
......
......@@ -3561,6 +3561,7 @@ mysql_new_select(LEX *lex, bool move_down)
unit->link_prev= 0;
unit->return_to= lex->current_select;
select_lex->include_down(unit);
// TODO: assign resolve_mode for fake subquery after merging with new tree
}
else
select_lex->include_neighbour(lex->current_select);
......@@ -3568,6 +3569,7 @@ mysql_new_select(LEX *lex, bool move_down)
select_lex->master_unit()->global_parameters= select_lex;
select_lex->include_global((st_select_lex_node**)&lex->all_selects_list);
lex->current_select= select_lex;
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
return 0;
}
......
......@@ -294,7 +294,8 @@ JOIN::prepare(Item ***rref_pointer_array,
fields_list,
&all_fields, wild_num))) ||
setup_ref_array(thd, rref_pointer_array, (fields_list.elements +
select_lex->select_items +
select_lex->
select_n_having_items +
og_num)) ||
setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
&all_fields, 1) ||
......
......@@ -159,7 +159,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
item_list= select_cursor->item_list;
select_cursor->with_wild= 0;
if (setup_ref_array(thd, &select_cursor->ref_pointer_array,
(item_list.elements + select_cursor->select_items +
(item_list.elements +
select_cursor->select_n_having_items +
select_cursor->order_list.elements +
select_cursor->group_list.elements)) ||
setup_fields(thd, select_cursor->ref_pointer_array, first_table,
......
......@@ -1910,7 +1910,12 @@ opt_ignore_leaves:
select:
select_init { Lex->sql_command=SQLCOM_SELECT; };
select_init
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
};
/* Need select_init2 for subselects. */
select_init:
......@@ -3401,7 +3406,7 @@ insert:
lex->sql_command = SQLCOM_INSERT;
/* for subselects */
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
lex->select_lex.insert_select= 1;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
} insert_lock_option
opt_ignore insert2
{
......@@ -3417,7 +3422,7 @@ replace:
LEX *lex=Lex;
lex->sql_command = SQLCOM_REPLACE;
lex->duplicates= DUP_REPLACE;
lex->select_lex.insert_select= 1;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
}
replace_lock_option insert2
{
......@@ -3486,7 +3491,7 @@ insert_values:
it is not simple select => table list will be
preprocessed before passing to handle_select
*/
lex->select_lex.insert_select= 0;
lex->select_lex.resolve_mode= SELECT_LEX::NOMATTER_MODE;
lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
}
select_options select_item_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment