Commit 21bb08e8 authored by unknown's avatar unknown

Merge mysql.com:/home/jimw/my/mysql-4.1-12327

into  mysql.com:/home/jimw/my/mysql-4.1-clean

parents bea4fbb0 1c847f79
......@@ -575,8 +575,13 @@ static void print_result()
if (status)
{
/*
if there was an error with the table, we have --auto-repair set,
and this isn't a repair op, then add the table to the tables4repair
list
*/
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
(!opt_fast || strcmp(row[3],"OK")))
strcmp(row[3],"OK"))
insert_dynamic(&tables4repair, prev);
found_error=0;
if (opt_silent)
......@@ -595,8 +600,8 @@ static void print_result()
strmov(prev, row[0]);
putchar('\n');
}
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
!opt_fast)
/* add the last table to be repaired to the list */
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
insert_dynamic(&tables4repair, prev);
mysql_free_result(res);
}
......
......@@ -68,6 +68,21 @@ drop table t1;
select TRUE,FALSE,NULL;
TRUE FALSE NULL
1 0 NULL
create table t1 (c1 char(5)) character set=latin1;
insert into t1 values('row 1');
insert into t1 values('row 2');
insert into t1 values('row 3');
select concat(user(), '--', c1) from t1;
concat(user(), '--', c1)
root@localhost--row 1
root@localhost--row 2
root@localhost--row 3
select concat(database(), '--', c1) from t1;
concat(database(), '--', c1)
test--row 1
test--row 2
test--row 3
drop table t1;
create table t1 (a char(10)) character set latin1;
select * from t1 where a=version();
a
......
......@@ -80,4 +80,18 @@ show status like "Qcache_free_blocks";
Variable_name Value
Qcache_free_blocks 1
drop table t1, t2, t3, t11, t21;
CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE =
MyISAM;
LOCK TABLE t1 READ LOCAL;
INSERT INTO t1 VALUES (), (), ();
SELECT * FROM t1;
a
SELECT * FROM t1;
a
1
2
3
SELECT * FROM t1;
a
drop table t1;
set GLOBAL query_cache_size=0;
......@@ -2742,13 +2742,26 @@ one two flag
5 6 N
7 8 N
insert into t2 values (null,null,'N');
insert into t2 values (null,3,'0');
insert into t2 values (null,5,'0');
insert into t2 values (10,null,'0');
insert into t1 values (10,3,'0');
insert into t1 values (10,5,'0');
insert into t1 values (10,10,'0');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
one two test
1 2 0
2 3 0
3 4 0
1 2 NULL
2 3 NULL
3 4 NULL
5 6 1
7 8 1
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
one two
5 6
7 8
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
one two test
1 2 NULL
......@@ -2756,6 +2769,47 @@ one two test
3 4 NULL
5 6 1
7 8 1
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
one two test
1 2 0
2 3 NULL
3 4 0
5 6 0
7 8 0
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
one two test
1 2 0
2 3 NULL
3 4 0
5 6 0
7 8 0
10 3 NULL
10 5 NULL
10 10 NULL
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
Warnings:
Note 1003 select test.t1.one AS `one`,test.t1.two AS `two`,<in_optimizer>((test.t1.one,test.t1.two),<exists>(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where ((test.t2.flag = _latin1'0') and ((<cache>(test.t1.one) = test.t2.one) or isnull(test.t2.one)) and ((<cache>(test.t1.two) = test.t2.two) or isnull(test.t2.two))) having (<is_not_null_test>(test.t2.one) and <is_not_null_test>(test.t2.two)))) AS `test` from test.t1
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
Warnings:
Note 1003 select test.t1.one AS `one`,test.t1.two AS `two` from test.t1 where <in_optimizer>((test.t1.one,test.t1.two),<exists>(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where ((test.t2.flag = _latin1'N') and (<cache>(test.t1.one) = test.t2.one) and (<cache>(test.t1.two) = test.t2.two))))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select test.t1.one AS `one`,test.t1.two AS `two`,<in_optimizer>((test.t1.one,test.t1.two),<exists>(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where (test.t2.flag = _latin1'0') group by test.t2.one,test.t2.two having (((<cache>(test.t1.one) = test.t2.one) or isnull(test.t2.one)) and ((<cache>(test.t1.two) = test.t2.two) or isnull(test.t2.two)) and <is_not_null_test>(test.t2.one) and <is_not_null_test>(test.t2.two)))) AS `test` from test.t1
DROP TABLE t1,t2;
CREATE TABLE t1 (a char(5), b char(5));
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');
......
......@@ -31,6 +31,18 @@ drop table t1;
select TRUE,FALSE,NULL;
#
# Bug#12351: CONCAT with USER()/DATEBASE() and
# a constant and a column gets strange results
#
create table t1 (c1 char(5)) character set=latin1;
insert into t1 values('row 1');
insert into t1 values('row 2');
insert into t1 values('row 3');
select concat(user(), '--', c1) from t1;
select concat(database(), '--', c1) from t1;
drop table t1;
#
# Bug#8291 Illegal collation mix with USER() function
#
......
......@@ -78,4 +78,23 @@ show status like "Qcache_total_blocks";
show status like "Qcache_free_blocks";
drop table t1, t2, t3, t11, t21;
#
# do not use QC if tables locked (BUG#12385)
#
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock);
connection root;
CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE =
MyISAM;
LOCK TABLE t1 READ LOCAL;
connect (root2,localhost,root,,test,$MASTER_MYPORT,master.sock);
connection root2;
INSERT INTO t1 VALUES (), (), ();
connection root;
SELECT * FROM t1;
connection root2;
SELECT * FROM t1;
connection root;
SELECT * FROM t1;
drop table t1;
set GLOBAL query_cache_size=0;
......@@ -1769,9 +1769,20 @@ SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
insert into t2 values (null,null,'N');
insert into t2 values (null,3,'0');
insert into t2 values (null,5,'0');
insert into t2 values (10,null,'0');
insert into t1 values (10,3,'0');
insert into t1 values (10,5,'0');
insert into t1 values (10,10,'0');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
DROP TABLE t1,t2;
#
......
......@@ -2827,7 +2827,16 @@ void ha_ndbcluster::info(uint flag)
errkey= m_dupkey;
}
if (flag & HA_STATUS_AUTO)
{
DBUG_PRINT("info", ("HA_STATUS_AUTO"));
if (m_table)
{
Ndb *ndb= get_ndb();
auto_increment_value=
ndb->readAutoIncrementValue((const NDBTAB *) m_table);
}
}
DBUG_VOID_RETURN;
}
......
......@@ -1023,6 +1023,15 @@ class Item_ref_null_helper: public Item_ref
String* val_str(String* s);
bool get_date(TIME *ltime, uint fuzzydate);
void print(String *str);
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
*/
table_map used_tables() const
{
return (depended_from ?
OUTER_REF_TABLE_BIT :
(*ref)->used_tables() | RAND_TABLE_BIT);
}
};
class Item_null_helper :public Item_ref_null_helper
......
......@@ -832,6 +832,11 @@ class Item_is_not_null_test :public Item_func_isnull
longlong val_int();
const char *func_name() const { return "<is_not_null_test>"; }
void update_used_tables();
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
*/
table_map used_tables() const
{ return used_tables_cache | RAND_TABLE_BIT; }
};
......
......@@ -1187,7 +1187,7 @@ String *Item_func_substr_index::val_str(String *str)
}
}
else
{ // Start counting at end
{
/*
Negative index, start counting at the end
*/
......@@ -1562,6 +1562,7 @@ Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs)
return NULL;
}
conv->str_value.copy();
conv->str_value.shrink_to_length();
return conv;
}
......
......@@ -859,6 +859,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
argument (reference) to fix_fields()
*/
select_lex->where= join->conds= and_items(join->conds, item);
select_lex->where->top_level_item();
if (join->conds->fix_fields(thd, join->tables_list, 0))
DBUG_RETURN(RES_ERROR);
}
......@@ -912,10 +913,13 @@ Item_in_subselect::single_value_transformer(JOIN *join,
Item_subselect::trans_res
Item_in_subselect::row_value_transformer(JOIN *join)
{
DBUG_ENTER("Item_in_subselect::row_value_transformer");
Item *item= 0;
SELECT_LEX *select_lex= join->select_lex;
Item *having_item= 0;
uint cols_num= left_expr->cols();
bool is_having_used= (join->having || select_lex->with_sum_func ||
select_lex->group_list.first ||
!select_lex->table_list.elements);
DBUG_ENTER("Item_in_subselect::row_value_transformer");
if (select_lex->item_list.elements != left_expr->cols())
{
......@@ -946,62 +950,157 @@ Item_in_subselect::row_value_transformer(JOIN *join)
}
select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
if (is_having_used)
{
uint n= left_expr->cols();
List_iterator_fast<Item> li(select_lex->item_list);
for (uint i= 0; i < n; i++)
/*
(l1, l2, l3) IN (SELECT v1, v2, v3 ... HAVING having) =>
EXISTS (SELECT ... HAVING having and
(l1 = v1 or is null v1) and
(l2 = v2 or is null v2) and
(l3 = v3 or is null v3) and
is_not_null_test(v1) and
is_not_null_test(v2) and
is_not_null_test(v3))
where is_not_null_test used to register nulls in case if we have
not found matching to return correct NULL value
*/
Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++)
{
Item *func;
DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->el(i)->cols()))
DBUG_RETURN(RES_ERROR);
if (join->having || select_lex->with_sum_func ||
select_lex->group_list.elements)
func= new Item_ref_null_helper(this,
select_lex->ref_pointer_array+i,
(char *) "<no matter>",
(char *) "<list ref>");
else
func= li++;
func=
eq_creator.create(new Item_direct_ref((*optimizer->get_cache())->
Item *item_eq=
new Item_func_eq(new
Item_direct_ref((*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
func);
item= and_items(item, func);
new
Item_direct_ref(select_lex->ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")
);
Item *item_isnull=
new Item_func_isnull(new
Item_direct_ref( select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>")
);
having_item=
and_items(having_item,
new Item_cond_or(item_eq, item_isnull));
item_having_part2=
and_items(item_having_part2,
new
Item_is_not_null_test(this,
new
Item_direct_ref(select_lex->
ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")
)
);
item_having_part2->top_level_item();
}
having_item= and_items(having_item, item_having_part2);
having_item->top_level_item();
}
if (join->having || select_lex->with_sum_func ||
select_lex->group_list.first ||
!select_lex->table_list.elements)
else
{
/*
AND can't be changed during fix_fields()
we can assign select_lex->having here, and pass 0 as last
argument (reference) to fix_fields()
(l1, l2, l3) IN (SELECT v1, v2, v3 ... WHERE where) =>
EXISTS (SELECT ... WHERE where and
(l1 = v1 or is null v1) and
(l2 = v2 or is null v2) and
(l3 = v3 or is null v3)
HAVING is_not_null_test(v1) and
is_not_null_test(v2) and
is_not_null_test(v3))
where is_not_null_test register NULLs values but reject rows
in case when we do not need correct NULL, we have simplier construction:
EXISTS (SELECT ... WHERE where and
(l1 = v1) and
(l2 = v2) and
(l3 = v3)
*/
select_lex->having= join->having= and_items(join->having, item);
select_lex->having_fix_field= 1;
if (join->having->fix_fields(thd, join->tables_list, 0))
Item *where_item= 0;
for (uint i= 0; i < cols_num; i++)
{
select_lex->having_fix_field= 0;
Item *item, *item_isnull;
DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->el(i)->cols()))
DBUG_RETURN(RES_ERROR);
item=
new Item_func_eq(new
Item_direct_ref((*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
(char *)in_left_expr_name),
new
Item_direct_ref( select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>")
);
if (!abort_on_null)
{
having_item=
and_items(having_item,
new
Item_is_not_null_test(this,
new
Item_direct_ref(select_lex->
ref_pointer_array + i,
(char *)"<no matter>",
(char *)"<list ref>")
)
);
item_isnull= new
Item_func_isnull(new
Item_direct_ref( select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>")
);
item= new Item_cond_or(item, item_isnull);
}
select_lex->having_fix_field= 0;
where_item= and_items(where_item, item);
}
else
/*
AND can't be changed during fix_fields()
we can assign select_lex->where here, and pass 0 as last
argument (reference) to fix_fields()
*/
select_lex->where= join->conds= and_items(join->conds, where_item);
select_lex->where->top_level_item();
if (join->conds->fix_fields(thd, join->tables_list, 0))
DBUG_RETURN(RES_ERROR);
}
if (having_item)
{
bool res;
select_lex->having= join->having= and_items(join->having, having_item);
select_lex->having->top_level_item();
/*
AND can't be changed during fix_fields()
we can assign select_lex->having here, and pass 0 as last
argument (reference) to fix_fields()
*/
select_lex->where= join->conds= and_items(join->conds, item);
if (join->conds->fix_fields(thd, join->tables_list, 0))
select_lex->having_fix_field= 1;
res= join->having->fix_fields(thd, join->tables_list, 0);
select_lex->having_fix_field= 0;
if (res)
{
DBUG_RETURN(RES_ERROR);
}
}
DBUG_RETURN(RES_OK);
}
......
......@@ -762,7 +762,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
TABLE_COUNTER_TYPE local_tables;
ulong tot_length;
DBUG_ENTER("Query_cache::store_query");
if (query_cache_size == 0)
if (query_cache_size == 0 || thd->locked_tables)
DBUG_VOID_RETURN;
uint8 tables_type= 0;
......@@ -921,8 +921,8 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
bool check_tables;
DBUG_ENTER("Query_cache::send_result_to_client");
if (query_cache_size == 0 || thd->variables.query_cache_type == 0)
if (query_cache_size == 0 || thd->locked_tables ||
thd->variables.query_cache_type == 0)
goto err;
/* Check that we haven't forgot to reset the query cache variables */
......
......@@ -1439,7 +1439,8 @@ JOIN::exec()
curr_join->tmp_having= make_cond_for_table(curr_join->tmp_having,
~ (table_map) 0,
~used_tables);
DBUG_EXECUTE("where",print_where(conds,"having after sort"););
DBUG_EXECUTE("where",print_where(curr_join->tmp_having,
"having after sort"););
}
}
{
......
......@@ -20,19 +20,25 @@
EXTRA_DIST = Info.plist.sh \
Description.plist.sh \
StartupParameters.plist.sh \
postinstall.sh \
preinstall.sh \
postflight.sh \
preflight.sh \
ReadMe.txt \
MySQLCOM \
StartupItem.Description.plist \
StartupItem.Info.plist \
StartupItem.postinstall
noinst_DATA = Info.plist \
Description.plist \
StartupParameters.plist \
postflight \
preflight
CLEANFILES = Info.plist \
Description.plist \
StartupParameters.plist \
postinstall \
preinstall
postflight \
preflight
SUFFIXES = .sh
......
#!/bin/sh
#
# postinstall - this script will be executed after the MySQL PKG
# postflight - this script will be executed after the MySQL PKG
# installation has been performed.
#
# This script will install the MySQL privilege tables using the
......
#!/bin/sh
#
# preinstall - this script will be executed before the MySQL PKG
# preflight - this script will be executed before the MySQL PKG
# installation will be performed.
#
# If this package has been compiled with a prefix ending with "mysql" (e.g.
# /usr/local/mysql or /opt/mysql), it will rename any previosuly existing
# /usr/local/mysql or /opt/mysql), it will rename any previously existing
# directory with this name before installing the new package (which includes
# a symlink named "mysql", pointing to the newly installed directory, which
# is named mysql-<version>)
......
......@@ -43,6 +43,9 @@ pkgdata_DATA = my-small.cnf \
pkgdata_SCRIPTS = mysql.server
noinst_DATA = mysql-@VERSION@.spec \
MySQL-shared-compat.spec
CLEANFILES = my-small.cnf \
my-medium.cnf \
my-large.cnf \
......
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