summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorvenu@myvenu.com <>2003-05-21 00:12:09 -0700
committervenu@myvenu.com <>2003-05-21 00:12:09 -0700
commit39cbb547d433f7fdcfbe5655f14ffb8c93fe6122 (patch)
tree390fab0240f652c5c3ddbf153549ac34cb5c1b2b /sql/sql_insert.cc
parent9ad75823e7406c3afec09e642615e4821d25df5a (diff)
parent666d46b6ee19c0399fadff220952a9ac9a097f85 (diff)
downloadmariadb-git-39cbb547d433f7fdcfbe5655f14ffb8c93fe6122.tar.gz
Resolve merge colflict
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 05abc25143b..a3e11d9d1c6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -184,6 +184,15 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->proc_info="init";
thd->used_tables=0;
values= its++;
+
+ if (duplic == DUP_UPDATE && !table->insert_values)
+ {
+ /* it should be allocated before Item::fix_fields() */
+ table->insert_values=alloc_root(&table->mem_root, table->rec_buff_length);
+ if (!table->insert_values)
+ goto abort;
+ }
+
if (check_insert_fields(thd,table,fields,*values,1) ||
setup_tables(insert_table_list) ||
setup_fields(thd, 0, insert_table_list, *values, 0, 0, 0) ||
@@ -248,7 +257,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
{
if (fields.elements || !value_count)
{
- restore_record(table,2); // Get empty record
+ restore_record(table,default_values); // Get empty record
if (fill_record(fields,*values)|| thd->net.report_error ||
check_null_fields(thd,table))
{
@@ -264,9 +273,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
{
if (thd->used_tables) // Column used in values()
- restore_record(table,2); // Get empty record
+ restore_record(table,default_values); // Get empty record
else
- table->record[0][0]=table->record[2][0]; // Fix delete marker
+ table->record[0][0]=table->default_values[0]; // Fix delete marker
if (fill_record(table->field,*values) || thd->net.report_error)
{
if (values_list.elements != 1 && ! thd->net.report_error)
@@ -334,7 +343,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->insert_id(id); // For update log
else if (table->next_number_field)
id=table->next_number_field->val_int(); // Return auto_increment value
-
+
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
@@ -384,7 +393,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
char buff[160];
if (duplic == DUP_IGNORE)
sprintf(buff,ER(ER_INSERT_INFO),info.records,
- (lock_type == TL_WRITE_DELAYED) ? 0 :
+ (lock_type == TL_WRITE_DELAYED) ? 0 :
info.records-info.copied,
thd->cuted_fields);
else
@@ -393,12 +402,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
::send_ok(thd,info.copied+info.deleted,(ulonglong)id,buff);
}
free_underlaid_joins(thd, &thd->lex.select_lex);
+ table->insert_values=0;
DBUG_RETURN(0);
abort:
if (lock_type == TL_WRITE_DELAYED)
end_delayed_insert(thd);
free_underlaid_joins(thd, &thd->lex.select_lex);
+ table->insert_values=0;
DBUG_RETURN(-1);
}
@@ -483,7 +494,8 @@ int write_record(TABLE *table,COPY_INFO *info)
that matches, is updated. If update causes a conflict again,
an error is returned
*/
- restore_record(table,1);
+ store_record(table,insert_values);
+ restore_record(table,record[1]);
if (fill_record(*info->update_fields,*info->update_values))
goto err;
if ((error=table->file->update_row(table->record[1],table->record[0])))
@@ -1350,7 +1362,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (check_insert_fields(thd,table,*fields,values,1))
DBUG_RETURN(1);
- restore_record(table,2); // Get empty record
+ restore_record(table,default_values); // Get empty record
table->next_number_field=table->found_next_number_field;
thd->count_cuted_fields=1; // calc cuted fields
thd->cuted_fields=0;
@@ -1481,7 +1493,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
}
table->next_number_field=table->found_next_number_field;
- restore_record(table,2); // Get empty record
+ restore_record(table,default_values); // Get empty record
thd->count_cuted_fields=1; // count warnings
thd->cuted_fields=0;
if (info.handle_duplicates == DUP_IGNORE ||