1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Fixed bugs found by pushbuild

Added code to detect and give error when doing an insert into a view where we accessed fields in a not yet read table
Disabled test in subselect.test as the CHECK_OPTION for views doesn't work for insert.
This needs to be fixed properly later.

The problem with views are described in Bug #41760 Inserting into multiple-table views is not working

mysql-test/r/insert.result:
  Fixed wrong usage of insert into view.
mysql-test/r/subselect.result:
  Disabled wrong test (temporary)
mysql-test/suite/maria/r/maria.result:
  Added test of size of table
mysql-test/suite/maria/t/maria.test:
  Added test of size of table
mysql-test/t/insert.test:
  Fixed wrong usage of insert into view
  The bug is that during insert/update we currently don't read any of the referenced tables of the view.
  This means that we can't get a value from another table to use as part of the update.
mysql-test/t/subselect.test:
  Disabled not working test until someone has time to fix insert into view properly
  Here we where refering to last used value in t2, which is wrong.
sql/sql_insert.cc:
  Detect if we are trying to update one table in a view based on value in another, not yet read, table.
  This fixes the problem discovered in insert.test
storage/maria/ma_blockrec.c:
  Don't ignore not critical changes to the last page in the table.
  We need to write the last page as otherwise we can during aborting of a row with a duplicate key get
  state.data_file_length and the real length of file out of sync
storage/maria/ma_check.c:
  Flush the page cache even if we got an error during zerofill.
  (This fixes a call to assert() in case of a too short data file)
storage/maria/ma_pagecache.c:
  Mark page as read when we do a write of a full page.
  This fixes a bug when we got an error during read and then used direct write to page to update it
storage/maria/ma_state.c:
  Restore info->lock.type after call to maria_versioning.
  Fixed crash in maria_recover.test
storage/maria/maria_read_log.c:
  Don't write thread id in debug log. (Not needed as maria_read_log is a single treaded program)
This commit is contained in:
Michael Widenius
2008-12-27 04:05:16 +02:00
parent ee4ddd8e64
commit 910284e6e6
12 changed files with 62 additions and 21 deletions

View File

@@ -107,8 +107,8 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
1 Error
*/
bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
table_map *map)
bool check_view_single_update(List<Item> &fields, List<Item> &values,
TABLE_LIST *view, table_map *map)
{
/* it is join view => we need to find the table for update */
List_iterator_fast<Item> it(fields);
@@ -116,6 +116,10 @@ bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
TABLE_LIST *tbl= 0; // reset for call to check_single_table()
table_map tables= 0;
while ((item= it++))
tables|= item->used_tables();
it.init(values);
while ((item= it++))
tables|= item->used_tables();
@@ -238,7 +242,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
{
if (check_view_single_update(fields, table_list, map))
if (check_view_single_update(fields, values, table_list, map))
return -1;
table= table_list->table;
}
@@ -298,7 +302,8 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
*/
static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
List<Item> &update_fields, table_map *map)
List<Item> &update_fields,
List<Item> &update_values, table_map *map)
{
TABLE *table= insert_table_list->table;
my_bool timestamp_mark;
@@ -320,7 +325,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
return -1;
if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
check_view_single_update(update_fields, insert_table_list, map))
check_view_single_update(update_fields, update_values, insert_table_list,
map))
return -1;
if (table->timestamp_field)
@@ -1246,7 +1252,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if (!res && duplic == DUP_UPDATE)
{
select_lex->no_wrap_view_item= TRUE;
res= check_update_fields(thd, context->table_list, update_fields, &map);
res= check_update_fields(thd, context->table_list, update_fields,
update_values, &map);
select_lex->no_wrap_view_item= FALSE;
}
@@ -2912,7 +2919,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
lex->select_lex.no_wrap_view_item= TRUE;
res= res || check_update_fields(thd, context->table_list,
*info.update_fields, &map);
*info.update_fields, *info.update_values,
&map);
lex->select_lex.no_wrap_view_item= FALSE;
/*
When we are not using GROUP BY and there are no ungrouped aggregate functions
@@ -3580,7 +3588,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
DBUG_RETURN(-1);
}
/* First field to copy */
/* First field to copy */
field= table->field+table->s->fields - values.elements;
/* Mark all fields that are given values */