mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Added possibility to detect if libmysqld is restarted
(Needed to check if memory allocated with mysql_once_init() has been freed)
This commit is contained in:
@@ -214,6 +214,7 @@ extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests,
|
|||||||
my_cache_read;
|
my_cache_read;
|
||||||
extern ulong my_blocks_used, my_blocks_changed;
|
extern ulong my_blocks_used, my_blocks_changed;
|
||||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||||
|
extern uint mysys_usage_id;
|
||||||
extern my_bool my_init_done;
|
extern my_bool my_init_done;
|
||||||
|
|
||||||
/* Point to current my_message() */
|
/* Point to current my_message() */
|
||||||
|
@@ -42,8 +42,8 @@ static void netware_init();
|
|||||||
#define netware_init()
|
#define netware_init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
my_bool my_init_done= 0;
|
||||||
my_bool my_init_done=0;
|
uint mysys_usage_id= 0; /* Incremented for each my_init() */
|
||||||
|
|
||||||
static ulong atoi_octal(const char *str)
|
static ulong atoi_octal(const char *str)
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ static ulong atoi_octal(const char *str)
|
|||||||
while (*str && my_isspace(&my_charset_latin1, *str))
|
while (*str && my_isspace(&my_charset_latin1, *str))
|
||||||
str++;
|
str++;
|
||||||
str2int(str,
|
str2int(str,
|
||||||
(*str == '0' ? 8 : 10), /* Octalt or decimalt */
|
(*str == '0' ? 8 : 10), /* Octalt or decimalt */
|
||||||
0, INT_MAX, &tmp);
|
0, INT_MAX, &tmp);
|
||||||
return (ulong) tmp;
|
return (ulong) tmp;
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,7 @@ my_bool my_init(void)
|
|||||||
if (my_init_done)
|
if (my_init_done)
|
||||||
return 0;
|
return 0;
|
||||||
my_init_done=1;
|
my_init_done=1;
|
||||||
|
mysys_usage_id++;
|
||||||
#if defined(THREAD) && defined(SAFE_MUTEX)
|
#if defined(THREAD) && defined(SAFE_MUTEX)
|
||||||
safe_mutex_global_init(); /* Must be called early */
|
safe_mutex_global_init(); /* Must be called early */
|
||||||
#endif
|
#endif
|
||||||
|
@@ -110,6 +110,7 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
|
|||||||
tx_isolation_names, NULL};
|
tx_isolation_names, NULL};
|
||||||
|
|
||||||
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
|
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
|
||||||
|
uint known_extensions_id= 0;
|
||||||
|
|
||||||
enum db_type ha_resolve_by_name(const char *name, uint namelen)
|
enum db_type ha_resolve_by_name(const char *name, uint namelen)
|
||||||
{
|
{
|
||||||
@@ -1635,6 +1636,7 @@ int handler::index_read_idx(byte * buf, uint index, const byte * key,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns a list of all known extensions.
|
Returns a list of all known extensions.
|
||||||
|
|
||||||
@@ -1643,20 +1645,24 @@ int handler::index_read_idx(byte * buf, uint index, const byte * key,
|
|||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
No mutexes, worst case race is a minor surplus memory allocation
|
No mutexes, worst case race is a minor surplus memory allocation
|
||||||
|
We have to recreate the extension map if mysqld is restarted (for example
|
||||||
|
within libmysqld)
|
||||||
|
|
||||||
RETURN VALUE
|
RETURN VALUE
|
||||||
pointer pointer to TYPELIB structure
|
pointer pointer to TYPELIB structure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TYPELIB *ha_known_exts(void)
|
TYPELIB *ha_known_exts(void)
|
||||||
{
|
{
|
||||||
if (!known_extensions.type_names)
|
if (!known_extensions.type_names || mysys_usage_id != known_extensions_id)
|
||||||
{
|
{
|
||||||
show_table_type_st *types;
|
show_table_type_st *types;
|
||||||
List<char> found_exts;
|
List<char> found_exts;
|
||||||
List_iterator_fast<char> it(found_exts);
|
List_iterator_fast<char> it(found_exts);
|
||||||
const char *e, **ext;
|
const char **ext, *old_ext;
|
||||||
|
|
||||||
found_exts.push_back(".db");
|
known_extensions_id= mysys_usage_id;
|
||||||
|
found_exts.push_back((char*) ".db");
|
||||||
for (types= sys_table_types; types->type; types++)
|
for (types= sys_table_types; types->type; types++)
|
||||||
{
|
{
|
||||||
if (*types->value == SHOW_OPTION_YES)
|
if (*types->value == SHOW_OPTION_YES)
|
||||||
@@ -1664,28 +1670,30 @@ TYPELIB *ha_known_exts(void)
|
|||||||
handler *file= get_new_handler(0,(enum db_type) types->db_type);
|
handler *file= get_new_handler(0,(enum db_type) types->db_type);
|
||||||
for (ext= file->bas_ext(); *ext; ext++)
|
for (ext= file->bas_ext(); *ext; ext++)
|
||||||
{
|
{
|
||||||
while (e=it++)
|
while ((old_ext= it++))
|
||||||
if (e == *ext)
|
{
|
||||||
|
if (!strcmp(old_ext, *ext))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (!e)
|
if (!old_ext)
|
||||||
found_exts.push_back((char *)*ext);
|
found_exts.push_back((char *) *ext);
|
||||||
|
|
||||||
it.rewind();
|
it.rewind();
|
||||||
}
|
}
|
||||||
delete file;
|
delete file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext= (const char **)my_once_alloc(sizeof(char *)*
|
ext= (const char **) my_once_alloc(sizeof(char *)*
|
||||||
(found_exts.elements+1), MYF(MY_WME));
|
(found_exts.elements+1),
|
||||||
|
MYF(MY_WME | MY_FAE));
|
||||||
|
|
||||||
DBUG_ASSERT(ext);
|
DBUG_ASSERT(ext);
|
||||||
for (uint i=0; e=it++; i++)
|
|
||||||
ext[i]= e;
|
|
||||||
ext[found_exts.elements]= 0;
|
|
||||||
|
|
||||||
known_extensions.count= found_exts.elements;
|
known_extensions.count= found_exts.elements;
|
||||||
known_extensions.type_names= ext;
|
known_extensions.type_names= ext;
|
||||||
|
|
||||||
|
while ((old_ext= it++))
|
||||||
|
*ext++= old_ext;
|
||||||
|
*ext= 0;
|
||||||
}
|
}
|
||||||
return &known_extensions;
|
return &known_extensions;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user