Commit 25042ae7 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0

into sanja.is.com.ua:/home/bell/mysql/bk/work-repl-5.0
parents 14d887c4 e9ad5085
...@@ -187,6 +187,11 @@ typedef struct st_net { ...@@ -187,6 +187,11 @@ typedef struct st_net {
char save_char; char save_char;
my_bool no_send_ok; /* For SPs and other things that do multiple stmts */ my_bool no_send_ok; /* For SPs and other things that do multiple stmts */
my_bool no_send_eof; /* For SPs' first version read-only cursors */ my_bool no_send_eof; /* For SPs' first version read-only cursors */
/*
Set if OK packet is already sent, and we do not need to send error
messages
*/
my_bool no_send_error;
/* /*
Pointer to query object in query cache, do not equal NULL (0) for Pointer to query object in query cache, do not equal NULL (0) for
queries in cache that have not stored its results yet queries in cache that have not stored its results yet
......
...@@ -9,3 +9,15 @@ select 4; ...@@ -9,3 +9,15 @@ select 4;
4 4
4 4
drop table t1; drop table t1;
select get_lock("a", 10);
get_lock("a", 10)
1
select get_lock("a", 10);
get_lock("a", 10)
NULL
select 1;
1
1
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1,v1;
drop view if exists t1,v1;
create table t1 (a int);
insert into t1 values (1);
create view v1 as select a from t1;
insert into v1 values (2);
select * from v1 order by a;
a
1
2
select * from v1 order by a;
a
1
2
update v1 set a=3 where a=1;
select * from v1 order by a;
a
2
3
select * from v1 order by a;
a
2
3
delete from v1 where a=2;
select * from v1 order by a;
a
3
select * from v1 order by a;
a
3
alter view v1 as select a as b from t1;
select * from v1 order by 1;
b
3
drop view v1;
select * from v1 order by a;
ERROR 42S02: Table 'test.v1' doesn't exist
drop table t1;
...@@ -1730,3 +1730,23 @@ select * from v1 where F1 = 1; ...@@ -1730,3 +1730,23 @@ select * from v1 where F1 = 1;
f1 f1
drop view v1; drop view v1;
drop table t1; drop table t1;
create table t1(c1 int);
create table t2(c2 int);
insert into t1 values (1),(2),(3);
insert into t2 values (1);
SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
c1
1
SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
c1
1
create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
select * from v1;
c1
1
select * from v2;
c1
1
drop view v2, v1;
drop table t1, t2;
...@@ -35,3 +35,21 @@ select @id != connection_id(); ...@@ -35,3 +35,21 @@ select @id != connection_id();
connection con2; connection con2;
select 4; select 4;
drop table t1; drop table t1;
#
# test of blocking of sending ERROR after OK or EOF
#
connection con1;
select get_lock("a", 10);
connection con2;
let $ID= `select connection_id()`;
send select get_lock("a", 10);
connection con1;
disable_query_log;
eval kill query $ID;
enable_query_log;
connection con2;
reap;
select 1;
connection con1;
select RELEASE_LOCK("a");
source include/master-slave.inc;
--disable_warnings
drop table if exists t1,v1;
drop view if exists t1,v1;
sync_slave_with_master;
--enable_warnings
#
# Check that createion drop of view is replicated, also check replication of
# updating of view
#
connection master;
create table t1 (a int);
insert into t1 values (1);
create view v1 as select a from t1;
insert into v1 values (2);
select * from v1 order by a;
sync_slave_with_master;
# view already have to be on slave
select * from v1 order by a;
connection master;
update v1 set a=3 where a=1;
select * from v1 order by a;
sync_slave_with_master;
select * from v1 order by a;
connection master;
delete from v1 where a=2;
select * from v1 order by a;
sync_slave_with_master;
select * from v1 order by a;
connection master;
# 'alter view' internally maped to creation, but still check that it works
alter view v1 as select a as b from t1;
sync_slave_with_master;
select * from v1 order by 1;
connection master;
drop view v1;
sync_slave_with_master;
#error, because view have to be removed from slave
-- error 1146
select * from v1 order by a;
connection master;
drop table t1;
sync_slave_with_master;
...@@ -1655,9 +1655,27 @@ select * from v3; ...@@ -1655,9 +1655,27 @@ select * from v3;
drop view v3; drop view v3;
drop tables t1,t2; drop tables t1,t2;
#
# View field names should be case insensitive # View field names should be case insensitive
#
create table t1(f1 int); create table t1(f1 int);
create view v1 as select f1 from t1; create view v1 as select f1 from t1;
select * from v1 where F1 = 1; select * from v1 where F1 = 1;
drop view v1; drop view v1;
drop table t1; drop table t1;
#
# Resolving view fields in subqueries in VIEW (Bug #6394)
#
create table t1(c1 int);
create table t2(c2 int);
insert into t1 values (1),(2),(3);
insert into t2 values (1);
SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
select * from v1;
select * from v2;
drop view v2, v1;
drop table t1, t2;
...@@ -3578,7 +3578,7 @@ Item_func_sp::execute(Item **itp) ...@@ -3578,7 +3578,7 @@ Item_func_sp::execute(Item **itp)
#endif #endif
/* /*
We don't need to surpress senfing of ok packet here (by setting We don't need to surpress sending of ok packet here (by setting
thd->net.no_send_ok to true), because we are not allowing statements thd->net.no_send_ok to true), because we are not allowing statements
in functions now. in functions now.
*/ */
......
...@@ -121,8 +121,7 @@ my_bool my_net_init(NET *net, Vio* vio) ...@@ -121,8 +121,7 @@ my_bool my_net_init(NET *net, Vio* vio)
DBUG_RETURN(1); DBUG_RETURN(1);
net->buff_end=net->buff+net->max_packet; net->buff_end=net->buff+net->max_packet;
net->vio = vio; net->vio = vio;
net->no_send_ok = 0; net->no_send_ok= net->no_send_eof= net->no_send_error= 0;
net->no_send_eof = 0;
net->error=0; net->return_errno=0; net->return_status=0; net->error=0; net->return_errno=0; net->return_status=0;
net->pkt_nr=net->compress_pkt_nr=0; net->pkt_nr=net->compress_pkt_nr=0;
net->write_pos=net->read_pos = net->buff; net->write_pos=net->read_pos = net->buff;
......
...@@ -65,6 +65,12 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -65,6 +65,12 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
err ? err : net->last_error[0] ? err ? err : net->last_error[0] ?
net->last_error : "NULL")); net->last_error : "NULL"));
if (net && net->no_send_error)
{
thd->clear_error();
DBUG_PRINT("info", ("sending error messages prohibited"));
DBUG_VOID_RETURN;
}
if (thd->spcont && thd->spcont->find_handler(sql_errno, if (thd->spcont && thd->spcont->find_handler(sql_errno,
MYSQL_ERROR::WARN_LEVEL_ERROR)) MYSQL_ERROR::WARN_LEVEL_ERROR))
{ {
...@@ -154,6 +160,13 @@ net_printf_error(THD *thd, uint errcode, ...) ...@@ -154,6 +160,13 @@ net_printf_error(THD *thd, uint errcode, ...)
DBUG_ENTER("net_printf_error"); DBUG_ENTER("net_printf_error");
DBUG_PRINT("enter",("message: %u",errcode)); DBUG_PRINT("enter",("message: %u",errcode));
if (net && net->no_send_error)
{
thd->clear_error();
DBUG_PRINT("info", ("sending error messages prohibited"));
DBUG_VOID_RETURN;
}
if (thd->spcont && thd->spcont->find_handler(errcode, if (thd->spcont && thd->spcont->find_handler(errcode,
MYSQL_ERROR::WARN_LEVEL_ERROR)) MYSQL_ERROR::WARN_LEVEL_ERROR))
{ {
...@@ -300,6 +313,9 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) ...@@ -300,6 +313,9 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
VOID(net_flush(net)); VOID(net_flush(net));
/* We can't anymore send an error to the client */ /* We can't anymore send an error to the client */
thd->net.report_error= 0; thd->net.report_error= 0;
thd->net.no_send_error= 1;
DBUG_PRINT("info", ("OK sent, so no more error sendong allowed"));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -357,6 +373,8 @@ send_eof(THD *thd, bool no_flush) ...@@ -357,6 +373,8 @@ send_eof(THD *thd, bool no_flush)
if (!no_flush) if (!no_flush)
VOID(net_flush(net)); VOID(net_flush(net));
} }
thd->net.no_send_error= 1;
DBUG_PRINT("info", ("EOF sent, so no more error sendong allowed"));
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -5520,6 +5520,9 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, ...@@ -5520,6 +5520,9 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
/* global privileges */ /* global privileges */
grant->privilege= thd->master_access; grant->privilege= thd->master_access;
if (!thd->priv_user)
return; // it is slave
/* db privileges */ /* db privileges */
grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0);
......
...@@ -957,6 +957,7 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, ...@@ -957,6 +957,7 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var,
*/ */
save_vio= thd->net.vio; save_vio= thd->net.vio;
thd->net.vio= 0; thd->net.vio= 0;
thd->net.no_send_error= 0;
dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1);
rw_unlock(var_mutex); rw_unlock(var_mutex);
thd->client_capabilities= save_client_capabilities; thd->client_capabilities= save_client_capabilities;
...@@ -1016,6 +1017,7 @@ pthread_handler_decl(handle_one_connection,arg) ...@@ -1016,6 +1017,7 @@ pthread_handler_decl(handle_one_connection,arg)
int error; int error;
NET *net= &thd->net; NET *net= &thd->net;
thd->thread_stack= (char*) &thd; thd->thread_stack= (char*) &thd;
net->no_send_error= 0;
if ((error=check_connection(thd))) if ((error=check_connection(thd)))
{ // Wrong permissions { // Wrong permissions
...@@ -1054,6 +1056,7 @@ pthread_handler_decl(handle_one_connection,arg) ...@@ -1054,6 +1056,7 @@ pthread_handler_decl(handle_one_connection,arg)
thd->init_for_queries(); thd->init_for_queries();
while (!net->error && net->vio != 0 && !(thd->killed == THD::KILL_CONNECTION)) while (!net->error && net->vio != 0 && !(thd->killed == THD::KILL_CONNECTION))
{ {
net->no_send_error= 0;
if (do_command(thd)) if (do_command(thd))
break; break;
} }
...@@ -2084,6 +2087,7 @@ mysql_execute_command(THD *thd) ...@@ -2084,6 +2087,7 @@ mysql_execute_command(THD *thd)
/* most outer SELECT_LEX_UNIT of query */ /* most outer SELECT_LEX_UNIT of query */
SELECT_LEX_UNIT *unit= &lex->unit; SELECT_LEX_UNIT *unit= &lex->unit;
DBUG_ENTER("mysql_execute_command"); DBUG_ENTER("mysql_execute_command");
thd->net.no_send_error= 0;
/* /*
In many cases first table of main SELECT_LEX have special meaning => In many cases first table of main SELECT_LEX have special meaning =>
...@@ -4055,7 +4059,12 @@ unsent_create_error: ...@@ -4055,7 +4059,12 @@ unsent_create_error:
} }
case SQLCOM_CREATE_VIEW: case SQLCOM_CREATE_VIEW:
{ {
res= mysql_create_view(thd, thd->lex->create_view_mode); if (!(res= mysql_create_view(thd, thd->lex->create_view_mode)) &&
mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
}
break; break;
} }
case SQLCOM_DROP_VIEW: case SQLCOM_DROP_VIEW:
...@@ -4063,7 +4072,12 @@ unsent_create_error: ...@@ -4063,7 +4072,12 @@ unsent_create_error:
if (check_table_access(thd, DROP_ACL, all_tables, 0) || if (check_table_access(thd, DROP_ACL, all_tables, 0) ||
end_active_trans(thd)) end_active_trans(thd))
goto error; goto error;
res= mysql_drop_view(thd, first_table, thd->lex->drop_mode); if (!(res= mysql_drop_view(thd, first_table, thd->lex->drop_mode)) &&
mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
}
break; break;
} }
case SQLCOM_CREATE_TRIGGER: case SQLCOM_CREATE_TRIGGER:
......
...@@ -1699,6 +1699,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, ...@@ -1699,6 +1699,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
Field_translator *transl; Field_translator *transl;
SELECT_LEX *select= &view->select_lex; SELECT_LEX *select= &view->select_lex;
SELECT_LEX *current_select_save= thd->lex->current_select; SELECT_LEX *current_select_save= thd->lex->current_select;
byte *main_table_list_save= thd->lex->select_lex.table_list.first;
Item *item; Item *item;
TABLE_LIST *tbl; TABLE_LIST *tbl;
List_iterator_fast<Item> it(select->item_list); List_iterator_fast<Item> it(select->item_list);
...@@ -1721,8 +1722,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, ...@@ -1721,8 +1722,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if (field_translation) if (field_translation)
{ {
DBUG_PRINT("info", ("there are already translation table")); DBUG_PRINT("info", ("there are already translation table"));
/* prevent look up in SELECTs tree */ /*
prevent look up in SELECTs tree, and emulate main table list by
ancestor table list for subquery processing
*/
thd->lex->current_select= &thd->lex->select_lex; thd->lex->current_select= &thd->lex->select_lex;
thd->lex->select_lex.table_list.first= (byte *)ancestor;
thd->lex->select_lex.no_wrap_view_item= 1; thd->lex->select_lex.no_wrap_view_item= 1;
thd->set_query_id= 1; thd->set_query_id= 1;
/* this view was prepared already on previous PS/SP execution */ /* this view was prepared already on previous PS/SP execution */
...@@ -1767,8 +1773,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, ...@@ -1767,8 +1773,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
DBUG_RETURN(1); DBUG_RETURN(1);
} }
/* prevent look up in SELECTs tree */ /*
prevent look up in SELECTs tree, and emulate main table list by ancestor
table list for subquery processing
*/
thd->lex->current_select= &thd->lex->select_lex; thd->lex->current_select= &thd->lex->select_lex;
thd->lex->select_lex.table_list.first= (byte *)ancestor;
thd->lex->select_lex.no_wrap_view_item= 1; thd->lex->select_lex.no_wrap_view_item= 1;
/* /*
...@@ -1913,6 +1924,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, ...@@ -1913,6 +1924,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
ok: ok:
thd->lex->select_lex.no_wrap_view_item= save_wrapper; thd->lex->select_lex.no_wrap_view_item= save_wrapper;
thd->lex->current_select= current_select_save; thd->lex->current_select= current_select_save;
thd->lex->select_lex.table_list.first= main_table_list_save;
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
thd->allow_sum_func= save_allow_sum_func; thd->allow_sum_func= save_allow_sum_func;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1927,6 +1939,7 @@ err: ...@@ -1927,6 +1939,7 @@ err:
} }
thd->lex->select_lex.no_wrap_view_item= save_wrapper; thd->lex->select_lex.no_wrap_view_item= save_wrapper;
thd->lex->current_select= current_select_save; thd->lex->current_select= current_select_save;
thd->lex->select_lex.table_list.first= main_table_list_save;
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
thd->allow_sum_func= save_allow_sum_func; thd->allow_sum_func= save_allow_sum_func;
DBUG_RETURN(1); DBUG_RETURN(1);
......
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