diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-09-08 00:50:10 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-09-08 00:50:10 +0400 |
commit | 29f0dcb56337a3e352ad7a70dcff6b25bb605325 (patch) | |
tree | 84935c21dc958724ae7dcbeeca0c0f08986fc430 /mysys | |
parent | 915a624cbcb58a10a2cfb2e2e4fd5029191fa86a (diff) | |
parent | 8a2454f8e9fce648272577fcf8006ae6e6806cf9 (diff) | |
download | mariadb-git-29f0dcb56337a3e352ad7a70dcff6b25bb605325.tar.gz |
Merge MySQL->MariaDB
* Finished Monty and Jani's merge
* Some InnoDB tests still fail (because it's old xtradb code run against
newer testsuite). They are expected to go after mergning with the latest
xtradb.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/Makefile.am | 2 | ||||
-rw-r--r-- | mysys/array.c | 15 | ||||
-rw-r--r-- | mysys/charset.c | 43 | ||||
-rw-r--r-- | mysys/hash.c | 36 | ||||
-rw-r--r-- | mysys/mf_format.c | 2 | ||||
-rw-r--r-- | mysys/mf_getdate.c | 8 | ||||
-rw-r--r-- | mysys/mf_iocache2.c | 1 | ||||
-rw-r--r-- | mysys/mf_keycache.c | 6 | ||||
-rw-r--r-- | mysys/my_getopt.c | 18 | ||||
-rw-r--r-- | mysys/my_handler_errors.h | 1 | ||||
-rw-r--r-- | mysys/my_init.c | 4 |
11 files changed, 94 insertions, 42 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 6efdd0d75e7..f958d1821da 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -68,7 +68,7 @@ EXTRA_DIST = CMakeLists.txt mf_soundex.c \ # test_charset_DEPENDENCIES= $(LIBRARIES) # charset2html_DEPENDENCIES= $(LIBRARIES) DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \ - -DDATADIR="\"$(MYSQLDATAdir)\"" \ + -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \ -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ -DDEFAULT_HOME_ENV=MYSQL_HOME \ diff --git a/mysys/array.c b/mysys/array.c index 62d6b1ed4e9..743bf4ef302 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -32,11 +32,11 @@ DESCRIPTION init_dynamic_array() initiates array and allocate space for init_alloc eilements. - Array is usable even if space allocation failed. + Array is usable even if space allocation failed, hence, the + function never returns TRUE. Static buffers must begin immediately after the array structure. RETURN VALUE - TRUE my_malloc_ci() failed FALSE Ok */ @@ -57,13 +57,12 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, array->size_of_element=element_size; if ((array->buffer= init_buffer)) DBUG_RETURN(FALSE); - if (init_alloc && - !(array->buffer=(uchar*) my_malloc_ci(element_size*init_alloc, - MYF(MY_WME)))) - { + /* + Since the dynamic array is usable even if allocation fails here malloc + should not throw an error + */ + if (!(array->buffer= (char*) my_malloc_ci(element_size*init_alloc, MYF(0)))) array->max_element=0; - DBUG_RETURN(TRUE); - } DBUG_RETURN(FALSE); } diff --git a/mysys/charset.c b/mysys/charset.c index 933694477fa..84723a88a96 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -387,7 +387,7 @@ char *get_charsets_dir(char *buf) DBUG_RETURN(res); } -CHARSET_INFO *all_charsets[256]; +CHARSET_INFO *all_charsets[256]={NULL}; CHARSET_INFO *default_charset_info = &my_charset_latin1; void add_compiled_collation(CHARSET_INFO *cs) @@ -497,29 +497,40 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) { char buf[FN_REFLEN]; CHARSET_INFO *cs; - /* - To make things thread safe we are not allowing other threads to interfere - while we may changing the cs_info_table - */ - pthread_mutex_lock(&THR_LOCK_charset); + if ((cs= all_charsets[cs_number])) { - if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED)) + if (cs->state & MY_CS_READY) /* if CS is already initialized */ + return cs; + + /* + To make things thread safe we are not allowing other threads to interfere + while we may changing the cs_info_table + */ + pthread_mutex_lock(&THR_LOCK_charset); + + if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */ { strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS); my_read_charset_file(buf,flags); } - cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; - } - if (cs && !(cs->state & MY_CS_READY)) - { - if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || - (cs->coll->init && cs->coll->init(cs, cs_alloc))) - cs= NULL; + + if (cs->state & MY_CS_AVAILABLE) + { + if (!(cs->state & MY_CS_READY)) + { + if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || + (cs->coll->init && cs->coll->init(cs, cs_alloc))) + cs= NULL; + else + cs->state|= MY_CS_READY; + } + } else - cs->state|= MY_CS_READY; + cs= NULL; + + pthread_mutex_unlock(&THR_LOCK_charset); } - pthread_mutex_unlock(&THR_LOCK_charset); return cs; } diff --git a/mysys/hash.c b/mysys/hash.c index 5443dedf7e0..136c2854bbe 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -45,6 +45,32 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length) return nr1; } +/** + @brief Initialize the hash + + @details + + Initialize the hash, by defining and giving valid values for + its elements. The failure to allocate memory for the + hash->array element will not result in a fatal failure. The + dynamic array that is part of the hash will allocate memory + as required during insertion. + + @param[in,out] hash The hash that is initialized + @param[in] charset The charater set information + @param[in] size The hash size + @param[in] key_offest The key offset for the hash + @param[in] key_length The length of the key used in + the hash + @param[in] get_key get the key for the hash + @param[in] free_element pointer to the function that + does cleanup + @param[in] CALLER_INFO_PROTO flag that define the behaviour + of the hash + @return inidicates success or failure of initialization + @retval 0 success + @retval 1 failure +*/ my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, ulong size, size_t key_offset, size_t key_length, @@ -55,12 +81,6 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size)); hash->records=0; - if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size, - growth_size)) - { - hash->free=0; /* Allow call to my_hash_free */ - DBUG_RETURN(1); - } hash->key_offset=key_offset; hash->key_length=key_length; hash->blength=1; @@ -68,7 +88,8 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, hash->free=free_element; hash->flags=flags; hash->charset=charset; - DBUG_RETURN(0); + DBUG_RETURN(my_init_dynamic_array_ci(&hash->array, + sizeof(HASH_LINK), size, growth_size)); } @@ -114,6 +135,7 @@ void my_hash_free(HASH *hash) my_hash_free_elements(hash); hash->free= 0; delete_dynamic(&hash->array); + hash->blength= 0; DBUG_VOID_RETURN; } diff --git a/mysys/mf_format.c b/mysys/mf_format.c index f199132626b..6afa2938fa3 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -79,7 +79,7 @@ char * fn_format(char * to, const char *name, const char *dir, /* To long path, return original or NULL */ size_t tmp_length; if (flag & MY_SAFE_PATH) - return NullS; + DBUG_RETURN(NullS); tmp_length= strlength(startpos); DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext, (uint) length)); diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 3a8e1be6a0b..9475bebd107 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -45,15 +45,15 @@ void get_date(register char * to, int flag, time_t date) skr=date ? (time_t) date : my_time(0); #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) if (flag & GETDATE_GMT) - localtime_r(&skr,&tm_tmp); - else gmtime_r(&skr,&tm_tmp); + else + localtime_r(&skr,&tm_tmp); start_time= &tm_tmp; #else if (flag & GETDATE_GMT) - start_time= localtime(&skr); - else start_time= gmtime(&skr); + else + start_time= localtime(&skr); #endif if (flag & GETDATE_SHORT_DATE) sprintf(to,"%02d%02d%02d", diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 87346f26b60..e83ba7b82fb 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -465,6 +465,7 @@ err: return (size_t) -1; } + int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, const char *default_val) { diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index ea0c97f5913..ece6c35888d 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -2044,13 +2044,15 @@ restart: } else { + size_t block_mem_offset; /* There are some never used blocks, take first of them */ DBUG_ASSERT(keycache->blocks_used < (ulong) keycache->disk_blocks); block= &keycache->block_root[keycache->blocks_used]; + block_mem_offset= + ((size_t) keycache->blocks_used) * keycache->key_cache_block_size; block->buffer= ADD_TO_PTR(keycache->block_mem, - ((ulong) keycache->blocks_used* - keycache->key_cache_block_size), + block_mem_offset, uchar*); keycache->blocks_used++; DBUG_ASSERT(!block->next_used); diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0de80b01c4f..e57c1d71a13 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,6 +20,7 @@ #include <mysys_err.h> #include <my_getopt.h> #include <errno.h> +#include <m_string.h> typedef void (*init_func_p)(const struct my_option *option, uchar* *variable, longlong value); @@ -409,7 +410,8 @@ invalid value '%s'", argument= optend; } else if (optp->arg_type == OPT_ARG && - (optp->var_type & GET_TYPE_MASK) == GET_BOOL) + (((optp->var_type & GET_TYPE_MASK) == GET_BOOL) || + (optp->var_type & GET_TYPE_MASK) == GET_ENUM)) { if (optend == disabled_my_option) *((my_bool*) value)= (my_bool) 0; @@ -647,8 +649,18 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) - return EXIT_ARGUMENT_INVALID; + if (((*(ulong *)result_pos)= + find_type(argument, opts->typelib, 2) - 1) < 0) + { + /* + Accept an integer representation of the enumerated item. + */ + char *endptr; + unsigned int arg= (unsigned int) strtol(argument, &endptr, 10); + if (*endptr || arg >= opts->typelib->count) + return EXIT_ARGUMENT_INVALID; + *(int*)result_pos= arg; + } break; case GET_SET: *((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err); diff --git a/mysys/my_handler_errors.h b/mysys/my_handler_errors.h index 4c952466545..4f0fd52e767 100644 --- a/mysys/my_handler_errors.h +++ b/mysys/my_handler_errors.h @@ -63,6 +63,7 @@ static const char *handler_error_messages[]= "Got a fatal error during initialization of handler", "File too short; Expected more data in file", "Read page with wrong checksum", + "Too many active concurrent transactions", "Row is not visible by the current transaction" }; diff --git a/mysys/my_init.c b/mysys/my_init.c index a34a2d9148c..0e1a8c9a4aa 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -136,6 +136,10 @@ void my_end(int infoflag) */ FILE *info_file= DBUG_FILE; my_bool print_info= (info_file != stderr); + + if (!my_init_done) + return; + /* We do not use DBUG_ENTER here, as after cleanup DBUG is no longer operational, so we cannot use DBUG_RETURN. |