Commit d9602ac7 authored by unknown's avatar unknown

Merge of ha_innobase.cc from 4.0; This fixes that MySQL doesn't allocate too...

Merge of ha_innobase.cc from 4.0; This fixes that MySQL doesn't allocate too big buffers when sorting innobase rows
Changed name of variables
NO_FOREIGN_KEY_CHECKS -> FOREIGN_KEY_CHECKS
RELAXED_UNIQUE_CHECKS -> UNIQUE_CHECKS
to avoid confusion with 'not...' variables.
Write name of adminstrator command to slow log.
Added mysqldumpslow to RPM


Docs/manual.texi:
  Changelog
sql/gen_lex_hash.cc:
  Updated values
sql/ha_innobase.cc:
  Remove return value of sprintf
  Merged back optimizations done in 4.0
  Fixed ref_length;  Caused MySQL to use big buffers when using InnoDB
sql/lex.h:
  Changed name of variables
  NO_FOREIGN_KEY_CHECKS -> FOREIGN_KEY_CHECKS
  RELAXED_UNIQUE_CHECKS -> UNIQUE_CHECKS
sql/log.cc:
  Write name of adminstrator command to slow log
sql/sql_yacc.yy:
  Changed name of variables
  NO_FOREIGN_KEY_CHECKS -> FOREIGN_KEY_CHECKS
  RELAXED_UNIQUE_CHECKS -> UNIQUE_CHECKS
support-files/mysql.spec.sh:
  Added mysqldumpslow to RPM
parent 0e6a67da
......@@ -46928,6 +46928,8 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.52
@itemize @bullet
@item
Added name of 'administrator command' logs.
@item
Fixed bug with creating an auto-increment value on second part of a
@code{UNIQUE()} key where first part could contain NULL values.
@item
......@@ -481,7 +481,7 @@ int main(int argc,char **argv)
int error;
MY_INIT(argv[0]);
start_value=6130115L; best_t1=3632784L; best_t2=86437L; best_type=3; /* mode=4229 add=2 type: 0 */
start_value=7740512L; best_t1=7953583L; best_t2=6918639L; best_type=1; /* mode=5449 add=1 type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & InnoDB Oy
/* Copyright (C) 2000 MySQL AB & InnoDB Oy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -93,8 +93,8 @@ are determined in innobase_init below: */
/* innobase_data_file_path=ibdata:15,idata2:1,... */
char* innobase_data_home_dir = NULL;
char* innobase_data_file_path = NULL;
char* innobase_data_home_dir = NULL;
char* innobase_log_group_home_dir = NULL;
char* innobase_log_arch_dir = NULL;
char* innobase_unix_file_flush_method = NULL;
......@@ -254,8 +254,6 @@ convert_error_code_to_mysql(
return(HA_ERR_TO_BIG_ROW);
} else {
dbug_assert(0);
return(-1); // Unknown error
}
}
......@@ -277,29 +275,40 @@ innobase_mysql_print_thd(
thd = (THD*) input_thd;
buf += sprintf(buf, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id);
if (thd->host) {
buf += sprintf(buf, " %.30s", thd->host);
/* We can't use value of sprintf() as this is not portable */
buf=my_sprintf(buf,
(buf, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id));
if (thd->host)
{
*buf++=' ';
buf=strnmov(buf, thd->host, 30);
}
if (thd->ip) {
buf += sprintf(buf, " %.20s", thd->ip);
if (thd->ip)
{
*buf++=' ';
buf=strnmov(buf, thd->ip, 20);
}
if (thd->user) {
buf += sprintf(buf, " %.20s", thd->user);
if (thd->user)
{
*buf++=' ';
buf=strnmov(buf, thd->user, 20);
}
if (thd->proc_info) {
buf += sprintf(buf, " %.50s", thd->proc_info);
if (thd->proc_info)
{
*buf++=' ';
buf=strnmov(buf, thd->procinfo, 50);
}
if (thd->query) {
buf += sprintf(buf, "\n%.150s", thd->query);
if (thd->query)
{
*buf++=' ';
buf=strnmov(buf, thd->query, 150);
}
buf += sprintf(buf, "\n");
*buf='\n';
}
}
......@@ -401,6 +410,11 @@ innobase_init(void)
os_innodb_umask = (ulint)my_umask;
/* Use current_dir if no paths are set */
current_dir[0] = FN_CURLIB;
current_dir[1] = FN_LIBCHAR;
current_dir[2] = 0;
if (specialflag & SPECIAL_NO_PRIOR) {
srv_set_thread_priorities = FALSE;
} else {
......@@ -408,11 +422,6 @@ innobase_init(void)
srv_query_thread_priority = QUERY_PRIOR;
}
/* Use current_dir if no paths are set */
current_dir[0] = FN_CURLIB;
current_dir[1] = FN_LIBCHAR;
current_dir[2] = 0;
/* Set InnoDB initialization parameters according to the values
read from MySQL .cnf file */
......@@ -452,9 +461,8 @@ innobase_init(void)
DBUG_RETURN(TRUE);
}
if (!innobase_log_group_home_dir) {
if (!innobase_log_group_home_dir)
innobase_log_group_home_dir = current_dir;
}
ret = (bool)
srv_parse_log_group_home_dirs(innobase_log_group_home_dir,
......@@ -797,7 +805,7 @@ normalize_table_name(
name_ptr = ptr + 1;
dbug_assert(ptr > name);
DBUG_ASSERT(ptr > name);
ptr--;
......@@ -824,7 +832,7 @@ normalize_table_name(
}
/*********************************************************************
Creates and opens a handle to a table which already exists in an Innnobase
Creates and opens a handle to a table which already exists in an Innobase
database. */
int
......@@ -909,20 +917,22 @@ ha_innobase::open(
primary_key = 0;
key_used_on_scan = 0;
/* MySQL allocates the buffer for ref */
/*
MySQL allocates the buffer for ref.
This includes all keys + one byte for each column
that may be NULL.
The ref_length must be exact as possible as
all reference buffers are allocated based on this.
*/
ref_length = table->key_info->key_length
+ table->key_info->key_parts + 10;
/* One byte per key field is consumed to the SQL NULL
info of the field; we add also 10 bytes of safety margin */
ref_length = table->key_info->key_length;
} else {
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = TRUE;
ref_length = DATA_ROW_ID_LEN + 10;
ref_length = DATA_ROW_ID_LEN;
dbug_assert(key_used_on_scan == MAX_KEY);
DBUG_ASSERT(key_used_on_scan == MAX_KEY);
}
auto_inc_counter_for_this_stat = 0;
......@@ -1069,8 +1079,8 @@ innobase_mysql_cmp(
enum_field_types mysql_tp;
int ret;
dbug_assert(a_length != UNIV_SQL_NULL);
dbug_assert(b_length != UNIV_SQL_NULL);
DBUG_ASSERT(a_length != UNIV_SQL_NULL);
DBUG_ASSERT(b_length != UNIV_SQL_NULL);
mysql_tp = (enum_field_types) mysql_type;
......@@ -1108,11 +1118,11 @@ get_innobase_type_from_mysql_type(
8 bits: this is used in ibuf and also when DATA_NOT_NULL is
ORed to the type */
dbug_assert((ulint)FIELD_TYPE_STRING < 256);
dbug_assert((ulint)FIELD_TYPE_VAR_STRING < 256);
dbug_assert((ulint)FIELD_TYPE_DOUBLE < 256);
dbug_assert((ulint)FIELD_TYPE_FLOAT < 256);
dbug_assert((ulint)FIELD_TYPE_DECIMAL < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_STRING < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_VAR_STRING < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_DOUBLE < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_FLOAT < 256);
DBUG_ASSERT((ulint)FIELD_TYPE_DECIMAL < 256);
switch (field->type()) {
case FIELD_TYPE_VAR_STRING: if (field->flags & BINARY_FLAG) {
......@@ -1204,7 +1214,12 @@ ha_innobase::store_key_val_for_row(
buff += key_part->length;
}
DBUG_RETURN(buff - buff_start);
/*
We have to zero-fill the buffer to be able to compare two
keys to see if they are equal
*/
bzero(buff, (ref_length- (uint) (buff - buff_start)));
DBUG_RETURN(ref_length);
}
/******************************************************************
......@@ -1994,7 +2009,7 @@ ha_innobase::change_active_index(
statistic_increment(ha_read_key_count, &LOCK_status);
DBUG_ENTER("index_read_idx");
DBUG_ENTER("change_active_index");
active_index = keynr;
......@@ -2013,10 +2028,10 @@ ha_innobase::change_active_index(
"InnoDB: Could not find key n:o %u with name %s from dict cache\n"
"InnoDB: for table %s\n", keynr, key ? key->name : "NULL", prebuilt->table->name);
return(1);
DBUG_RETURN(1);
}
assert(prebuilt->search_tuple);
assert(prebuilt->search_tuple != 0);
dtuple_set_n_fields(prebuilt->search_tuple, prebuilt->index->n_fields);
......@@ -2029,7 +2044,7 @@ ha_innobase::change_active_index(
build_template(prebuilt, user_thd, table, ROW_MYSQL_WHOLE_ROW);
return(0);
DBUG_RETURN(0);
}
/**************************************************************************
......@@ -2349,7 +2364,7 @@ ha_innobase::position(
len = store_key_val_for_row(primary_key, (char*) ref, record);
}
dbug_assert(len <= ref_length);
DBUG_ASSERT(len == ref_length);
ref_stored_len = len;
}
......@@ -2441,7 +2456,8 @@ create_index(
ind_type = 0;
if (strcmp(key->name, "PRIMARY") == 0) {
if (key_num == form->primary_key)
{
ind_type = ind_type | DICT_CLUSTERED;
}
......@@ -2513,23 +2529,23 @@ ha_innobase::create(
int error;
dict_table_t* innobase_table;
trx_t* trx;
int primary_key_no = -1;
KEY* key;
int primary_key_no;
uint i;
char name2[FN_REFLEN];
char norm_name[FN_REFLEN];
THD *thd= current_thd;
DBUG_ENTER("ha_innobase::create");
assert(current_thd != NULL);
DBUG_ASSERT(thd != NULL);
trx = trx_allocate_for_mysql();
if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) {
if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) {
trx->check_foreigns = FALSE;
}
if (current_thd->options & OPTION_RELAXED_UNIQUE_CHECKS) {
if (thd->options & OPTION_RELAXED_UNIQUE_CHECKS) {
trx->check_unique_secondary = FALSE;
}
......@@ -2559,13 +2575,9 @@ ha_innobase::create(
/* Look for a primary key */
for (i = 0; i < form->keys; i++) {
key = form->key_info + i;
if (strcmp(key->name, "PRIMARY") == 0) {
primary_key_no = (int) i;
}
}
primary_key_no= (table->primary_key != MAX_KEY ?
(int) table->primary_key :
-1);
/* Our function row_get_mysql_key_number_for_index assumes
the primary key is always number 0, if it exists */
......@@ -2651,7 +2663,7 @@ ha_innobase::create(
innobase_table = dict_table_get(norm_name, NULL);
assert(innobase_table);
assert(innobase_table != 0);
/* Tell the InnoDB server that there might be work for
utility threads: */
......@@ -2750,14 +2762,7 @@ innobase_drop_database(
namebuf[len + 1] = '\0';
#ifdef __WIN__
/* Put to lower case */
ptr = namebuf;
while (*ptr != '\0') {
*ptr = tolower(*ptr);
ptr++;
}
casedn_str(namebuf);
#endif
trx = trx_allocate_for_mysql();
......@@ -2948,7 +2953,7 @@ ha_innobase::estimate_number_of_rows(void)
estimate = 2 * data_file_length / dict_index_calc_min_rec_len(index);
return((ha_rows) estimate);
DBUG_RETURN((ha_rows) estimate);
}
/*************************************************************************
......@@ -3144,8 +3149,9 @@ ha_innobase::update_table_comment(
*pos++=' ';
}
pos += sprintf(pos, "InnoDB free: %lu kB",
(ulong) innobase_get_free_space());
pos += my_sprintf(pos,
(pos,"InnoDB free: %lu kB",
(ulong) innobase_get_free_space()));
/* We assume 450 - length bytes of space to print info */
......@@ -3322,6 +3328,7 @@ ha_innobase::external_lock(
& (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
innobase_commit(thd, trx);
thd->transaction.all.innodb_active_trans=0;
}
}
}
......
......@@ -232,7 +232,7 @@ static SYMBOL symbols[] = {
{ "NCHAR", SYM(NCHAR_SYM),0,0},
{ "NUMERIC", SYM(NUMERIC_SYM),0,0},
{ "NO", SYM(NO_SYM),0,0},
{ "NO_FOREIGN_KEY_CHECKS", SYM(NO_FOREIGN_KEY_CHECKS), 0, 0},
{ "FOREIGN_KEY_CHECKS", SYM(FOREIGN_KEY_CHECKS), 0, 0},
{ "NOT", SYM(NOT),0,0},
{ "NULL", SYM(NULL_SYM),0,0},
{ "ON", SYM(ON),0,0},
......@@ -261,7 +261,7 @@ static SYMBOL symbols[] = {
{ "REFERENCES", SYM(REFERENCES),0,0},
{ "RELOAD", SYM(RELOAD),0,0},
{ "REGEXP", SYM(REGEXP),0,0},
{ "RELAXED_UNIQUE_CHECKS", SYM(RELAXED_UNIQUE_CHECKS), 0, 0},
{ "UNIQUE_CHECKS", SYM(UNIQUE_CHECKS), 0, 0},
{ "RENAME", SYM(RENAME),0,0},
{ "REPAIR", SYM(REPAIR),0,0},
{ "REPLACE", SYM(REPLACE),0,0},
......
......@@ -948,16 +948,16 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
if (end != buff)
{
*end++=';';
*end++='\n';
*end=0;
*end='\n';
if (my_b_write(&log_file, (byte*) "SET ",4) ||
my_b_write(&log_file, (byte*) buff+1,(uint) (end-buff)-1))
my_b_write(&log_file, (byte*) buff+1,(uint) (end-buff)))
tmp_errno=errno;
}
if (!query)
{
query="#adminstrator command";
query_length=21;
end=strxmov(buff, "# administrator command: ",
command_name[thd->command], NullS);
query_length=(ulong) (end-buff);
}
if (my_b_write(&log_file, (byte*) query,query_length) ||
my_b_write(&log_file, (byte*) ";\n",2) ||
......
......@@ -224,7 +224,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token NATURAL
%token NCHAR_SYM
%token NOT
%token NO_FOREIGN_KEY_CHECKS
%token FOREIGN_KEY_CHECKS
%token NO_SYM
%token NULL_SYM
%token NUM
......@@ -253,7 +253,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token REAL_NUM
%token REFERENCES
%token REGEXP
%token RELAXED_UNIQUE_CHECKS
%token RELOAD
%token RENAME
%token REPEATABLE_SYM
......@@ -289,6 +288,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token UNCOMMITTED_SYM
%token UNION_SYM
%token UNIQUE_SYM
%token UNIQUE_CHECKS
%token USAGE
%token USE_SYM
%token USING
......@@ -2606,7 +2606,7 @@ keyword:
| MYISAM_SYM {}
| NATIONAL_SYM {}
| NCHAR_SYM {}
| NO_FOREIGN_KEY_CHECKS {}
| FOREIGN_KEY_CHECKS {}
| NO_SYM {}
| OPEN_SYM {}
| PACK_KEYS_SYM {}
......@@ -2619,7 +2619,7 @@ keyword:
| RAID_CHUNKSIZE {}
| RAID_STRIPED_SYM {}
| RAID_TYPE {}
| RELAXED_UNIQUE_CHECKS {}
| UNIQUE_CHECKS {}
| RELOAD {}
| REPAIR {}
| REPEATABLE_SYM {}
......@@ -2777,16 +2777,16 @@ option_value:
slave_skip_counter = $3;
pthread_mutex_unlock(&LOCK_slave);
}
| NO_FOREIGN_KEY_CHECKS equal NUM
| FOREIGN_KEY_CHECKS equal NUM
{
if (atoi($3.str) != 0)
if (atoi($3.str) == 0)
Lex->options|= OPTION_NO_FOREIGN_KEY_CHECKS;
else
Lex->options&= ~(OPTION_NO_FOREIGN_KEY_CHECKS);
}
| RELAXED_UNIQUE_CHECKS equal NUM
| UNIQUE_CHECKS equal NUM
{
if (atoi($3.str) != 0)
if (atoi($3.str) == 0)
Lex->options|= OPTION_RELAXED_UNIQUE_CHECKS;
else
Lex->options&= ~(OPTION_RELAXED_UNIQUE_CHECKS);
......
......@@ -382,6 +382,7 @@ fi
%attr(755, root, root) /usr/bin/safe_mysqld
%attr(755, root, root) /usr/bin/mysqld_multi
%attr(755, root, root) /usr/bin/my_print_defaults
%attr(755, root, root) /usr/bin/mysqldumpslow
%attr(644, root, root) /usr/info/mysql.info*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment