summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-04-07 16:20:46 +0200
committerunknown <serg@serg.mylan>2004-04-07 16:20:46 +0200
commitb6f2a534fe9cfa4b67afa2ea8ad8c65f043d6302 (patch)
tree8e3d0724200afbcae1e7e7b321b2e166b4f4cd39 /sql/sql_insert.cc
parent0948f9769b3e3da2e064e65015b86644af4acd78 (diff)
parent736853e501181c33e692653d00d7a84c6ff68f25 (diff)
downloadmariadb-git-b6f2a534fe9cfa4b67afa2ea8ad8c65f043d6302.tar.gz
merged
sql/field.cc: Auto merged sql/item.cc: Auto merged sql/protocol.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/table.cc: Auto merged
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc55
1 files changed, 14 insertions, 41 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 241b293262f..c6aff403f5b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -260,17 +260,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->proc_info="update";
if (duplic != DUP_ERROR)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)) &&
- values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT)
- {
- table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
- min(thd->variables.read_buff_size,
- table->avg_row_length*values_list.elements));
- table->file->deactivate_non_unique_index(values_list.elements);
- bulk_insert=1;
- }
- else
- bulk_insert=0;
+ if (lock_type != TL_WRITE_DELAYED)
+ table->file->start_bulk_insert(values_list.elements);
while ((values= its++))
{
@@ -348,24 +339,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
#endif
{
- if (bulk_insert)
+ if (table->file->end_bulk_insert() && !error)
{
- if (table->file->extra(HA_EXTRA_NO_CACHE))
- {
- if (!error)
- {
- table->file->print_error(my_errno,MYF(0));
- error=1;
- }
- }
- if (table->file->activate_all_index(thd))
- {
- if (!error)
- {
- table->file->print_error(my_errno,MYF(0));
- error=1;
- }
- }
+ table->file->print_error(my_errno,MYF(0));
+ error=1;
}
if (id && values_list.elements != 1)
thd->insert_id(id); // For update log
@@ -383,7 +360,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
- if ((info.copied || info.deleted || info.updated) &&
+ if ((info.copied || info.deleted || info.updated) &&
(error <= 0 || !transactional_table))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
@@ -1435,12 +1412,10 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
table->next_number_field=table->found_next_number_field;
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
thd->cuted_fields=0;
- if (info.handle_duplicates != DUP_REPLACE)
- table->file->extra(HA_EXTRA_WRITE_CACHE);
if (info.handle_duplicates == DUP_IGNORE ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- table->file->deactivate_non_unique_index((ha_rows) 0);
+ table->file->start_bulk_insert((ha_rows) 0);
DBUG_RETURN(0);
}
@@ -1449,7 +1424,7 @@ select_insert::~select_insert()
if (table)
{
table->next_number_field=0;
- table->file->extra(HA_EXTRA_RESET);
+ table->file->reset();
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
}
@@ -1493,15 +1468,14 @@ void select_insert::send_error(uint errcode,const char *err)
*/
DBUG_VOID_RETURN;
}
- table->file->extra(HA_EXTRA_NO_CACHE);
- table->file->activate_all_index(thd);
+ table->file->end_bulk_insert();
/*
If at least one row has been inserted/modified and will stay in the table
(the table doesn't have transactions) (example: we got a duplicate key
error while inserting into a MyISAM table) we must write to the binlog (and
the error code will make the slave stop).
*/
- if ((info.copied || info.deleted || info.updated) &&
+ if ((info.copied || info.deleted || info.updated) &&
!table->file->has_transactions())
{
if (last_insert_id)
@@ -1514,7 +1488,7 @@ void select_insert::send_error(uint errcode,const char *err)
mysql_bin_log.write(&qinfo);
}
if (!table->tmp_table)
- thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
+ thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (info.copied || info.deleted || info.updated)
query_cache_invalidate3(thd, table, 1);
@@ -1528,8 +1502,7 @@ bool select_insert::send_eof()
int error,error2;
DBUG_ENTER("select_insert::send_eof");
- if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
- error=table->file->activate_all_index(thd);
+ error=table->file->end_bulk_insert();
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
/*
@@ -1605,7 +1578,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
/* Don't set timestamp if used */
table->timestamp_default_now= table->timestamp_on_update_now= 0;
-
+
table->next_number_field=table->found_next_number_field;
restore_record(table,default_values); // Get empty record
@@ -1614,7 +1587,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_IGNORE ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- table->file->deactivate_non_unique_index((ha_rows) 0);
+ table->file->start_bulk_insert((ha_rows) 0);
DBUG_RETURN(0);
}