summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-11-25 02:23:13 +0200
committerunknown <bell@sanja.is.com.ua>2004-11-25 02:23:13 +0200
commitf88d01932f4a81682267e21022686d3dea4edb78 (patch)
treeb6370530d805ecddad3284428883cac10256f774 /sql/sql_insert.cc
parent5a00a868b74ffb6b220eb72c87ec38696ce9406c (diff)
downloadmariadb-git-f88d01932f4a81682267e21022686d3dea4edb78.tar.gz
post-merge fix
mysql-test/r/view.result: changes in error number, and key in view processing mysql-test/t/view.test: changes in error number, and key in view processing sql/mysql_priv.h: changes functions sql/sp.cc: now we report to setup_tables(), are we setuping SELECT...INSERT sql/sql_base.cc: fixed finding table, taking in account join view, which can have not TABLE pointer now we report to setup_tables(), are we setuping SELECT...INSERT and ennumerete insert table separately sql/sql_delete.cc: now we report to setup_tables(), are we setuping SELECT...INSERT sql/sql_help.cc: now we report to setup_tables(), are we setuping SELECT...INSERT sql/sql_insert.cc: fixed returning value of functions sql/sql_load.cc: now we report to setup_tables(), are we setuping SELECT...INSERT removed second setup_tables call (merge) sql/sql_olap.cc: now we report to setup_tables(), are we setuping SELECT...INSERT sql/sql_parse.cc: UPDATE->MULTIUPDATE switching fixed sql/sql_prepare.cc: UPDATE->MULTIUPDATE switching fixed sql/sql_select.cc: now we report to setup_tables(), are we setuping SELECT...INSERT sql/sql_update.cc: UPDATE->MULTIUPDATE switching fixed sql/sql_view.cc: returning value fixed sql/sql_view.h: returning value fixed
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index dca2a498d7d..673d7425c36 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -612,25 +612,26 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
SYNOPSIS
mysql_prepare_insert_check_table()
thd Thread handle
- table_list Table list (only one table)
+ table_list Table list
fields List of fields to be updated
where Pointer to where clause
+ select_insert Check is making for SELECT ... INSERT
RETURN
- 0 ok
- 1 ERROR and message sent to client
- -1 ERROR but message is not sent to client
+ FALSE ok
+ TRUE ERROR
*/
-static int mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
- List<Item> &fields, COND **where)
+static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
+ List<Item> &fields, COND **where,
+ bool select_insert)
{
bool insert_into_view= (table_list->view != 0);
DBUG_ENTER("mysql_prepare_insert_check_table");
if (setup_tables(thd, table_list, where, &thd->lex->select_lex.leaf_tables,
- 0))
- DBUG_RETURN(thd->net.report_error ? -1 : 1);
+ FALSE, select_insert))
+ DBUG_RETURN(TRUE);
if (insert_into_view && !fields.elements)
{
@@ -641,12 +642,12 @@ static int mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
table_list->ancestor && table_list->ancestor->next_local);
my_error(ER_VIEW_NO_INSERT_FIELD_LIST, MYF(0),
table_list->view_db.str, table_list->view_name.str);
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
DBUG_RETURN(insert_view_fields(&fields, table_list));
}
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -674,9 +675,12 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
bool res;
DBUG_ENTER("mysql_prepare_insert");
- if ((res= mysql_prepare_insert_check_table(thd, table_list,
- fields, &unused_conds)))
- DBUG_RETURN(res);
+ DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
+ (ulong)table_list, (ulong)table,
+ (int)insert_into_view));
+ if (mysql_prepare_insert_check_table(thd, table_list, fields, &unused_conds,
+ FALSE))
+ DBUG_RETURN(TRUE);
if (check_insert_fields(thd, table_list, fields, *values, 1,
!insert_into_view) ||
@@ -689,6 +693,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
setup_fields(thd, 0, table_list, update_values, 1, 0, 0))))
DBUG_RETURN(TRUE);
+ if (!table)
+ table= table_list->table;
+
if (unique_table(table_list, table_list->next_global))
{
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name);
@@ -1716,8 +1723,9 @@ bool mysql_insert_select_prepare(THD *thd)
lex->query_tables->no_where_clause= 1;
if (mysql_prepare_insert_check_table(thd, lex->query_tables,
lex->field_list,
- &lex->select_lex.where))
- DBUG_RETURN(FALSE);
+ &lex->select_lex.where,
+ TRUE))
+ DBUG_RETURN(TRUE);
/*
setup was done in mysql_insert_select_prepare, but we have to mark
first local table