mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Added code to flush a bulk_insert index.
This fixes a bug when doing multi-row inserts on table with an auto_increment key that is not in the first key segment. Docs/manual.texi: Changelog include/my_base.h: Added code to flush a bulk_insert index myisam/mi_extra.c: Added code to flush a bulk_insert index mysql-test/r/insert.result: test of auto_increment and bulk_insert mysql-test/t/insert.test: test of auto_increment and bulk_insert sql/ha_myisam.cc: Added code to flush a bulk_insert index sql/sql_insert.cc: Mark that bulk_insert is used sql/sql_load.cc: Mark that bulk_insert is used Remove duplicated call to initialize bulk insert sql/table.h: Mark that bulk_insert is used vio/viosslfactories.c: Remove compiler warning
This commit is contained in:
@ -50442,6 +50442,12 @@ each individual 4.0.x release.
|
||||
|
||||
@itemize @bullet
|
||||
@item
|
||||
Fixed bug when doing a multi-line insert on a table with an
|
||||
auto_increment key which was not in the first part of the key.
|
||||
@item
|
||||
Changed @code{LOAD DATA INFILE} to not recreate index if the table had
|
||||
rows from before.
|
||||
@item
|
||||
Fixed overrun bug when calling @code{AES_DECRYPT()} with wrong arguments
|
||||
@item
|
||||
@code{--skip-ssl} can now be used to disable SSL in the MySQL clients,
|
||||
|
@ -107,6 +107,7 @@ enum ha_extra_function {
|
||||
HA_EXTRA_NO_IGNORE_DUP_KEY,
|
||||
HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE, /* Cursor will not be used for update */
|
||||
HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
HA_EXTRA_BULK_INSERT_FLUSH, /* Flush one index */
|
||||
HA_EXTRA_BULK_INSERT_END,
|
||||
HA_EXTRA_PREPARE_FOR_DELETE
|
||||
};
|
||||
|
@ -34,7 +34,9 @@
|
||||
HA_EXTRA_WRITE_CACHE
|
||||
HA_EXTRA_CACHE
|
||||
HA_EXTRA_BULK_INSERT_BEGIN
|
||||
If extra_arg is 0, then the default cache size is used.
|
||||
If extra_arg is 0, then the default cache size is used.
|
||||
HA_EXTRA_BULK_INSERT_FLUSH
|
||||
extra_arg is a a pointer to which index to flush (uint*)
|
||||
RETURN VALUES
|
||||
0 ok
|
||||
*/
|
||||
@ -356,6 +358,14 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
|
||||
error=_mi_init_bulk_insert(info, (extra_arg ? *(ulong*) extra_arg :
|
||||
myisam_bulk_insert_tree_size));
|
||||
break;
|
||||
case HA_EXTRA_BULK_INSERT_FLUSH:
|
||||
if (info->bulk_insert)
|
||||
{
|
||||
uint index_to_flush= *(uint*) extra_arg;
|
||||
if (is_tree_inited(&info->bulk_insert[index_to_flush]))
|
||||
reset_tree(&info->bulk_insert[index_to_flush]);
|
||||
}
|
||||
break;
|
||||
case HA_EXTRA_BULK_INSERT_END:
|
||||
if (info->bulk_insert)
|
||||
{
|
||||
|
@ -41,6 +41,14 @@ a t>0 c i
|
||||
5 0 a NULL
|
||||
6 1 hello NULL
|
||||
drop table t1;
|
||||
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
sid id
|
||||
skr 1
|
||||
skr 2
|
||||
test 1
|
||||
drop table t1;
|
||||
drop database if exists foo;
|
||||
create database foo;
|
||||
use foo;
|
||||
|
@ -39,6 +39,15 @@ insert into t1 set a=default,t=default,c=default,i=default;
|
||||
select a,t>0,c,i from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test problem with bulk insert and auto_increment on second part keys
|
||||
#
|
||||
|
||||
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test of mysqld crash with fully qualified column names
|
||||
#
|
||||
|
@ -657,7 +657,15 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize)
|
||||
}
|
||||
|
||||
|
||||
/* Deactive all not unique index that can be recreated fast */
|
||||
/*
|
||||
Deactive all not unique index that can be recreated fast
|
||||
|
||||
SYNOPSIS
|
||||
deactivate_non_unique_index()
|
||||
rows Rows to be inserted
|
||||
0 if we don't know
|
||||
HA_POS_ERROR if we want to disable all keys
|
||||
*/
|
||||
|
||||
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||
{
|
||||
@ -670,9 +678,12 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||
mi_extra(file, HA_EXTRA_NO_KEYS, 0);
|
||||
else
|
||||
{
|
||||
mi_disable_non_unique_index(file,rows);
|
||||
/* Only disable old index if the table was empty */
|
||||
if (file->state->records == 0)
|
||||
mi_disable_non_unique_index(file,rows);
|
||||
ha_myisam::extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
current_thd->variables.bulk_insert_buff_size);
|
||||
table->bulk_insert= 1;
|
||||
}
|
||||
}
|
||||
enable_activate_all_index=1;
|
||||
@ -690,6 +701,7 @@ bool ha_myisam::activate_all_index(THD *thd)
|
||||
DBUG_ENTER("activate_all_index");
|
||||
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_END, 0);
|
||||
table->bulk_insert= 0;
|
||||
if (enable_activate_all_index &&
|
||||
share->state.key_map != set_bits(ulonglong, share->base.keys))
|
||||
{
|
||||
@ -1194,6 +1206,10 @@ longlong ha_myisam::get_auto_increment()
|
||||
return auto_increment_value;
|
||||
}
|
||||
|
||||
if (table->bulk_insert)
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_FLUSH,
|
||||
(void*) &table->next_number_index);
|
||||
|
||||
longlong nr;
|
||||
int error;
|
||||
byte key[MI_MAX_KEY_LENGTH];
|
||||
|
@ -202,6 +202,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
|
||||
thd->variables.read_buff_size);
|
||||
table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
thd->variables.bulk_insert_buff_size);
|
||||
table->bulk_insert= 1;
|
||||
}
|
||||
|
||||
while ((values= its++))
|
||||
@ -290,6 +291,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
table->bulk_insert= 0;
|
||||
}
|
||||
if (id && values_list.elements != 1)
|
||||
thd->insert_id(id); // For update log
|
||||
|
@ -248,8 +248,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
table->next_number_field=table->found_next_number_field;
|
||||
VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
|
||||
thd->variables.read_buff_size));
|
||||
VOID(table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
thd->variables.bulk_insert_buff_size));
|
||||
table->bulk_insert= 1;
|
||||
if (handle_duplicates == DUP_IGNORE ||
|
||||
handle_duplicates == DUP_REPLACE)
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
|
@ -91,7 +91,7 @@ struct st_table {
|
||||
my_bool null_row; /* All columns are null */
|
||||
my_bool maybe_null,outer_join; /* Used with OUTER JOIN */
|
||||
my_bool distinct,const_table,no_rows;
|
||||
my_bool key_read;
|
||||
my_bool key_read, bulk_insert;
|
||||
my_bool crypted;
|
||||
my_bool db_low_byte_first; /* Portable row format */
|
||||
my_bool locked_by_flush;
|
||||
|
@ -71,9 +71,11 @@ report_errors()
|
||||
|
||||
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
|
||||
{
|
||||
#ifndef DBUG_OFF /* Avoid warning */
|
||||
char buf[200];
|
||||
DBUG_PRINT("error", ("OpenSSL: %s:%s:%d:%s\n", ERR_error_string(l,buf),
|
||||
file,line,(flags & ERR_TXT_STRING) ? data : "")) ;
|
||||
#endif
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
Reference in New Issue
Block a user