Commit 317524ce authored by paul@ice.snake.net's avatar paul@ice.snake.net

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into ice.snake.net:/Volumes/ice2/MySQL/bk/mysql-4.1
parents 7228c5cb e71b6931
...@@ -2336,6 +2336,7 @@ dnl you must also create strings/ctype-$charset_name.c ...@@ -2336,6 +2336,7 @@ dnl you must also create strings/ctype-$charset_name.c
AC_DIVERT_PUSH(0) AC_DIVERT_PUSH(0)
define(CHARSETS_AVAILABLE0,binary)
define(CHARSETS_AVAILABLE1,ascii armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) define(CHARSETS_AVAILABLE1,ascii armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257)
define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 dec8 euckr gb2312 gbk geostd8) define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 dec8 euckr gb2312 gbk geostd8)
define(CHARSETS_AVAILABLE3,greek hebrew hp8 keybcs2 koi8r koi8u) define(CHARSETS_AVAILABLE3,greek hebrew hp8 keybcs2 koi8r koi8u)
...@@ -2343,7 +2344,7 @@ define(CHARSETS_AVAILABLE4,latin1 latin2 latin5 latin7 macce macroman) ...@@ -2343,7 +2344,7 @@ define(CHARSETS_AVAILABLE4,latin1 latin2 latin5 latin7 macce macroman)
define(CHARSETS_AVAILABLE5,sjis swe7 tis620 ucs2 ujis utf8) define(CHARSETS_AVAILABLE5,sjis swe7 tis620 ucs2 ujis utf8)
DEFAULT_CHARSET=latin1 DEFAULT_CHARSET=latin1
CHARSETS_AVAILABLE="CHARSETS_AVAILABLE1 CHARSETS_AVAILABLE2 CHARSETS_AVAILABLE3 CHARSETS_AVAILABLE4 CHARSETS_AVAILABLE5" CHARSETS_AVAILABLE="CHARSETS_AVAILABLE0 CHARSETS_AVAILABLE1 CHARSETS_AVAILABLE2 CHARSETS_AVAILABLE3 CHARSETS_AVAILABLE4 CHARSETS_AVAILABLE5"
CHARSETS_COMPLEX="big5 cp1250 euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8" CHARSETS_COMPLEX="big5 cp1250 euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8"
AC_DIVERT_POP AC_DIVERT_POP
...@@ -2351,6 +2352,7 @@ AC_DIVERT_POP ...@@ -2351,6 +2352,7 @@ AC_DIVERT_POP
AC_ARG_WITH(charset, AC_ARG_WITH(charset,
[ --with-charset=CHARSET [ --with-charset=CHARSET
Default character set, use one of: Default character set, use one of:
CHARSETS_AVAILABLE0
CHARSETS_AVAILABLE1 CHARSETS_AVAILABLE1
CHARSETS_AVAILABLE2 CHARSETS_AVAILABLE2
CHARSETS_AVAILABLE3 CHARSETS_AVAILABLE3
......
drop table if exists t1; drop table if exists t1;
drop table if exists t2;
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3; create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
insert into t1 values (1,1),(NULL,3),(NULL,4); insert into t1 values (1,1),(NULL,3),(NULL,4);
......
...@@ -120,3 +120,13 @@ a b ...@@ -120,3 +120,13 @@ a b
0 10 0 10
1 11 1 11
drop table t11, t12, t2; drop table t11, t12, t2;
create table t1 (a int, b int, unique key (a), key (b));
insert into t1 values (3, 3), (7, 7);
delete t1 from t1 where a = 3;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
a b
7 7
drop table t1;
...@@ -81,3 +81,20 @@ _latin1'a' regexp _latin1'A' collate latin1_general_ci ...@@ -81,3 +81,20 @@ _latin1'a' regexp _latin1'A' collate latin1_general_ci
select _latin1'a' regexp _latin1'A' collate latin1_bin; select _latin1'a' regexp _latin1'A' collate latin1_bin;
_latin1'a' regexp _latin1'A' collate latin1_bin _latin1'a' regexp _latin1'A' collate latin1_bin
0 0
create table t1 (a varchar(40));
insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3');
prepare stmt1 from 'select a from t1 where a rlike ? order by a';
set @a="^C.*";
execute stmt1 using @a;
a
C1
C2
C3
set @a="^R.*";
execute stmt1 using @a;
a
R1
R2
R3
deallocate prepare stmt1;
drop table t1;
...@@ -1831,6 +1831,15 @@ Warnings: ...@@ -1831,6 +1831,15 @@ Warnings:
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a)) Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a))
drop table t1; drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (t2_a int, t2_b int, PRIMARY KEY (t2_a, t2_b));
INSERT INTO t2 VALUES (1, 1), (1, 2);
SELECT * FROM t1, t2 table2 WHERE t1_a = 1 AND table2.t2_a = 1
HAVING table2.t2_b = (SELECT MAX(t2_b) FROM t2 WHERE t2_a = table2.t2_a);
t1_a t2_a t2_b
1 1 2
DROP TABLE t1, t2;
CREATE TABLE t1 (id int(11) default NULL,name varchar(10) default NULL); CREATE TABLE t1 (id int(11) default NULL,name varchar(10) default NULL);
INSERT INTO t1 VALUES (1,'Tim'),(2,'Rebecca'),(3,NULL); INSERT INTO t1 VALUES (1,'Tim'),(2,'Rebecca'),(3,NULL);
CREATE TABLE t2 (id int(11) default NULL, pet varchar(10) default NULL); CREATE TABLE t2 (id int(11) default NULL, pet varchar(10) default NULL);
...@@ -1841,3 +1850,44 @@ id name id pet ...@@ -1841,3 +1850,44 @@ id name id pet
2 Rebecca 2 Spot 2 Rebecca 2 Spot
3 NULL 3 Felix 3 NULL 3 Felix
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
abc b
1 2
2 3
3 4
INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t2;
c d
1 2
2 3
3 4
CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t3;
abc b
1 2
2 3
3 4
prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
execute stmt1;
deallocate prepare stmt1;
select * from t2;
c d
1 2
2 3
3 4
1 2
2 3
3 4
drop table t3;
prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
execute stmt1;
select * from t3;
abc b
1 2
2 3
3 4
deallocate prepare stmt1;
DROP TABLE t1, t2, t3;
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
drop table if exists t2;
--enable_warnings --enable_warnings
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;
......
...@@ -98,3 +98,14 @@ select * from t11; ...@@ -98,3 +98,14 @@ select * from t11;
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11; select * from t11;
drop table t11, t12, t2; drop table t11, t12, t2;
#
# Bug #4198: deletion and KEYREAD
#
create table t1 (a int, b int, unique key (a), key (b));
insert into t1 values (3, 3), (7, 7);
delete t1 from t1 where a = 3;
check table t1;
select * from t1;
drop table t1;
...@@ -60,3 +60,16 @@ select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]'; ...@@ -60,3 +60,16 @@ select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
select _latin1'a' regexp _latin1'A' collate latin1_general_ci; select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
select _latin1'a' regexp _latin1'A' collate latin1_bin; select _latin1'a' regexp _latin1'A' collate latin1_bin;
#
# regexp cleanup()
#
create table t1 (a varchar(40));
insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3');
prepare stmt1 from 'select a from t1 where a rlike ? order by a';
set @a="^C.*";
execute stmt1 using @a;
set @a="^R.*";
execute stmt1 using @a;
deallocate prepare stmt1;
drop table t1;
...@@ -1168,6 +1168,18 @@ select * from t1 up where exists (select * from t1 where t1.a=up.a); ...@@ -1168,6 +1168,18 @@ select * from t1 up where exists (select * from t1 where t1.a=up.a);
explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a); explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
drop table t1; drop table t1;
#
# Bug #4102: subselect in HAVING
#
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (t2_a int, t2_b int, PRIMARY KEY (t2_a, t2_b));
INSERT INTO t2 VALUES (1, 1), (1, 2);
SELECT * FROM t1, t2 table2 WHERE t1_a = 1 AND table2.t2_a = 1
HAVING table2.t2_b = (SELECT MAX(t2_b) FROM t2 WHERE t2_a = table2.t2_a);
DROP TABLE t1, t2;
# #
# Test problem with NULL and derived tables (Bug #4097) # Test problem with NULL and derived tables (Bug #4097)
# #
...@@ -1178,3 +1190,25 @@ CREATE TABLE t2 (id int(11) default NULL, pet varchar(10) default NULL); ...@@ -1178,3 +1190,25 @@ CREATE TABLE t2 (id int(11) default NULL, pet varchar(10) default NULL);
INSERT INTO t2 VALUES (1,'Fido'),(2,'Spot'),(3,'Felix'); INSERT INTO t2 VALUES (1,'Fido'),(2,'Spot'),(3,'Felix');
SELECT a.*, b.* FROM (SELECT * FROM t1) AS a JOIN t2 as b on a.id=b.id; SELECT a.*, b.* FROM (SELECT * FROM t1) AS a JOIN t2 as b on a.id=b.id;
drop table t1,t2; drop table t1,t2;
#
# outer fields resolving in INSERT/REPLACE and CRETE with SELECT
#
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t2;
CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t3;
prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
execute stmt1;
deallocate prepare stmt1;
select * from t2;
drop table t3;
prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
execute stmt1;
select * from t3;
deallocate prepare stmt1;
DROP TABLE t1, t2, t3;
...@@ -27,7 +27,7 @@ WRAPLIBS= @WRAPLIBS@ ...@@ -27,7 +27,7 @@ WRAPLIBS= @WRAPLIBS@
SUBDIRS = share SUBDIRS = share
libexec_PROGRAMS = mysqld libexec_PROGRAMS = mysqld
bin_PROGRAMS = mysql_tzinfo_to_sql bin_PROGRAMS = mysql_tzinfo_to_sql
noinst_PROGRAMS = gen_lex_hash test_time noinst_PROGRAMS = gen_lex_hash
gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@ gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
LDADD = @isam_libs@ \ LDADD = @isam_libs@ \
../myisam/libmyisam.a \ ../myisam/libmyisam.a \
...@@ -97,10 +97,6 @@ mysql_tzinfo_to_sql_SOURCES = tztime.cc tzfile.h ...@@ -97,10 +97,6 @@ mysql_tzinfo_to_sql_SOURCES = tztime.cc tzfile.h
mysql_tzinfo_to_sql_CPPFLAGS = -DTZINFO2SQL $(AM_CPPFLAGS) mysql_tzinfo_to_sql_CPPFLAGS = -DTZINFO2SQL $(AM_CPPFLAGS)
mysql_tzinfo_to_sql_LDADD = $(LDADD) $(CXXLDFLAGS) mysql_tzinfo_to_sql_LDADD = $(LDADD) $(CXXLDFLAGS)
test_time_SOURCES = tztime.cc time.cc tzfile.h
test_time_CPPFLAGS = -DTESTTIME $(AM_CPPFLAGS)
test_time_LDADD = $(LDADD) $(CXXLDFLAGS)
DEFS = -DMYSQL_SERVER \ DEFS = -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \
......
...@@ -756,43 +756,42 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) ...@@ -756,43 +756,42 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
if (entry && entry->value) if (entry && entry->value)
{ {
item_result_type= entry->type; item_result_type= entry->type;
switch (entry->type) switch (entry->type) {
case REAL_RESULT:
set_double(*(double*)entry->value);
break;
case INT_RESULT:
set_int(*(longlong*)entry->value, 21);
break;
case STRING_RESULT:
{ {
case REAL_RESULT: CHARSET_INFO *fromcs= entry->collation.collation;
set_double(*(double*)entry->value); CHARSET_INFO *tocs= thd->variables.collation_connection;
break; uint32 dummy_offset;
case INT_RESULT:
set_int(*(longlong*)entry->value, 21); value.cs_info.character_set_client= fromcs;
break; /*
case STRING_RESULT: Setup source and destination character sets so that they
{ are different only if conversion is necessary: this will
CHARSET_INFO *fromcs= entry->collation.collation; make later checks easier.
CHARSET_INFO *tocs= thd->variables.collation_connection; */
uint32 dummy_offset; value.cs_info.final_character_set_of_str_value=
String::needs_conversion(0, fromcs, tocs, &dummy_offset) ?
value.cs_info.character_set_client= fromcs; tocs : fromcs;
/* /*
Setup source and destination character sets so that they Exact value of max_length is not known unless data is converted to
are different only if conversion is necessary: this will charset of connection, so we have to set it later.
make later checks easier. */
*/ item_type= Item::STRING_ITEM;
value.cs_info.final_character_set_of_str_value= item_result_type= STRING_RESULT;
String::needs_conversion(0, fromcs, tocs, &dummy_offset) ?
tocs : fromcs; if (set_str((const char *)entry->value, entry->length))
/* DBUG_RETURN(1);
Exact value of max_length is not known unless data is converted to break;
charset of connection, so we have to set it later. }
*/ default:
item_type= Item::STRING_ITEM; DBUG_ASSERT(0);
item_result_type= STRING_RESULT; set_null();
if (set_str((const char *)entry->value, entry->length))
DBUG_RETURN(1);
}
break;
default:
DBUG_ASSERT(0);
set_null();
} }
} }
else else
......
...@@ -822,7 +822,10 @@ public: ...@@ -822,7 +822,10 @@ public:
void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); } void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); }
enum Item_result result_type () const { return (*ref)->result_type(); } enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); } enum_field_types field_type() const { return (*ref)->field_type(); }
table_map used_tables() const { return (*ref)->used_tables(); } table_map used_tables() const
{
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
}
void set_result_field(Field *field) { result_field= field; } void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; } bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions) void save_in_result_field(bool no_conversions)
......
...@@ -2298,15 +2298,19 @@ longlong Item_func_regex::val_int() ...@@ -2298,15 +2298,19 @@ longlong Item_func_regex::val_int()
} }
Item_func_regex::~Item_func_regex() void Item_func_regex::cleanup()
{ {
DBUG_ENTER("Item_func_regex::cleanup");
Item_bool_func::cleanup();
if (regex_compiled) if (regex_compiled)
{ {
regfree(&preg); regfree(&preg);
regex_compiled=0; regex_compiled=0;
} }
DBUG_VOID_RETURN;
} }
#endif /* USE_REGEX */ #endif /* USE_REGEX */
......
...@@ -869,7 +869,7 @@ class Item_func_regex :public Item_bool_func ...@@ -869,7 +869,7 @@ class Item_func_regex :public Item_bool_func
public: public:
Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b), Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b),
regex_compiled(0),regex_is_const(0) {} regex_compiled(0),regex_is_const(0) {}
~Item_func_regex(); void cleanup();
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref);
const char *func_name() const { return "regexp"; } const char *func_name() const { return "regexp"; }
......
...@@ -561,7 +561,7 @@ public: ...@@ -561,7 +561,7 @@ public:
{ {
Statement *stmt; Statement *stmt;
stmt= (Statement *) hash_search(&st_hash, (byte *) &id, sizeof(id)); stmt= (Statement *) hash_search(&st_hash, (byte *) &id, sizeof(id));
if (stmt->name.str) if (stmt && stmt->name.str)
return NULL; return NULL;
last_found_statement= stmt; last_found_statement= stmt;
} }
......
...@@ -2354,7 +2354,15 @@ mysql_execute_command(THD *thd) ...@@ -2354,7 +2354,15 @@ mysql_execute_command(THD *thd)
lex->create_list, lex->create_list,
lex->key_list, lex->key_list,
select_lex->item_list,lex->duplicates))) select_lex->item_list,lex->duplicates)))
{
/*
CREATE from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
res=handle_select(thd, lex, result); res=handle_select(thd, lex, result);
select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
}
//reset for PS //reset for PS
lex->create_list.empty(); lex->create_list.empty();
lex->key_list.empty(); lex->key_list.empty();
...@@ -2704,7 +2712,11 @@ unsent_create_error: ...@@ -2704,7 +2712,11 @@ unsent_create_error:
lex->duplicates))) lex->duplicates)))
/* Skip first table, which is the table we are inserting in */ /* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*) first_local_table->next; lex->select_lex.table_list.first= (byte*) first_local_table->next;
lex->select_lex.resolve_mode= SELECT_LEX::NOMATTER_MODE; /*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
res=handle_select(thd,lex,result); res=handle_select(thd,lex,result);
/* revert changes for SP */ /* revert changes for SP */
lex->select_lex.table_list.first= (byte*) first_local_table; lex->select_lex.table_list.first= (byte*) first_local_table;
......
...@@ -1307,6 +1307,7 @@ static int mysql_test_create_table(Prepared_statement *stmt, ...@@ -1307,6 +1307,7 @@ static int mysql_test_create_table(Prepared_statement *stmt,
DBUG_ENTER("mysql_test_create_table"); DBUG_ENTER("mysql_test_create_table");
THD *thd= stmt->thd; THD *thd= stmt->thd;
LEX *lex= stmt->lex; LEX *lex= stmt->lex;
SELECT_LEX *select_lex= &lex->select_lex;
int res= 0; int res= 0;
/* Skip first table, which is the table we are creating */ /* Skip first table, which is the table we are creating */
...@@ -1315,8 +1316,12 @@ static int mysql_test_create_table(Prepared_statement *stmt, ...@@ -1315,8 +1316,12 @@ static int mysql_test_create_table(Prepared_statement *stmt,
&create_table_local); &create_table_local);
if (!(res= create_table_precheck(thd, tables, create_table)) && if (!(res= create_table_precheck(thd, tables, create_table)) &&
lex->select_lex.item_list.elements) select_lex->item_list.elements)
{
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
res= select_like_statement_test(stmt, tables); res= select_like_statement_test(stmt, tables);
select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
}
/* put tables back for PS rexecuting */ /* put tables back for PS rexecuting */
tables= lex->link_first_table_back(tables, create_table, tables= lex->link_first_table_back(tables, create_table,
...@@ -1400,7 +1405,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt, ...@@ -1400,7 +1405,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
(TABLE_LIST *)lex->select_lex.table_list.first; (TABLE_LIST *)lex->select_lex.table_list.first;
/* Skip first table, which is the table we are inserting in */ /* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*) first_local_table->next; lex->select_lex.table_list.first= (byte*) first_local_table->next;
lex->select_lex.resolve_mode= SELECT_LEX::NOMATTER_MODE; /*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
res= select_like_statement_test(stmt, tables); res= select_like_statement_test(stmt, tables);
/* revert changes*/ /* revert changes*/
lex->select_lex.table_list.first= (byte*) first_local_table; lex->select_lex.table_list.first= (byte*) first_local_table;
......
...@@ -5976,7 +5976,8 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) ...@@ -5976,7 +5976,8 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
else else
{ {
if (!table->key_read && table->used_keys.is_set(tab->ref.key) && if (!table->key_read && table->used_keys.is_set(tab->ref.key) &&
!table->no_keyread) !table->no_keyread &&
(int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY)
{ {
table->key_read=1; table->key_read=1;
table->file->extra(HA_EXTRA_KEYREAD); table->file->extra(HA_EXTRA_KEYREAD);
......
...@@ -36,7 +36,6 @@ LIBS = @CLIENT_LIBS@ ...@@ -36,7 +36,6 @@ LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
client_test_LDADD= $(LDADD) $(CXXLDFLAGS) client_test_LDADD= $(LDADD) $(CXXLDFLAGS)
client_test_SOURCES= client_test.c client_test_SOURCES= client_test.c
client_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
......
...@@ -9912,6 +9912,35 @@ static void test_bug4079() ...@@ -9912,6 +9912,35 @@ static void test_bug4079()
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
static void test_bug4236()
{
MYSQL_STMT *stmt;
const char *stmt_text;
int rc;
MYSQL_STMT backup;
myheader("test_bug4296");
stmt= mysql_stmt_init(mysql);
/* mysql_stmt_execute() of statement with statement id= 0 crashed server */
stmt_text= "SELECT 1";
/* We need to prepare statement to pass by possible check in libmysql */
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
/* Hack to check that server works OK if statement wasn't found */
backup.stmt_id= stmt->stmt_id;
stmt->stmt_id= 0;
rc= mysql_stmt_execute(stmt);
assert(rc);
/* Restore original statement id to be able to reprepare it */
stmt->stmt_id= backup.stmt_id;
mysql_stmt_close(stmt);
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
*/ */
...@@ -10206,6 +10235,7 @@ int main(int argc, char **argv) ...@@ -10206,6 +10235,7 @@ int main(int argc, char **argv)
test_bug3796(); /* test for select concat(?, <string>) */ test_bug3796(); /* test for select concat(?, <string>) */
test_bug4026(); /* test microseconds precision of time types */ test_bug4026(); /* test microseconds precision of time types */
test_bug4079(); /* erroneous subquery in prepared statement */ test_bug4079(); /* erroneous subquery in prepared statement */
test_bug4236(); /* init -> execute */
/* /*
XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST
DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH.
......
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