1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
This commit is contained in:
serg@serg.mylan
2004-04-07 16:20:46 +02:00
43 changed files with 242 additions and 248 deletions

View File

@ -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);
}