summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2004-12-31 12:05:43 +0200
committermonty@mysql.com <>2004-12-31 12:05:43 +0200
commit78da7196ad70f922a8209b969fef91f90cb448e2 (patch)
treeaa9ad4f333f053e73bd7d0f82cc1a3677636ed4a /sql/sql_insert.cc
parentf455778fc12bdb8e940ab0add095946864f96801 (diff)
parent1bd22faa05c03dfb19916a92266fb5b45768d3f6 (diff)
downloadmariadb-git-78da7196ad70f922a8209b969fef91f90cb448e2.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 622176e22cc..92c429bcfde 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -22,7 +22,7 @@
static int check_null_fields(THD *thd,TABLE *entry);
#ifndef EMBEDDED_LIBRARY
static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list);
-static int write_delayed(THD *thd,TABLE *table, enum_duplicates dup,
+static int write_delayed(THD *thd,TABLE *table, enum_duplicates dup, bool ignore,
char *query, uint query_length, int log_on);
static void end_delayed_insert(THD *thd);
extern "C" pthread_handler_decl(handle_delayed_insert,arg);
@@ -111,7 +111,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
List<List_item> &values_list,
List<Item> &update_fields,
List<Item> &update_values,
- enum_duplicates duplic)
+ enum_duplicates duplic,
+ bool ignore)
{
int error, res;
/*
@@ -222,9 +223,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
*/
info.records= info.deleted= info.copied= info.updated= 0;
+ info.ignore= ignore;
info.handle_duplicates=duplic;
- info.update_fields=&update_fields;
- info.update_values=&update_values;
+ info.update_fields= &update_fields;
+ info.update_values= &update_values;
/*
Count warnings for all inserts.
For single line insert, generate an error if try to set a NOT NULL field
@@ -289,7 +291,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
#ifndef EMBEDDED_LIBRARY
if (lock_type == TL_WRITE_DELAYED)
{
- error=write_delayed(thd,table,duplic,query, thd->query_length, log_on);
+ error=write_delayed(thd, table, duplic, ignore, query, thd->query_length, log_on);
query=0;
}
else
@@ -395,7 +397,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
{
char buff[160];
- if (duplic == DUP_IGNORE)
+ if (ignore)
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(lock_type == TL_WRITE_DELAYED) ? (ulong) 0 :
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
@@ -591,7 +593,7 @@ int write_record(TABLE *table,COPY_INFO *info)
}
else if ((error=table->file->write_row(table->record[0])))
{
- if (info->handle_duplicates != DUP_IGNORE ||
+ if (!info->ignore ||
(error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE))
goto err;
}
@@ -647,14 +649,14 @@ public:
char *record,*query;
enum_duplicates dup;
time_t start_time;
- bool query_start_used,last_insert_id_used,insert_id_used;
+ bool query_start_used,last_insert_id_used,insert_id_used, ignore;
int log_query;
ulonglong last_insert_id;
timestamp_auto_set_type timestamp_field_type;
uint query_length;
- delayed_row(enum_duplicates dup_arg, int log_query_arg)
- :record(0),query(0),dup(dup_arg),log_query(log_query_arg) {}
+ delayed_row(enum_duplicates dup_arg, bool ignore_arg, int log_query_arg)
+ :record(0),query(0),dup(dup_arg),ignore(ignore_arg),log_query(log_query_arg) {}
~delayed_row()
{
x_free(record);
@@ -966,7 +968,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd)
/* Put a question in queue */
-static int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic,
+static int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool ignore,
char *query, uint query_length, int log_on)
{
delayed_row *row=0;
@@ -979,7 +981,7 @@ static int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic,
pthread_cond_wait(&di->cond_client,&di->mutex);
thd->proc_info="storing row into queue";
- if (thd->killed || !(row= new delayed_row(duplic, log_on)))
+ if (thd->killed || !(row= new delayed_row(duplic, ignore, log_on)))
goto err;
if (!query)
@@ -1340,8 +1342,9 @@ bool delayed_insert::handle_inserts(void)
thd.insert_id_used=row->insert_id_used;
table->timestamp_field_type= row->timestamp_field_type;
+ info.ignore= row->ignore;
info.handle_duplicates= row->dup;
- if (info.handle_duplicates == DUP_IGNORE ||
+ if (info.ignore ||
info.handle_duplicates == DUP_REPLACE)
{
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
@@ -1459,7 +1462,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
restore_record(table,default_values); // Get empty record
table->next_number_field=table->found_next_number_field;
thd->cuted_fields=0;
- if (info.handle_duplicates == DUP_IGNORE ||
+ if (info.ignore ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
table->file->start_bulk_insert((ha_rows) 0);
@@ -1601,7 +1604,7 @@ bool select_insert::send_eof()
DBUG_RETURN(1);
}
char buff[160];
- if (info.handle_duplicates == DUP_IGNORE)
+ if (info.ignore)
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
(ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
else
@@ -1645,7 +1648,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
restore_record(table,default_values); // Get empty record
thd->cuted_fields=0;
- if (info.handle_duplicates == DUP_IGNORE ||
+ if (info.ignore ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
table->file->start_bulk_insert((ha_rows) 0);