Commit 59dec1bc authored by unknown's avatar unknown

Fixed bug when creating keys in temporary HEAP tables.

(This caused the DISTINCT test to fail)
Removed one inline as this caused compiler problems


heap/hp_create.c:
  Comment
heap/hp_update.c:
  Indentation cleanup
heap/hp_write.c:
  Indentation cleanup
mysql-test/mysql-test-run.sh:
  Better options for valgrind
sql/item_sum.cc:
  Removed inline as this caused compiler problems with gcc 3.2
  (Was also non standard usage of inline)
sql/item_sum.h:
  Removed inline as this caused compiler problems with gcc 3.2
sql/sql_class.cc:
  Fixed reference to uninitialized value
sql/sql_lex.cc:
  Indentation cleanup
sql/sql_select.cc:
  Fixed bug when creating keys in temporary HEAP tables.
parent 9fcbfc0d
...@@ -140,6 +140,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, ...@@ -140,6 +140,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->auto_key= create_info->auto_key; share->auto_key= create_info->auto_key;
share->auto_key_type= create_info->auto_key_type; share->auto_key_type= create_info->auto_key_type;
share->auto_increment= create_info->auto_increment; share->auto_increment= create_info->auto_increment;
/* Must be allocated separately for rename to work */
if (!(share->name= my_strdup(name,MYF(0)))) if (!(share->name= my_strdup(name,MYF(0))))
{ {
my_free((gptr) share,MYF(0)); my_free((gptr) share,MYF(0));
......
...@@ -62,7 +62,8 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new) ...@@ -62,7 +62,8 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new)
/* we don't need to delete non-inserted key from rb-tree */ /* we don't need to delete non-inserted key from rb-tree */
if ((*keydef->write_key)(info, keydef, old, pos)) if ((*keydef->write_key)(info, keydef, old, pos))
{ {
if (++(share->records) == share->blength) share->blength+= share->blength; if (++(share->records) == share->blength)
share->blength+= share->blength;
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
keydef--; keydef--;
...@@ -78,6 +79,7 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new) ...@@ -78,6 +79,7 @@ int heap_update(HP_INFO *info, const byte *old, const byte *heap_new)
keydef--; keydef--;
} }
} }
if (++(share->records) == share->blength) share->blength+= share->blength; if (++(share->records) == share->blength)
share->blength+= share->blength;
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} /* heap_update */ } /* heap_update */
...@@ -155,7 +155,7 @@ static byte *next_free_record_pos(HP_SHARE *info) ...@@ -155,7 +155,7 @@ static byte *next_free_record_pos(HP_SHARE *info)
/* Write a hash-key to the hash-index */ /* Write a hash-key to the hash-index */
int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
const byte *record, byte *recpos) const byte *record, byte *recpos)
{ {
HP_SHARE *share = info->s; HP_SHARE *share = info->s;
int flag; int flag;
......
...@@ -19,7 +19,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work ...@@ -19,7 +19,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
# Program Definitions # Program Definitions
#-- #--
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11 PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$PATH
MASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master" MASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master"
# Standard functions # Standard functions
...@@ -319,8 +319,8 @@ while test $# -gt 0; do ...@@ -319,8 +319,8 @@ while test $# -gt 0; do
VALGRIND="valgrind --alignment=8 --leak-check=yes" VALGRIND="valgrind --alignment=8 --leak-check=yes"
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc"
SLEEP_TIME_AFTER_RESTART=120 SLEEP_TIME_AFTER_RESTART=60
SLEEP_TIME_FOR_DELETE=120 SLEEP_TIME_FOR_DELETE=60
;; ;;
--valgrind-options=*) --valgrind-options=*)
TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"` TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"`
......
...@@ -41,7 +41,7 @@ Item_sum::Item_sum(List<Item> &list) ...@@ -41,7 +41,7 @@ Item_sum::Item_sum(List<Item> &list)
list.empty(); // Fields are used list.empty(); // Fields are used
} }
inline void Item_sum::mark_as_sum_func() void Item_sum::mark_as_sum_func()
{ {
current_thd->lex.current_select->with_sum_func= with_sum_func= 1; current_thd->lex.current_select->with_sum_func= with_sum_func= 1;
} }
......
...@@ -34,7 +34,7 @@ class Item_sum :public Item_result_field ...@@ -34,7 +34,7 @@ class Item_sum :public Item_result_field
uint arg_count; uint arg_count;
bool quick_group; /* If incremental update of fields */ bool quick_group; /* If incremental update of fields */
inline void mark_as_sum_func(); void mark_as_sum_func();
Item_sum() : arg_count(0),quick_group(1) Item_sum() : arg_count(0),quick_group(1)
{ {
mark_as_sum_func(); mark_as_sum_func();
......
...@@ -142,8 +142,6 @@ THD::THD():user_time(0), fatal_error(0), ...@@ -142,8 +142,6 @@ THD::THD():user_time(0), fatal_error(0),
bzero((char*) &con_root,sizeof(con_root)); bzero((char*) &con_root,sizeof(con_root));
bzero((char*) &warn_root,sizeof(warn_root)); bzero((char*) &warn_root,sizeof(warn_root));
init_alloc_root(&warn_root, 1024, 0); init_alloc_root(&warn_root, 1024, 0);
bzero((char*) warn_count, sizeof(warn_count));
warn_list.empty();
user_connect=(USER_CONN *)0; user_connect=(USER_CONN *)0;
hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0, hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key, (hash_get_key) get_var_key,
...@@ -187,17 +185,20 @@ THD::THD():user_time(0), fatal_error(0), ...@@ -187,17 +185,20 @@ THD::THD():user_time(0), fatal_error(0),
void THD::init(void) void THD::init(void)
{ {
pthread_mutex_lock(&LOCK_global_system_variables);
variables= global_system_variables;
pthread_mutex_unlock(&LOCK_global_system_variables);
server_status= SERVER_STATUS_AUTOCOMMIT; server_status= SERVER_STATUS_AUTOCOMMIT;
update_lock_default= (variables.low_priority_updates ?
TL_WRITE_LOW_PRIORITY :
TL_WRITE);
options= thd_startup_options; options= thd_startup_options;
sql_mode=(uint) opt_sql_mode; sql_mode=(uint) opt_sql_mode;
open_options=ha_open_options; open_options=ha_open_options;
pthread_mutex_lock(&LOCK_global_system_variables); update_lock_default= (variables.low_priority_updates ?
variables= global_system_variables; TL_WRITE_LOW_PRIORITY :
pthread_mutex_unlock(&LOCK_global_system_variables); TL_WRITE);
session_tx_isolation= (enum_tx_isolation) variables.tx_isolation; session_tx_isolation= (enum_tx_isolation) variables.tx_isolation;
warn_list.empty();
bzero((char*) warn_count, sizeof(warn_count));
total_warn_count= 0;
} }
/* /*
...@@ -228,6 +229,7 @@ void THD::cleanup(void) ...@@ -228,6 +229,7 @@ void THD::cleanup(void)
{ {
DBUG_ENTER("THD::cleanup"); DBUG_ENTER("THD::cleanup");
ha_rollback(this); ha_rollback(this);
delete_tree(&prepared_statements);
if (locked_tables) if (locked_tables)
{ {
lock=locked_tables; locked_tables=0; lock=locked_tables; locked_tables=0;
...@@ -289,7 +291,6 @@ THD::~THD() ...@@ -289,7 +291,6 @@ THD::~THD()
free_root(&con_root,MYF(0)); free_root(&con_root,MYF(0));
free_root(&warn_root,MYF(0)); free_root(&warn_root,MYF(0));
free_root(&transaction.mem_root,MYF(0)); free_root(&transaction.mem_root,MYF(0));
delete_tree(&prepared_statements);
mysys_var=0; // Safety (shouldn't be needed) mysys_var=0; // Safety (shouldn't be needed)
pthread_mutex_destroy(&LOCK_delete); pthread_mutex_destroy(&LOCK_delete);
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -458,7 +458,7 @@ int yylex(void *arg, void *yythd) ...@@ -458,7 +458,7 @@ int yylex(void *arg, void *yythd)
LINT_INIT(c); LINT_INIT(c);
for (;;) for (;;)
{ {
switch(state) { switch (state) {
case STATE_OPERATOR_OR_IDENT: // Next is operator or keyword case STATE_OPERATOR_OR_IDENT: // Next is operator or keyword
case STATE_START: // Start of token case STATE_START: // Start of token
// Skip startspace // Skip startspace
...@@ -900,7 +900,8 @@ int yylex(void *arg, void *yythd) ...@@ -900,7 +900,8 @@ int yylex(void *arg, void *yythd)
return((int) '@'); return((int) '@');
case STATE_HOSTNAME: // end '@' of user@hostname case STATE_HOSTNAME: // end '@' of user@hostname
for (c=yyGet() ; for (c=yyGet() ;
my_isalnum(system_charset_info,c) || c == '.' || c == '_' || c == '$'; my_isalnum(system_charset_info,c) || c == '.' || c == '_' ||
c == '$';
c= yyGet()) ; c= yyGet()) ;
yylval->lex_str=get_token(lex,yyLength()); yylval->lex_str=get_token(lex,yyLength());
return(LEX_HOSTNAME); return(LEX_HOSTNAME);
......
...@@ -4115,6 +4115,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -4115,6 +4115,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->usable_key_parts=keyinfo->key_parts= param->group_parts; keyinfo->usable_key_parts=keyinfo->key_parts= param->group_parts;
keyinfo->key_length=0; keyinfo->key_length=0;
keyinfo->rec_per_key=0; keyinfo->rec_per_key=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
for (; group ; group=group->next,key_part_info++) for (; group ; group=group->next,key_part_info++)
{ {
Field *field=(*group->item)->tmp_table_field(); Field *field=(*group->item)->tmp_table_field();
...@@ -4191,6 +4192,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -4191,6 +4192,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL; keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL;
keyinfo->key_length=(uint16) reclength; keyinfo->key_length=(uint16) reclength;
keyinfo->name=(char*) "tmp"; keyinfo->name=(char*) "tmp";
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
if (null_pack_length) if (null_pack_length)
{ {
key_part_info->null_bit=0; key_part_info->null_bit=0;
......
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