@@ -264,17 +264,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
264
264
thd->proc_info =" update" ;
265
265
if (duplic != DUP_ERROR)
266
266
table->file ->extra (HA_EXTRA_IGNORE_DUP_KEY);
267
- if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)) &&
268
- values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT)
269
- {
270
- table->file ->extra_opt (HA_EXTRA_WRITE_CACHE,
271
- min (thd->variables .read_buff_size ,
272
- table->avg_row_length *values_list.elements ));
267
+ if (lock_type != TL_WRITE_DELAYED)
273
268
table->file ->start_bulk_insert (values_list.elements );
274
- bulk_insert=1 ;
275
- }
276
- else
277
- bulk_insert=0 ;
278
269
279
270
while ((values= its++))
280
271
{
@@ -352,24 +343,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
352
343
else
353
344
#endif
354
345
{
355
- if (bulk_insert )
346
+ if (table-> file -> end_bulk_insert () && !error )
356
347
{
357
- if (table->file ->extra (HA_EXTRA_NO_CACHE))
358
- {
359
- if (!error)
360
- {
361
- table->file ->print_error (my_errno,MYF (0 ));
362
- error=1 ;
363
- }
364
- }
365
- if (table->file ->end_bulk_insert ())
366
- {
367
- if (!error)
368
- {
369
- table->file ->print_error (my_errno,MYF (0 ));
370
- error=1 ;
371
- }
372
- }
348
+ table->file ->print_error (my_errno,MYF (0 ));
349
+ error=1 ;
373
350
}
374
351
if (id && values_list.elements != 1 )
375
352
thd->insert_id (id); // For update log
@@ -387,7 +364,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
387
364
transactional_table= table->file ->has_transactions ();
388
365
389
366
log_delayed= (transactional_table || table->tmp_table );
390
- if ((info.copied || info.deleted || info.updated ) &&
367
+ if ((info.copied || info.deleted || info.updated ) &&
391
368
(error <= 0 || !transactional_table))
392
369
{
393
370
mysql_update_log.write (thd, thd->query , thd->query_length );
@@ -1439,8 +1416,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
1439
1416
table->next_number_field =table->found_next_number_field ;
1440
1417
thd->count_cuted_fields = CHECK_FIELD_WARN; // calc cuted fields
1441
1418
thd->cuted_fields =0 ;
1442
- if (info.handle_duplicates != DUP_REPLACE)
1443
- table->file ->extra (HA_EXTRA_WRITE_CACHE);
1444
1419
if (info.handle_duplicates == DUP_IGNORE ||
1445
1420
info.handle_duplicates == DUP_REPLACE)
1446
1421
table->file ->extra (HA_EXTRA_IGNORE_DUP_KEY);
@@ -1497,15 +1472,14 @@ void select_insert::send_error(uint errcode,const char *err)
1497
1472
*/
1498
1473
DBUG_VOID_RETURN;
1499
1474
}
1500
- table->file ->extra (HA_EXTRA_NO_CACHE);
1501
1475
table->file ->end_bulk_insert ();
1502
1476
/*
1503
1477
If at least one row has been inserted/modified and will stay in the table
1504
1478
(the table doesn't have transactions) (example: we got a duplicate key
1505
1479
error while inserting into a MyISAM table) we must write to the binlog (and
1506
1480
the error code will make the slave stop).
1507
1481
*/
1508
- if ((info.copied || info.deleted || info.updated ) &&
1482
+ if ((info.copied || info.deleted || info.updated ) &&
1509
1483
!table->file ->has_transactions ())
1510
1484
{
1511
1485
if (last_insert_id)
@@ -1518,7 +1492,7 @@ void select_insert::send_error(uint errcode,const char *err)
1518
1492
mysql_bin_log.write (&qinfo);
1519
1493
}
1520
1494
if (!table->tmp_table )
1521
- thd->options |=OPTION_STATUS_NO_TRANS_UPDATE;
1495
+ thd->options |=OPTION_STATUS_NO_TRANS_UPDATE;
1522
1496
}
1523
1497
if (info.copied || info.deleted || info.updated )
1524
1498
query_cache_invalidate3 (thd, table, 1 );
@@ -1532,8 +1506,7 @@ bool select_insert::send_eof()
1532
1506
int error,error2;
1533
1507
DBUG_ENTER (" select_insert::send_eof" );
1534
1508
1535
- if (!(error=table->file ->extra (HA_EXTRA_NO_CACHE)))
1536
- error=table->file ->end_bulk_insert ();
1509
+ error=table->file ->end_bulk_insert ();
1537
1510
table->file ->extra (HA_EXTRA_NO_IGNORE_DUP_KEY);
1538
1511
1539
1512
/*
@@ -1609,7 +1582,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
1609
1582
1610
1583
/* Don't set timestamp if used */
1611
1584
table->timestamp_default_now = table->timestamp_on_update_now = 0 ;
1612
-
1585
+
1613
1586
table->next_number_field =table->found_next_number_field ;
1614
1587
1615
1588
restore_record (table,default_values); // Get empty record
0 commit comments