Commit c4c4510a authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new
parents ea22f9ea c0546328
DROP TABLE IF EXISTS t1,t2,t3;
DROP VIEW IF EXISTS v1,v2,v3;
create table t1 (a int, b int, c int, d int) engine=ndb;
insert into t1 values (1,2,3,4),(5,6,7,8);
create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1;
select * from v1 order by a,b,c;
a b c d
3 1 4 6
7 5 8 18
update v1 set a=a+100 where b=1;
select * from v1 order by a,b,c;
a b c d
7 5 8 18
103 1 4 106
drop view v1;
create view v1 as select t1.c as a from t1;
insert into v1 values (200);
select * from t1 order by a,b,c,d;
a b c d
NULL NULL 200 NULL
1 2 103 4
5 6 7 8
drop view v1;
drop table t1;
-- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
DROP VIEW IF EXISTS v1,v2,v3;
--enable_warnings
#
# simple operations via view
#
create table t1 (a int, b int, c int, d int) engine=ndb;
insert into t1 values (1,2,3,4),(5,6,7,8);
create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1;
select * from v1 order by a,b,c;
update v1 set a=a+100 where b=1;
select * from v1 order by a,b,c;
drop view v1;
create view v1 as select t1.c as a from t1;
insert into v1 values (200);
select * from t1 order by a,b,c,d;
drop view v1;
drop table t1;
...@@ -69,7 +69,7 @@ handlerton ndbcluster_hton = { ...@@ -69,7 +69,7 @@ handlerton ndbcluster_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION, MYSQL_HANDLERTON_INTERFACE_VERSION,
"ndbcluster", "ndbcluster",
SHOW_OPTION_YES, SHOW_OPTION_YES,
"Clustered, fault-tolerant, memory-based tables", "Clustered, fault-tolerant tables",
DB_TYPE_NDBCLUSTER, DB_TYPE_NDBCLUSTER,
ndbcluster_init, ndbcluster_init,
~(uint)0, /* slot */ ~(uint)0, /* slot */
......
...@@ -3858,13 +3858,37 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, ...@@ -3858,13 +3858,37 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
register_tree_change, actual_table); register_tree_change, actual_table);
} }
if (fld)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
/* Check if there are sufficient access rights to the found field. */ /* Check if there are sufficient access rights to the found field. */
if (fld && check_privileges && if (check_privileges &&
check_column_grant_in_table_ref(thd, *actual_table, name, length)) check_column_grant_in_table_ref(thd, *actual_table, name, length))
fld= WRONG_GRANT; fld= WRONG_GRANT;
else
#endif #endif
if (thd->set_query_id)
{
/*
* get rw_set correct for this field so that the handler
* knows that this field is involved in the query and gets
* retrieved/updated
*/
Field *field_to_set= NULL;
if (fld == view_ref_found)
{
Item *it= (*ref)->real_item();
if (it->type() == Item::FIELD_ITEM)
field_to_set= ((Item_field*)it)->field;
}
else
field_to_set= fld;
if (field_to_set)
field_to_set->table->file->
ha_set_bit_in_rw_set(field_to_set->fieldnr,
(bool)(thd->set_query_id-1));
}
}
DBUG_RETURN(fld); DBUG_RETURN(fld);
} }
...@@ -5044,6 +5068,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, ...@@ -5044,6 +5068,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
DBUG_ENTER("setup_fields"); DBUG_ENTER("setup_fields");
thd->set_query_id=set_query_id; thd->set_query_id=set_query_id;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
if (allow_sum_func) if (allow_sum_func)
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level; thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
thd->where= THD::DEFAULT_WHERE; thd->where= THD::DEFAULT_WHERE;
...@@ -5070,6 +5095,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, ...@@ -5070,6 +5095,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
{ {
thd->lex->allow_sum_func= save_allow_sum_func; thd->lex->allow_sum_func= save_allow_sum_func;
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
DBUG_RETURN(TRUE); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */
} }
if (ref) if (ref)
...@@ -5081,6 +5107,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, ...@@ -5081,6 +5107,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
} }
thd->lex->allow_sum_func= save_allow_sum_func; thd->lex->allow_sum_func= save_allow_sum_func;
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
DBUG_RETURN(test(thd->net.report_error)); DBUG_RETURN(test(thd->net.report_error));
} }
...@@ -5527,6 +5554,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, ...@@ -5527,6 +5554,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
arena= 0; // For easier test arena= 0; // For easier test
thd->set_query_id=1; thd->set_query_id=1;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
select_lex->cond_count= 0; select_lex->cond_count= 0;
for (table= tables; table; table= table->next_local) for (table= tables; table; table= table->next_local)
......
...@@ -1984,6 +1984,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, ...@@ -1984,6 +1984,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table,
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
thd->set_query_id= 0; thd->set_query_id= 0;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
/* /*
Set-up the TABLE_LIST object to be a list with a single table Set-up the TABLE_LIST object to be a list with a single table
Set the object to zero to create NULL pointers and set alias Set the object to zero to create NULL pointers and set alias
...@@ -2120,6 +2121,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, ...@@ -2120,6 +2121,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table,
result= FALSE; result= FALSE;
end: end:
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
DBUG_RETURN(result); DBUG_RETURN(result);
} }
......
...@@ -1338,6 +1338,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) ...@@ -1338,6 +1338,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
*/ */
bool save_set_query_id= thd->set_query_id; bool save_set_query_id= thd->set_query_id;
thd->set_query_id= 0; thd->set_query_id= 0;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
for (Field_translator *fld= trans; fld < end_of_trans; fld++) for (Field_translator *fld= trans; fld < end_of_trans; fld++)
{ {
if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item)) if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item))
...@@ -1347,6 +1348,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) ...@@ -1347,6 +1348,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
} }
} }
thd->set_query_id= save_set_query_id; thd->set_query_id= save_set_query_id;
DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id));
} }
/* Loop over all keys to see if a unique-not-null key is used */ /* Loop over all keys to see if a unique-not-null key is used */
for (;key_info != key_info_end ; key_info++) for (;key_info != key_info_end ; key_info++)
......
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