Commit 392c3069 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fixed open_and_lock_tables result processing (all open_and_lock_tables revision)

fixed printing of COLLATE operation
(BUG#5155)
parent 7682b10e
...@@ -141,7 +141,7 @@ COALESCE('a' COLLATE latin1_bin,'b'); ...@@ -141,7 +141,7 @@ COALESCE('a' COLLATE latin1_bin,'b');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce(_latin1'a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,_latin1'1') AS `COALESCE(1,'1')`,coalesce(1.1,_latin1'1') AS `COALESCE(1.1,'1')`,coalesce((_latin1'a' collate _latin1'latin1_bin'),_latin1'b') AS `COALESCE('a' COLLATE latin1_bin,'b')` Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce(_latin1'a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,_latin1'1') AS `COALESCE(1,'1')`,coalesce(1.1,_latin1'1') AS `COALESCE(1.1,'1')`,coalesce((_latin1'a' collate latin1_bin),_latin1'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
......
...@@ -43,7 +43,7 @@ explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order ...@@ -43,7 +43,7 @@ explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using filesort
Warnings: Warnings:
Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,(`test`.`t1`.`st` collate _latin1'BINARY')) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like _latin1'%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,(`test`.`t1`.`st` collate _latin1'BINARY')) Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,(`test`.`t1`.`st` collate BINARY)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like _latin1'%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,(`test`.`t1`.`st` collate BINARY))
select nullif(u=0, 'test') from t1; select nullif(u=0, 'test') from t1;
nullif(u=0, 'test') nullif(u=0, 'test')
NULL NULL
......
...@@ -146,7 +146,7 @@ explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin); ...@@ -146,7 +146,7 @@ explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (_latin1'a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate _latin1'latin1_bin'))) Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (_latin1'a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin)))
drop table t1; drop table t1;
select '1.0' in (1,2); select '1.0' in (1,2);
'1.0' in (1,2) '1.0' in (1,2)
......
...@@ -638,7 +638,7 @@ explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'moo ...@@ -638,7 +638,7 @@ explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'moo
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` Note 1003 select md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate BINARY) AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate latin1_bin),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")`
SELECT lpad(12345, 5, "#"); SELECT lpad(12345, 5, "#");
lpad(12345, 5, "#") lpad(12345, 5, "#")
12345 12345
......
...@@ -108,7 +108,7 @@ explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; ...@@ -108,7 +108,7 @@ explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select (_koi8r'a' = (_koi8r'A' collate _latin1'koi8r_general_ci')) AS `_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci` Note 1003 select (_koi8r'a' = (_koi8r'A' collate koi8r_general_ci)) AS `_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci`
select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin; select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
_koi8r'a' = _koi8r'A' COLLATE koi8r_bin _koi8r'a' = _koi8r'A' COLLATE koi8r_bin
0 0
......
...@@ -1183,3 +1183,13 @@ x () ...@@ -1183,3 +1183,13 @@ x ()
5 5
drop view v1; drop view v1;
drop function x; drop function x;
create table t2 (col1 char collate latin1_german2_ci);
create view v2 as select col1 collate latin1_german1_ci from t2;
show create view v2;
Table Create Table
v2 CREATE VIEW `test`.`v2` AS select (`test`.`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `test`.`t2`
show create view v2;
Table Create Table
v2 CREATE VIEW `test`.`v2` AS select (`test`.`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `test`.`t2`
drop view v2;
drop table t2;
...@@ -1125,3 +1125,13 @@ create view v1 as select x (); ...@@ -1125,3 +1125,13 @@ create view v1 as select x ();
select * from v1; select * from v1;
drop view v1; drop view v1;
drop function x; drop function x;
#
# VIEW with collation
#
create table t2 (col1 char collate latin1_german2_ci);
create view v2 as select col1 collate latin1_german1_ci from t2;
show create view v2;
show create view v2;
drop view v2;
drop table t2;
...@@ -2274,6 +2274,18 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const ...@@ -2274,6 +2274,18 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const
return 1; return 1;
} }
void Item_func_set_collation::print(String *str)
{
str->append('(');
args[0]->print(str);
str->append(" collate ", 9);
DBUG_ASSERT(args[1]->basic_const_item() &&
args[1]->type() == Item::STRING_ITEM);
args[1]->str_value.print(str);
str->append(')');
}
String *Item_func_charset::val_str(String *str) String *Item_func_charset::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
......
...@@ -635,7 +635,7 @@ public: ...@@ -635,7 +635,7 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
const char *func_name() const { return "collate"; } const char *func_name() const { return "collate"; }
void print(String *str) { print_op(str); } void print(String *str);
}; };
class Item_func_charset :public Item_str_func class Item_func_charset :public Item_str_func
......
...@@ -1192,7 +1192,7 @@ sp_instr_set::execute(THD *thd, uint *nextp) ...@@ -1192,7 +1192,7 @@ sp_instr_set::execute(THD *thd, uint *nextp)
if (tables && if (tables &&
((res= check_table_access(thd, SELECT_ACL, tables, 0)) || ((res= check_table_access(thd, SELECT_ACL, tables, 0)) ||
(res= open_and_lock_tables(thd, tables)))) (res= open_and_lock_tables(thd, tables))))
DBUG_RETURN(-1); DBUG_RETURN(res);
it= sp_eval_func_item(thd, m_value, m_type); it= sp_eval_func_item(thd, m_value, m_type);
if (! it) if (! it)
...@@ -1293,7 +1293,7 @@ sp_instr_jump_if::execute(THD *thd, uint *nextp) ...@@ -1293,7 +1293,7 @@ sp_instr_jump_if::execute(THD *thd, uint *nextp)
if (tables && if (tables &&
((res= check_table_access(thd, SELECT_ACL, tables, 0)) || ((res= check_table_access(thd, SELECT_ACL, tables, 0)) ||
(res= open_and_lock_tables(thd, tables)))) (res= open_and_lock_tables(thd, tables))))
DBUG_RETURN(-1); DBUG_RETURN(res);
it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY); it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY);
if (!it) if (!it)
...@@ -1350,7 +1350,7 @@ sp_instr_jump_if_not::execute(THD *thd, uint *nextp) ...@@ -1350,7 +1350,7 @@ sp_instr_jump_if_not::execute(THD *thd, uint *nextp)
if (tables && if (tables &&
((res= check_table_access(thd, SELECT_ACL, tables, 0)) || ((res= check_table_access(thd, SELECT_ACL, tables, 0)) ||
(res= open_and_lock_tables(thd, tables)))) (res= open_and_lock_tables(thd, tables))))
DBUG_RETURN(-1); DBUG_RETURN(res);
it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY); it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY);
if (! it) if (! it)
...@@ -1406,7 +1406,7 @@ sp_instr_freturn::execute(THD *thd, uint *nextp) ...@@ -1406,7 +1406,7 @@ sp_instr_freturn::execute(THD *thd, uint *nextp)
if (tables && if (tables &&
((res= check_table_access(thd, SELECT_ACL, tables, 0)) || ((res= check_table_access(thd, SELECT_ACL, tables, 0)) ||
(res= open_and_lock_tables(thd, tables)))) (res= open_and_lock_tables(thd, tables))))
DBUG_RETURN(-1); DBUG_RETURN(res);
it= sp_eval_func_item(thd, m_value, m_type); it= sp_eval_func_item(thd, m_value, m_type);
if (! it) if (! it)
......
...@@ -1751,6 +1751,7 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables) ...@@ -1751,6 +1751,7 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables)
RETURN RETURN
0 - ok 0 - ok
-1 - error -1 - error
1 - error reported to user
NOTE NOTE
The lock will automaticly be freed by close_thread_tables() The lock will automaticly be freed by close_thread_tables()
......
...@@ -39,8 +39,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, ...@@ -39,8 +39,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
ha_rows deleted; ha_rows deleted;
DBUG_ENTER("mysql_delete"); DBUG_ENTER("mysql_delete");
if ((open_and_lock_tables(thd, table_list))) if ((error= open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1); DBUG_RETURN(error);
table= table_list->table; table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
thd->proc_info="init"; thd->proc_info="init";
......
...@@ -640,11 +640,8 @@ int mysqld_help(THD *thd, const char *mask) ...@@ -640,11 +640,8 @@ int mysqld_help(THD *thd, const char *mask)
uint mlen= strlen(mask); uint mlen= strlen(mask);
MEM_ROOT *mem_root= &thd->mem_root; MEM_ROOT *mem_root= &thd->mem_root;
if (open_and_lock_tables(thd, tables)) if (res= open_and_lock_tables(thd, tables))
{
res= -1;
goto end; goto end;
}
/* /*
Init tables and fields to be usable from items Init tables and fields to be usable from items
......
...@@ -99,8 +99,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -99,8 +99,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
loaded is located loaded is located
*/ */
char *tdb= thd->db ? thd->db : db; // Result is never null char *tdb= thd->db ? thd->db : db; // Result is never null
bool transactional_table, log_delayed;
ulong skip_lines= ex->skip_lines; ulong skip_lines= ex->skip_lines;
int res;
bool transactional_table, log_delayed;
DBUG_ENTER("mysql_load"); DBUG_ENTER("mysql_load");
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
...@@ -114,8 +115,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -114,8 +115,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
table_list->lock_type= lock_type; table_list->lock_type= lock_type;
if (open_and_lock_tables(thd, table_list)) if ((res= open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1); DBUG_RETURN(res);
/* TODO: add key check when we will support VIEWs in LOAD */ /* TODO: add key check when we will support VIEWs in LOAD */
if (!table_list->updatable) if (!table_list->updatable)
{ {
......
...@@ -2136,7 +2136,7 @@ mysql_execute_command(THD *thd) ...@@ -2136,7 +2136,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_DO: case SQLCOM_DO:
if (all_tables && if (all_tables &&
((res= check_table_access(thd, SELECT_ACL, all_tables, 0)) || ((res= check_table_access(thd, SELECT_ACL, all_tables, 0)) ||
(res= open_and_lock_tables(thd, all_tables)))) (res= open_and_lock_tables(thd, all_tables))))
break; break;
res= mysql_do(thd, *lex->insert_list); res= mysql_do(thd, *lex->insert_list);
...@@ -2400,7 +2400,6 @@ mysql_execute_command(THD *thd) ...@@ -2400,7 +2400,6 @@ mysql_execute_command(THD *thd)
if (!(res= open_and_lock_tables(thd, select_tables))) if (!(res= open_and_lock_tables(thd, select_tables)))
{ {
res= -1; // If error
if ((result= new select_create(create_table, if ((result= new select_create(create_table,
&lex->create_info, &lex->create_info,
lex->create_list, lex->create_list,
......
...@@ -897,10 +897,10 @@ static int mysql_test_insert(Prepared_statement *stmt, ...@@ -897,10 +897,10 @@ static int mysql_test_insert(Prepared_statement *stmt,
tables & preparation procedure tables & preparation procedure
*/ */
thd->allocate_temporary_memory_pool_for_ps_preparing(); thd->allocate_temporary_memory_pool_for_ps_preparing();
if (open_and_lock_tables(thd, table_list)) if ((res= open_and_lock_tables(thd, table_list)))
{ {
thd->free_temporary_memory_pool_for_ps_preparing(); thd->free_temporary_memory_pool_for_ps_preparing();
DBUG_RETURN(-1); DBUG_RETURN(res);
} }
if ((values= its++)) if ((values= its++))
...@@ -969,9 +969,7 @@ static int mysql_test_update(Prepared_statement *stmt, ...@@ -969,9 +969,7 @@ static int mysql_test_update(Prepared_statement *stmt,
*/ */
thd->allocate_temporary_memory_pool_for_ps_preparing(); thd->allocate_temporary_memory_pool_for_ps_preparing();
if (open_and_lock_tables(thd, table_list)) if (!(res= open_and_lock_tables(thd, table_list)))
res= -1;
else
{ {
if (!(res= mysql_prepare_update(thd, table_list, if (!(res= mysql_prepare_update(thd, table_list,
&select->where, &select->where,
...@@ -1030,9 +1028,7 @@ static int mysql_test_delete(Prepared_statement *stmt, ...@@ -1030,9 +1028,7 @@ static int mysql_test_delete(Prepared_statement *stmt,
*/ */
thd->allocate_temporary_memory_pool_for_ps_preparing(); thd->allocate_temporary_memory_pool_for_ps_preparing();
if (open_and_lock_tables(thd, table_list)) if (!(res= open_and_lock_tables(thd, table_list)))
res= -1;
else
{ {
res= mysql_prepare_delete(thd, table_list, &lex->select_lex.where); res= mysql_prepare_delete(thd, table_list, &lex->select_lex.where);
lex->unit.cleanup(); lex->unit.cleanup();
...@@ -1065,6 +1061,7 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1065,6 +1061,7 @@ static int mysql_test_select(Prepared_statement *stmt,
THD *thd= stmt->thd; THD *thd= stmt->thd;
LEX *lex= stmt->lex; LEX *lex= stmt->lex;
SELECT_LEX_UNIT *unit= &lex->unit; SELECT_LEX_UNIT *unit= &lex->unit;
int res;
DBUG_ENTER("mysql_test_select"); DBUG_ENTER("mysql_test_select");
...@@ -1084,11 +1081,11 @@ static int mysql_test_select(Prepared_statement *stmt, ...@@ -1084,11 +1081,11 @@ static int mysql_test_select(Prepared_statement *stmt,
tables & preparation procedure tables & preparation procedure
*/ */
thd->allocate_temporary_memory_pool_for_ps_preparing(); thd->allocate_temporary_memory_pool_for_ps_preparing();
if (open_and_lock_tables(thd, tables)) if ((res= open_and_lock_tables(thd, tables)))
{ {
send_error(thd);
goto err; goto err;
} }
res= 1;
thd->used_tables= 0; // Updated by setup_fields thd->used_tables= 0; // Updated by setup_fields
...@@ -1126,7 +1123,7 @@ err_prep: ...@@ -1126,7 +1123,7 @@ err_prep:
unit->cleanup(); unit->cleanup();
err: err:
thd->free_temporary_memory_pool_for_ps_preparing(); thd->free_temporary_memory_pool_for_ps_preparing();
DBUG_RETURN(1); DBUG_RETURN(res);
} }
......
...@@ -497,6 +497,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ...@@ -497,6 +497,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
TABLE *table; TABLE *table;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
TIME time; TIME time;
int res;
DBUG_ENTER("mysqld_extend_show_tables"); DBUG_ENTER("mysqld_extend_show_tables");
(void) sprintf(path,"%s/%s",mysql_data_home,db); (void) sprintf(path,"%s/%s",mysql_data_home,db);
...@@ -554,13 +555,18 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ...@@ -554,13 +555,18 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
table_list.select_lex= &thd->lex->select_lex; table_list.select_lex= &thd->lex->select_lex;
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(files_charset_info, file_name); my_casedn_str(files_charset_info, file_name);
if (open_and_lock_tables(thd, &table_list)) if ((res= open_and_lock_tables(thd, &table_list)))
{ {
for (uint i=2 ; i < field_list.elements ; i++) for (uint i=2 ; i < field_list.elements ; i++)
protocol->store_null(); protocol->store_null();
// Send error to Comment field // Send error to Comment field if possible
protocol->store(thd->net.last_error, system_charset_info); if (res < 0)
thd->clear_error(); {
protocol->store(thd->net.last_error, system_charset_info);
thd->clear_error();
}
else
DBUG_RETURN(1)
} }
else if (table_list.view) else if (table_list.view)
{ {
...@@ -695,14 +701,16 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, ...@@ -695,14 +701,16 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
char tmp[MAX_FIELD_WIDTH]; char tmp[MAX_FIELD_WIDTH];
Item *item; Item *item;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
int res;
DBUG_ENTER("mysqld_show_fields"); DBUG_ENTER("mysqld_show_fields");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db, DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->real_name)); table_list->real_name));
table_list->lock_type= TL_UNLOCK; table_list->lock_type= TL_UNLOCK;
if (open_and_lock_tables(thd, table_list)) if ((res= open_and_lock_tables(thd, table_list)))
{ {
send_error(thd); if (res < 0)
send_error(thd);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
table= table_list->table; table= table_list->table;
...@@ -836,14 +844,16 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) ...@@ -836,14 +844,16 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
char buff[2048]; char buff[2048];
String buffer(buff, sizeof(buff), system_charset_info); String buffer(buff, sizeof(buff), system_charset_info);
int res;
DBUG_ENTER("mysqld_show_create"); DBUG_ENTER("mysqld_show_create");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db, DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->real_name)); table_list->real_name));
/* Only one table for now, but VIEW can involve several tables */ /* Only one table for now, but VIEW can involve several tables */
if (open_and_lock_tables(thd, table_list)) if ((res= open_and_lock_tables(thd, table_list)))
{ {
send_error(thd); if (res < 0)
send_error(thd);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
/* TODO: add environment variables show when it become possible */ /* TODO: add environment variables show when it become possible */
......
...@@ -113,8 +113,8 @@ int mysql_update(THD *thd, ...@@ -113,8 +113,8 @@ int mysql_update(THD *thd,
LINT_INIT(used_index); LINT_INIT(used_index);
LINT_INIT(timestamp_query_id); LINT_INIT(timestamp_query_id);
if ((open_and_lock_tables(thd, table_list))) if ((error= open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1); DBUG_RETURN(error);
thd->proc_info="init"; thd->proc_info="init";
table= table_list->table; table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
......
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