Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-03-02 00:09:22+03:00, evgen@stripped +7 -0
Bug#25122: Views based on a self-joined table aren't insertable.
When INSERT is done over a view the table being inserted into is
checked to be unique among all views tables. But if the view contains
self-joined table an error will be thrown even if all tables are used under
different aliases.
The unique_table() function now also checks tables' aliases when needed.
sql/mysql_priv.h@stripped, 2007-03-02 00:09:02+03:00, evgen@stripped +2 -1
Bug#25122: Views based on a self-joined table aren't insertable.
Updated prototype of the unique_table() function.
sql/sql_base.cc@stripped, 2007-03-02 00:09:04+03:00, evgen@stripped +7 -2
Bug#25122: Views based on a self-joined table aren't insertable.
Now the unique_table() function checks tables' aliases when needed.
sql/sql_delete.cc@stripped, 2007-03-02 00:09:05+03:00, evgen@stripped +2 -2
Bug#25122: Views based on a self-joined table aren't insertable.
Updated calls to the unique_table() function.
sql/sql_insert.cc@stripped, 2007-03-02 00:09:05+03:00, evgen@stripped +2 -2
Bug#25122: Views based on a self-joined table aren't insertable.
Updated calls to the unique_table() function.
sql/sql_load.cc@stripped, 2007-03-02 00:09:06+03:00, evgen@stripped +1 -1
Bug#25122: Views based on a self-joined table aren't insertable.
Updated calls to the unique_table() function.
sql/sql_parse.cc@stripped, 2007-03-02 00:09:06+03:00, evgen@stripped +2 -2
Bug#25122: Views based on a self-joined table aren't insertable.
Updated calls to the unique_table() function.
sql/sql_update.cc@stripped, 2007-03-02 00:09:07+03:00, evgen@stripped +3 -3
Bug#25122: Views based on a self-joined table aren't insertable.
Updated calls to the unique_table() function.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/25122-bug-5.0-opt-mysql
--- 1.435/sql/mysql_priv.h 2007-02-14 01:25:06 +03:00
+++ 1.436/sql/mysql_priv.h 2007-03-02 00:09:02 +03:00
@@ -1064,7 +1064,8 @@
st_table_list *TABLE_LIST::*link,
const char *db_name,
const char *table_name);
-TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list);
+TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
+ bool check_alias);
TABLE **find_temporary_table(THD *thd, const char *db, const char *table_name);
bool close_temporary_table(THD *thd, const char *db, const char *table_name);
void close_temporary(TABLE *table, bool delete_table);
--- 1.366/sql/sql_base.cc 2007-02-19 15:47:11 +03:00
+++ 1.367/sql/sql_base.cc 2007-03-02 00:09:04 +03:00
@@ -796,6 +796,7 @@
thd thread handle
table table which should be checked
table_list list of tables
+ check_alias whether to check tables' aliases
NOTE: to exclude derived tables from check we use following mechanism:
a) during derived table processing set THD::derived_tables_processing
@@ -823,10 +824,11 @@
0 if table is unique
*/
-TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list)
+TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
+ bool check_alias)
{
TABLE_LIST *res;
- const char *d_name, *t_name;
+ const char *d_name, *t_name, *t_alias;
DBUG_ENTER("unique_table");
DBUG_PRINT("enter", ("table alias: %s", table->alias));
@@ -854,6 +856,7 @@
}
d_name= table->db;
t_name= table->table_name;
+ t_alias= table->alias;
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
for (;;)
@@ -861,6 +864,8 @@
if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) &&
(! (res= mysql_lock_have_duplicate(thd, table, table_list)))) ||
((!res->table || res->table != table->table) &&
+ (!check_alias || !(lower_case_table_names ?
+ strcasecmp(t_alias, res->alias) : strcmp(t_alias, res->alias)))
&&
res->select_lex &&
!res->select_lex->exclude_from_table_unique_test &&
!res->prelocking_placeholder))
break;
--- 1.191/sql/sql_delete.cc 2007-02-01 11:54:43 +03:00
+++ 1.192/sql/sql_delete.cc 2007-03-02 00:09:05 +03:00
@@ -370,7 +370,7 @@
}
{
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, table_list, table_list->next_global)))
+ if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
update_non_unique_table_error(table_list, "DELETE", duplicate);
DBUG_RETURN(TRUE);
@@ -462,7 +462,7 @@
{
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, target_tbl->correspondent_table,
- lex->query_tables)))
+ lex->query_tables, 0)))
{
update_non_unique_table_error(target_tbl->correspondent_table,
"DELETE", duplicate);
--- 1.218/sql/sql_insert.cc 2007-02-19 15:47:12 +03:00
+++ 1.219/sql/sql_insert.cc 2007-03-02 00:09:05 +03:00
@@ -1044,7 +1044,7 @@
{
Item *fake_conds= 0;
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, table_list, table_list->next_global)))
+ if ((duplicate= unique_table(thd, table_list, table_list->next_global, 1)))
{
update_non_unique_table_error(table_list, "INSERT", duplicate);
DBUG_RETURN(TRUE);
@@ -2424,7 +2424,7 @@
query
*/
if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
- unique_table(thd, table_list, table_list->next_global))
+ unique_table(thd, table_list, table_list->next_global, 0))
{
/* Using same table for INSERT and SELECT */
lex->current_select->options|= OPTION_BUFFER_RESULT;
--- 1.104/sql/sql_load.cc 2006-12-30 23:02:07 +03:00
+++ 1.105/sql/sql_load.cc 2007-03-02 00:09:06 +03:00
@@ -175,7 +175,7 @@
table is marked to be 'used for insert' in which case we should never
mark this table as as 'const table' (ie, one that has only one row).
*/
- if (unique_table(thd, table_list, table_list->next_global))
+ if (unique_table(thd, table_list, table_list->next_global, 0))
{
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
DBUG_RETURN(TRUE);
--- 1.604/sql/sql_parse.cc 2007-02-06 17:50:35 +03:00
+++ 1.605/sql/sql_parse.cc 2007-03-02 00:09:06 +03:00
@@ -2993,7 +2993,7 @@
if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE))
{
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, create_table, select_tables)))
+ if ((duplicate= unique_table(thd, create_table, select_tables, 0)))
{
update_non_unique_table_error(create_table, "CREATE", duplicate);
res= 1;
@@ -3009,7 +3009,7 @@
tab= tab->next_local)
{
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, tab, select_tables)))
+ if ((duplicate= unique_table(thd, tab, select_tables, 0)))
{
update_non_unique_table_error(tab, "CREATE", duplicate);
res= 1;
--- 1.212/sql/sql_update.cc 2007-02-08 01:41:54 +03:00
+++ 1.213/sql/sql_update.cc 2007-03-02 00:09:07 +03:00
@@ -636,7 +636,7 @@
/* Check that we are not using table that we are updating in a sub select */
{
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, table_list, table_list->next_global)))
+ if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
update_non_unique_table_error(table_list, "UPDATE", duplicate);
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
@@ -863,7 +863,7 @@
tl->lock_type != TL_READ_NO_INSERT)
{
TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, tl, table_list)))
+ if ((duplicate= unique_table(thd, tl, table_list, 0)))
{
update_non_unique_table_error(table_list, "UPDATE", duplicate);
DBUG_RETURN(TRUE);
@@ -1082,7 +1082,7 @@
List<Item> *fields)
{
TABLE *table= join_tab->table;
- if (unique_table(thd, table_ref, all_tables))
+ if (unique_table(thd, table_ref, all_tables, 0))
return 0;
switch (join_tab->type) {
case JT_SYSTEM:
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2419) BUG#25122 | eugene | 2 Mar |