mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Don't enable HA_EXTRA_WRITE_CACHE if too few rows
Revert main parts of patch for online index builds. Should be done differently Added support for %lx in my_snprintf()
This commit is contained in:
@ -867,7 +867,9 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
|
|||||||
THD *thd=current_thd;
|
THD *thd=current_thd;
|
||||||
ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
|
ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
|
||||||
|
|
||||||
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*)&size);
|
/* don't enable row cache if too few rows */
|
||||||
|
if (!rows && rows > 10)
|
||||||
|
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size);
|
||||||
|
|
||||||
can_enable_indexes= (file->s->state.key_map ==
|
can_enable_indexes= (file->s->state.key_map ==
|
||||||
set_bits(ulonglong, file->s->base.keys));
|
set_bits(ulonglong, file->s->base.keys));
|
||||||
|
@ -92,10 +92,10 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bits in index_ddl_flags(KEY *wanted_index)
|
Bits in index_ddl_flags(KEY *wanted_index)
|
||||||
for what ddl you can do with index
|
for what ddl you can do with index
|
||||||
If none is set, the wanted type of index is not supported
|
If none is set, the wanted type of index is not supported
|
||||||
by the handler at all. See WorkLog 1563.
|
by the handler at all. See WorkLog 1563.
|
||||||
*/
|
*/
|
||||||
#define HA_DDL_SUPPORT 1 /* Supported by handler */
|
#define HA_DDL_SUPPORT 1 /* Supported by handler */
|
||||||
#define HA_DDL_WITH_LOCK 2 /* Can create/drop with locked table */
|
#define HA_DDL_WITH_LOCK 2 /* Can create/drop with locked table */
|
||||||
|
@ -509,23 +509,11 @@ int mysql_alter_table(THD *thd, char *new_db, char *new_name,
|
|||||||
List<create_field> &fields,
|
List<create_field> &fields,
|
||||||
List<Key> &keys,List<Alter_drop> &drop_list,
|
List<Key> &keys,List<Alter_drop> &drop_list,
|
||||||
List<Alter_column> &alter_list,
|
List<Alter_column> &alter_list,
|
||||||
uint order_num, ORDER *order, int alter_flags,
|
uint order_num, ORDER *order, uint alter_flags,
|
||||||
enum enum_duplicates handle_duplicates,
|
enum enum_duplicates handle_duplicates,
|
||||||
enum enum_enable_or_disable keys_onoff=LEAVE_AS_IS,
|
enum enum_enable_or_disable keys_onoff=LEAVE_AS_IS,
|
||||||
enum tablespace_op_type tablespace_op=NO_TABLESPACE_OP,
|
enum tablespace_op_type tablespace_op=NO_TABLESPACE_OP,
|
||||||
bool simple_alter=0);
|
bool simple_alter=0);
|
||||||
int real_alter_table(THD *thd, char *new_db, char *new_name,
|
|
||||||
HA_CREATE_INFO *create_info,
|
|
||||||
TABLE_LIST *table_list,
|
|
||||||
TABLE *table,
|
|
||||||
List<create_field> &fields,
|
|
||||||
List<Key> &keys,List<Alter_drop> &drop_list,
|
|
||||||
List<Alter_column> &alter_list,
|
|
||||||
uint order_num, ORDER *order, int alter_flags,
|
|
||||||
enum enum_duplicates handle_duplicates,
|
|
||||||
enum enum_enable_or_disable keys_onoff=LEAVE_AS_IS,
|
|
||||||
enum tablespace_op_type tablespace_op=NO_TABLESPACE_OP,
|
|
||||||
bool simple_alter=0);
|
|
||||||
int mysql_create_like_table(THD *thd, TABLE_LIST *table,
|
int mysql_create_like_table(THD *thd, TABLE_LIST *table,
|
||||||
HA_CREATE_INFO *create_info,
|
HA_CREATE_INFO *create_info,
|
||||||
Table_ident *src_table);
|
Table_ident *src_table);
|
||||||
@ -537,10 +525,6 @@ bool mysql_rename_table(enum db_type base,
|
|||||||
int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys);
|
int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys);
|
||||||
int mysql_drop_index(THD *thd, TABLE_LIST *table_list,
|
int mysql_drop_index(THD *thd, TABLE_LIST *table_list,
|
||||||
List<Alter_drop> &drop_list);
|
List<Alter_drop> &drop_list);
|
||||||
int mysql_add_column(THD *thd, TABLE_LIST *table_list,
|
|
||||||
List<create_field> &fields);
|
|
||||||
int mysql_drop_column(THD *thd, TABLE_LIST *table_list,
|
|
||||||
List<Alter_drop> &drop_list);
|
|
||||||
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
|
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
|
||||||
List<Item> &values,COND *conds,
|
List<Item> &values,COND *conds,
|
||||||
uint order_num, ORDER *order, ha_rows limit,
|
uint order_num, ORDER *order, ha_rows limit,
|
||||||
@ -944,9 +928,10 @@ void unlock_table_names(THD *thd, TABLE_LIST *table_list,
|
|||||||
|
|
||||||
void unireg_init(ulong options);
|
void unireg_init(ulong options);
|
||||||
void unireg_end(void);
|
void unireg_end(void);
|
||||||
int mysql_create_frm(THD *thd, my_string file_name,HA_CREATE_INFO *create_info,
|
bool mysql_create_frm(THD *thd, my_string file_name,
|
||||||
List<create_field> &create_field,
|
HA_CREATE_INFO *create_info,
|
||||||
uint key_count,KEY *key_info,handler *db_type);
|
List<create_field> &create_field,
|
||||||
|
uint key_count,KEY *key_info,handler *db_type);
|
||||||
int rea_create_table(THD *thd, my_string file_name,HA_CREATE_INFO *create_info,
|
int rea_create_table(THD *thd, my_string file_name,HA_CREATE_INFO *create_info,
|
||||||
List<create_field> &create_field,
|
List<create_field> &create_field,
|
||||||
uint key_count,KEY *key_info);
|
uint key_count,KEY *key_info);
|
||||||
|
@ -86,8 +86,7 @@ extern "C" void free_user_var(user_var_entry *entry)
|
|||||||
THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
|
THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
|
||||||
last_insert_id_used(0),
|
last_insert_id_used(0),
|
||||||
insert_id_used(0), rand_used(0), in_lock_tables(0),
|
insert_id_used(0), rand_used(0), in_lock_tables(0),
|
||||||
global_read_lock(0), bootstrap(0),
|
global_read_lock(0), bootstrap(0)
|
||||||
no_table_fix_fields_cache(0)
|
|
||||||
{
|
{
|
||||||
host= user= priv_user= db= ip=0;
|
host= user= priv_user= db= ip=0;
|
||||||
host_or_ip= "connecting host";
|
host_or_ip= "connecting host";
|
||||||
|
@ -260,7 +260,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
|||||||
thd->proc_info="update";
|
thd->proc_info="update";
|
||||||
if (duplic != DUP_ERROR)
|
if (duplic != DUP_ERROR)
|
||||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||||
if (lock_type != TL_WRITE_DELAYED)
|
if (lock_type != TL_WRITE_DELAYED && values_list.elements != 1);
|
||||||
table->file->start_bulk_insert(values_list.elements);
|
table->file->start_bulk_insert(values_list.elements);
|
||||||
|
|
||||||
while ((values= its++))
|
while ((values= its++))
|
||||||
|
@ -4993,3 +4993,49 @@ Item * all_any_subquery_creator(Item *left_expr,
|
|||||||
|
|
||||||
return it; /* ANY/SOME */
|
return it; /* ANY/SOME */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE INDEX and DROP INDEX are implemented by calling ALTER TABLE with
|
||||||
|
the proper arguments. This isn't very fast but it should work for most
|
||||||
|
cases.
|
||||||
|
|
||||||
|
In the future ALTER TABLE will notice that only added indexes
|
||||||
|
and create these one by one for the existing table without having to do
|
||||||
|
a full rebuild.
|
||||||
|
|
||||||
|
One should normally create all indexes with CREATE TABLE or ALTER TABLE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
|
||||||
|
{
|
||||||
|
List<create_field> fields;
|
||||||
|
List<Alter_drop> drop;
|
||||||
|
List<Alter_column> alter;
|
||||||
|
HA_CREATE_INFO create_info;
|
||||||
|
DBUG_ENTER("mysql_create_index");
|
||||||
|
bzero((char*) &create_info,sizeof(create_info));
|
||||||
|
create_info.db_type=DB_TYPE_DEFAULT;
|
||||||
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
|
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
|
||||||
|
&create_info, table_list,
|
||||||
|
fields, keys, drop, alter, 0, (ORDER*)0,
|
||||||
|
ALTER_ADD_INDEX, DUP_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
|
||||||
|
{
|
||||||
|
List<create_field> fields;
|
||||||
|
List<Key> keys;
|
||||||
|
List<Alter_column> alter;
|
||||||
|
HA_CREATE_INFO create_info;
|
||||||
|
DBUG_ENTER("mysql_drop_index");
|
||||||
|
bzero((char*) &create_info,sizeof(create_info));
|
||||||
|
create_info.db_type=DB_TYPE_DEFAULT;
|
||||||
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
|
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
|
||||||
|
&create_info, table_list,
|
||||||
|
fields, keys, drop, alter, 0, (ORDER*)0,
|
||||||
|
ALTER_DROP_INDEX, DUP_ERROR));
|
||||||
|
}
|
||||||
|
1885
sql/sql_table.cc
1885
sql/sql_table.cc
File diff suppressed because it is too large
Load Diff
@ -46,12 +46,29 @@ static bool make_empty_rec(int file, enum db_type table_type,
|
|||||||
List<create_field> &create_fields,
|
List<create_field> &create_fields,
|
||||||
uint reclength,uint null_fields);
|
uint reclength,uint null_fields);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a frm (table definition) file
|
||||||
|
|
||||||
int mysql_create_frm(THD *thd, my_string file_name,
|
SYNOPSIS
|
||||||
HA_CREATE_INFO *create_info,
|
mysql_create_frm()
|
||||||
List<create_field> &create_fields,
|
thd Thread handler
|
||||||
uint keys, KEY *key_info,
|
file_name Name of file (including database and .frm)
|
||||||
handler *db_file)
|
create_info create info parameters
|
||||||
|
create_fields Fields to create
|
||||||
|
keys number of keys to create
|
||||||
|
key_info Keys to create
|
||||||
|
db_file Handler to use. May be zero, in which case we use
|
||||||
|
create_info->db_type
|
||||||
|
RETURN
|
||||||
|
0 ok
|
||||||
|
1 error
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool mysql_create_frm(THD *thd, my_string file_name,
|
||||||
|
HA_CREATE_INFO *create_info,
|
||||||
|
List<create_field> &create_fields,
|
||||||
|
uint keys, KEY *key_info,
|
||||||
|
handler *db_file)
|
||||||
{
|
{
|
||||||
uint reclength,info_length,screens,key_info_length,maxlength,null_fields;
|
uint reclength,info_length,screens,key_info_length,maxlength,null_fields;
|
||||||
File file;
|
File file;
|
||||||
@ -166,9 +183,29 @@ err:
|
|||||||
err2:
|
err2:
|
||||||
VOID(my_close(file,MYF(MY_WME)));
|
VOID(my_close(file,MYF(MY_WME)));
|
||||||
err3:
|
err3:
|
||||||
|
my_delete(file_name,MYF(0));
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
} /* mysql_create_frm */
|
} /* mysql_create_frm */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a frm (table definition) file and the tables
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
mysql_create_frm()
|
||||||
|
thd Thread handler
|
||||||
|
file_name Name of file (including database and .frm)
|
||||||
|
create_info create info parameters
|
||||||
|
create_fields Fields to create
|
||||||
|
keys number of keys to create
|
||||||
|
key_info Keys to create
|
||||||
|
db_file Handler to use. May be zero, in which case we use
|
||||||
|
create_info->db_type
|
||||||
|
RETURN
|
||||||
|
0 ok
|
||||||
|
1 error
|
||||||
|
*/
|
||||||
|
|
||||||
int rea_create_table(THD *thd, my_string file_name,
|
int rea_create_table(THD *thd, my_string file_name,
|
||||||
HA_CREATE_INFO *create_info,
|
HA_CREATE_INFO *create_info,
|
||||||
List<create_field> &create_fields,
|
List<create_field> &create_fields,
|
||||||
@ -179,12 +216,8 @@ int rea_create_table(THD *thd, my_string file_name,
|
|||||||
if (mysql_create_frm(thd, file_name, create_info,
|
if (mysql_create_frm(thd, file_name, create_info,
|
||||||
create_fields, keys, key_info, NULL) ||
|
create_fields, keys, key_info, NULL) ||
|
||||||
ha_create_table(file_name,create_info,0))
|
ha_create_table(file_name,create_info,0))
|
||||||
goto err;
|
DBUG_RETURN(1);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
err:
|
|
||||||
my_delete(file_name,MYF(0));
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
} /* rea_create_table */
|
} /* rea_create_table */
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,9 @@
|
|||||||
|
|
||||||
IMPLEMENTION:
|
IMPLEMENTION:
|
||||||
Supports following formats:
|
Supports following formats:
|
||||||
%#d
|
%#[l]d
|
||||||
%#u
|
%#[l]u
|
||||||
|
%#[l]x
|
||||||
%#.#s Note #.# is skiped
|
%#.#s Note #.# is skiped
|
||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
@ -47,7 +48,7 @@ int my_snprintf(char* to, size_t n, const char* fmt, ...)
|
|||||||
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *start=to, *end=to+n-1;
|
char *start=to, *end=to+n-1;
|
||||||
uint length, num_state, pre_zero;
|
uint length, num_state, pre_zero, have_long;
|
||||||
|
|
||||||
for (; *fmt ; fmt++)
|
for (; *fmt ; fmt++)
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
|||||||
/* Read max fill size (only used with %d and %u) */
|
/* Read max fill size (only used with %d and %u) */
|
||||||
if (*fmt == '-')
|
if (*fmt == '-')
|
||||||
fmt++;
|
fmt++;
|
||||||
length= num_state= pre_zero= 0;
|
length= num_state= pre_zero= have_long= 0;
|
||||||
for (;; fmt++)
|
for (;; fmt++)
|
||||||
{
|
{
|
||||||
if (my_isdigit(&my_charset_latin1,*fmt))
|
if (my_isdigit(&my_charset_latin1,*fmt))
|
||||||
@ -80,7 +81,10 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
|||||||
num_state= 1;
|
num_state= 1;
|
||||||
}
|
}
|
||||||
if (*fmt == 'l')
|
if (*fmt == 'l')
|
||||||
|
{
|
||||||
fmt++;
|
fmt++;
|
||||||
|
have_long= 1;
|
||||||
|
}
|
||||||
if (*fmt == 's') /* String parameter */
|
if (*fmt == 's') /* String parameter */
|
||||||
{
|
{
|
||||||
reg2 char *par = va_arg(ap, char *);
|
reg2 char *par = va_arg(ap, char *);
|
||||||
@ -92,20 +96,29 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
|||||||
to=strnmov(to,par,plen);
|
to=strnmov(to,par,plen);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
|
else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */
|
||||||
{
|
{
|
||||||
register int iarg;
|
register long larg;
|
||||||
uint res_length, to_length;
|
uint res_length, to_length;
|
||||||
char *store_start= to, *store_end;
|
char *store_start= to, *store_end;
|
||||||
char buff[16];
|
char buff[32];
|
||||||
|
|
||||||
if ((to_length= (uint) (end-to)) < 16 || length)
|
if ((to_length= (uint) (end-to)) < 16 || length)
|
||||||
store_start= buff;
|
store_start= buff;
|
||||||
iarg = va_arg(ap, int);
|
if (have_long)
|
||||||
if (*fmt == 'd')
|
larg = va_arg(ap, long);
|
||||||
store_end= int10_to_str((long) iarg, store_start, -10);
|
|
||||||
else
|
else
|
||||||
store_end= int10_to_str((long) (uint) iarg, store_start, 10);
|
if (*fmt == 'd')
|
||||||
|
larg = va_arg(ap, int);
|
||||||
|
else
|
||||||
|
larg= (long) (uint) va_arg(ap, int);
|
||||||
|
if (*fmt == 'd')
|
||||||
|
store_end= int10_to_str(larg, store_start, -10);
|
||||||
|
else
|
||||||
|
if (*fmt== 'u')
|
||||||
|
store_end= int10_to_str(larg, store_start, 10);
|
||||||
|
else
|
||||||
|
store_end= int2str(larg, store_start, 16);
|
||||||
if ((res_length= (uint) (store_end - store_start)) > to_length)
|
if ((res_length= (uint) (store_end - store_start)) > to_length)
|
||||||
break; /* num doesn't fit in output */
|
break; /* num doesn't fit in output */
|
||||||
/* If %#d syntax was used, we have to pre-zero/pre-space the string */
|
/* If %#d syntax was used, we have to pre-zero/pre-space the string */
|
||||||
@ -146,7 +159,7 @@ static void my_printf(const char * fmt, ...)
|
|||||||
n = my_vsnprintf(buf, sizeof(buf)-1,fmt, ar);
|
n = my_vsnprintf(buf, sizeof(buf)-1,fmt, ar);
|
||||||
printf(buf);
|
printf(buf);
|
||||||
printf("n=%d, strlen=%d\n", n, strlen(buf));
|
printf("n=%d, strlen=%d\n", n, strlen(buf));
|
||||||
if (buf[sizeof(buf)-1] != OVERRUN_SENTRY)
|
if ((uchar) buf[sizeof(buf)-1] != OVERRUN_SENTRY)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Buffer overrun\n");
|
fprintf(stderr, "Buffer overrun\n");
|
||||||
abort();
|
abort();
|
||||||
@ -167,6 +180,7 @@ int main()
|
|||||||
my_printf("Hello '%s' hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n", "hack");
|
my_printf("Hello '%s' hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n", "hack");
|
||||||
my_printf("Hello hhhhhhhhhhhhhh %d sssssssssssssss\n", 1);
|
my_printf("Hello hhhhhhhhhhhhhh %d sssssssssssssss\n", 1);
|
||||||
my_printf("Hello %u\n", 1);
|
my_printf("Hello %u\n", 1);
|
||||||
|
my_printf("Hex: %lx '%6lx'\n", 32, 65);
|
||||||
my_printf("conn %ld to: '%-.64s' user: '%-.32s' host:\
|
my_printf("conn %ld to: '%-.64s' user: '%-.32s' host:\
|
||||||
`%-.64s' (%-.64s)", 1, 0,0,0,0);
|
`%-.64s' (%-.64s)", 1, 0,0,0,0);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user