Commit e01f6c89 authored by Sergei Golubchik's avatar Sergei Golubchik

merged

parents bdd170c5 7dc83c50
...@@ -251,8 +251,12 @@ HEX(a) ...@@ -251,8 +251,12 @@ HEX(a)
1 1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT DELAYED INTO t1 SET b= b(); INSERT DELAYED INTO t1 SET a= b();
ERROR 42000: FUNCTION test.b does not exist
INSERT DELAYED INTO t1 SET b= 1;
ERROR 42S22: Unknown column 'b' in 'field list' ERROR 42S22: Unknown column 'b' in 'field list'
INSERT DELAYED INTO t1 SET b= b();
ERROR 42000: FUNCTION test.b does not exist
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2;
......
...@@ -2568,7 +2568,9 @@ create table t2 (f3 int, f4 int) engine=maria; ...@@ -2568,7 +2568,9 @@ create table t2 (f3 int, f4 int) engine=maria;
create view v1 as select * from t1, t2 where f1= f3; create view v1 as select * from t1, t2 where f1= f3;
insert into t1 values (1,11), (2,22); insert into t1 values (1,11), (2,22);
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
drop table t1,t2; drop table t1,t2;
drop view v1; drop view v1;
CREATE TABLE t1 (id int, c varchar(10)) engine=maria; CREATE TABLE t1 (id int, c varchar(10)) engine=maria;
......
...@@ -1820,7 +1820,9 @@ create table t1 (f1 int unique, f2 int) engine=maria; ...@@ -1820,7 +1820,9 @@ create table t1 (f1 int unique, f2 int) engine=maria;
create table t2 (f3 int, f4 int) engine=maria; create table t2 (f3 int, f4 int) engine=maria;
create view v1 as select * from t1, t2 where f1= f3; create view v1 as select * from t1, t2 where f1= f3;
insert into t1 values (1,11), (2,22); insert into t1 values (1,11), (2,22);
--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
drop table t1,t2; drop table t1,t2;
drop view v1; drop view v1;
......
...@@ -256,7 +256,11 @@ DROP TABLE t1; ...@@ -256,7 +256,11 @@ DROP TABLE t1;
# Bug #32676: insert delayed crash with wrong column and function specified # Bug #32676: insert delayed crash with wrong column and function specified
# #
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
--error ER_SP_DOES_NOT_EXIST
INSERT DELAYED INTO t1 SET a= b();
--error ER_BAD_FIELD_ERROR --error ER_BAD_FIELD_ERROR
INSERT DELAYED INTO t1 SET b= 1;
--error ER_SP_DOES_NOT_EXIST
INSERT DELAYED INTO t1 SET b= b(); INSERT DELAYED INTO t1 SET b= b();
DROP TABLE t1; DROP TABLE t1;
......
...@@ -7342,6 +7342,9 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, ...@@ -7342,6 +7342,9 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
/* make * substituting permanent */ /* make * substituting permanent */
SELECT_LEX *select_lex= thd->lex->current_select; SELECT_LEX *select_lex= thd->lex->current_select;
select_lex->with_wild= 0; select_lex->with_wild= 0;
#ifdef HAVE_purify
if (&select_lex->item_list != &fields) // Avoid warning
#endif
select_lex->item_list= fields; select_lex->item_list= fields;
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);
......
...@@ -88,6 +88,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view); ...@@ -88,6 +88,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
SYNOPSIS SYNOPSIS
check_view_single_update() check_view_single_update()
fields The insert/update fields to be checked. fields The insert/update fields to be checked.
values Values to use for update
view The view for insert. view The view for insert.
map [in/out] The insert table map. map [in/out] The insert table map.
...@@ -107,7 +108,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view); ...@@ -107,7 +108,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
1 Error 1 Error
*/ */
bool check_view_single_update(List<Item> &fields, List<Item> &values, bool check_view_single_update(List<Item> &fields, List<Item> *values,
TABLE_LIST *view, table_map *map) TABLE_LIST *view, table_map *map)
{ {
/* it is join view => we need to find the table for update */ /* it is join view => we need to find the table for update */
...@@ -119,10 +120,15 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values, ...@@ -119,10 +120,15 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values,
while ((item= it++)) while ((item= it++))
tables|= item->used_tables(); tables|= item->used_tables();
it.init(values); if (values)
{
it.init(*values);
while ((item= it++)) while ((item= it++))
tables|= item->used_tables(); tables|= item->used_tables();
}
/* Convert to real table bits */
tables&= ~PSEUDO_TABLE_BITS;
/* Check found map against provided map */ /* Check found map against provided map */
if (*map) if (*map)
{ {
...@@ -156,6 +162,10 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values, ...@@ -156,6 +162,10 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values,
fields The insert fields. fields The insert fields.
values The insert values. values The insert values.
check_unique If duplicate values should be rejected. check_unique If duplicate values should be rejected.
fields_and_values_from_different_maps
Set to 1 if fields and values are using
different table maps, like on select ... insert
map Store here table map for used fields
NOTE NOTE
Clears TIMESTAMP_AUTO_SET_ON_INSERT from table->timestamp_field_type Clears TIMESTAMP_AUTO_SET_ON_INSERT from table->timestamp_field_type
...@@ -169,7 +179,9 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values, ...@@ -169,7 +179,9 @@ bool check_view_single_update(List<Item> &fields, List<Item> &values,
static int check_insert_fields(THD *thd, TABLE_LIST *table_list, static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
List<Item> &fields, List<Item> &values, List<Item> &fields, List<Item> &values,
bool check_unique, table_map *map) bool check_unique,
bool fields_and_values_from_different_maps,
table_map *map)
{ {
TABLE *table= table_list->table; TABLE *table= table_list->table;
...@@ -242,7 +254,10 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, ...@@ -242,7 +254,10 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE) if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
{ {
if (check_view_single_update(fields, values, table_list, map)) if (check_view_single_update(fields,
fields_and_values_from_different_maps ?
(List<Item>*) 0 : &values,
table_list, map))
return -1; return -1;
table= table_list->table; table= table_list->table;
} }
...@@ -325,8 +340,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, ...@@ -325,8 +340,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
return -1; return -1;
if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE && if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
check_view_single_update(update_fields, update_values, insert_table_list, check_view_single_update(update_fields, &update_values,
map)) insert_table_list, map))
return -1; return -1;
if (table->timestamp_field) if (table->timestamp_field)
...@@ -1234,9 +1249,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, ...@@ -1234,9 +1249,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
table_list->next_local= 0; table_list->next_local= 0;
context->resolve_in_table_list_only(table_list); context->resolve_in_table_list_only(table_list);
res= check_insert_fields(thd, context->table_list, fields, *values, res= (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0) ||
!insert_into_view, &map) || check_insert_fields(thd, context->table_list, fields, *values,
setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0); !insert_into_view, 0, &map));
if (!res && check_fields) if (!res && check_fields)
{ {
...@@ -1249,6 +1264,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, ...@@ -1249,6 +1264,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
thd->abort_on_warning= saved_abort_on_warning; thd->abort_on_warning= saved_abort_on_warning;
} }
if (!res)
res= setup_fields(thd, 0, update_values, MARK_COLUMNS_READ, 0, 0);
if (!res && duplic == DUP_UPDATE) if (!res && duplic == DUP_UPDATE)
{ {
select_lex->no_wrap_view_item= TRUE; select_lex->no_wrap_view_item= TRUE;
...@@ -1259,9 +1277,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, ...@@ -1259,9 +1277,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
/* Restore the current context. */ /* Restore the current context. */
ctx_state.restore_state(context, table_list); ctx_state.restore_state(context, table_list);
if (!res)
res= setup_fields(thd, 0, update_values, MARK_COLUMNS_READ, 0, 0);
} }
if (res) if (res)
...@@ -2890,10 +2905,9 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) ...@@ -2890,10 +2905,9 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
we are fixing fields from insert list. we are fixing fields from insert list.
*/ */
lex->current_select= &lex->select_lex; lex->current_select= &lex->select_lex;
res= check_insert_fields(thd, table_list, *fields, values, res= (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0) ||
!insert_into_view, &map) || check_insert_fields(thd, table_list, *fields, values,
setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0); !insert_into_view, 1, &map));
if (!res && fields->elements) if (!res && fields->elements)
{ {
bool saved_abort_on_warning= thd->abort_on_warning; bool saved_abort_on_warning= thd->abort_on_warning;
......
...@@ -2422,7 +2422,8 @@ static my_bool free_full_page_range(MARIA_HA *info, pgcache_page_no_t page, ...@@ -2422,7 +2422,8 @@ static my_bool free_full_page_range(MARIA_HA *info, pgcache_page_no_t page,
*/ */
delete_count--; delete_count--;
} }
if (pagecache_delete_pages(share->pagecache, &info->dfile, if (delete_count &&
pagecache_delete_pages(share->pagecache, &info->dfile,
page, delete_count, PAGECACHE_LOCK_WRITE, 0)) page, delete_count, PAGECACHE_LOCK_WRITE, 0))
res= 1; res= 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