diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-12-19 14:24:38 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-12-19 14:24:38 -0500 |
commit | dad555a09c8d590132c77c192a18d7fc1f8fe91e (patch) | |
tree | 38fb545e5df0a24333b8284c816f5bea95d19a03 /mysys | |
parent | 18173ddfc4081407832d9a6703d1b8356b7defe9 (diff) | |
parent | 90ea0145856338221803ebb9b446ed2a6e082412 (diff) | |
download | mariadb-git-dad555a09c8d590132c77c192a18d7fc1f8fe91e.tar.gz |
Merge tag 'mariadb-10.0.23' into 10.0-galera
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/hash.c | 2 | ||||
-rw-r--r-- | mysys/lf_hash.c | 40 | ||||
-rw-r--r-- | mysys/ma_dyncol.c | 11 | ||||
-rw-r--r-- | mysys/my_getopt.c | 2 | ||||
-rw-r--r-- | mysys/my_rdtsc.c | 25 | ||||
-rw-r--r-- | mysys/my_static.c | 1 | ||||
-rw-r--r-- | mysys/string.c | 3 |
7 files changed, 54 insertions, 30 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 4ef731cde15..344b698a433 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -40,7 +40,7 @@ static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, size_t length); -my_hash_value_type my_hash_sort(const CHARSET_INFO *cs, const uchar *key, +my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key, size_t length) { ulong nr1= 1, nr2= 4; diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index aa96ca94198..eb0c252edb1 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -43,7 +43,7 @@ const int LF_HASH_OVERHEAD= sizeof(LF_SLIST); /* a structure to pass the context (pointers two the three successive elements - in a list) from lfind to linsert/ldelete + in a list) from l_find to l_insert/l_delete */ typedef struct { intptr volatile *prev; @@ -70,7 +70,7 @@ typedef struct { cursor is positioned in either case pins[0..2] are used, they are NOT removed on return */ -static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, +static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins) { uint32 cur_hashnr; @@ -138,7 +138,7 @@ retry: /* DESCRIPTION insert a 'node' in the list that starts from 'head' in the correct - position (as found by lfind) + position (as found by l_find) RETURN 0 - inserted @@ -148,7 +148,7 @@ retry: it uses pins[0..2], on return all pins are removed. if there're nodes with the same key value, a new node is added before them. */ -static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs, +static LF_SLIST *l_insert(LF_SLIST * volatile *head, CHARSET_INFO *cs, LF_SLIST *node, LF_PINS *pins, uint flags) { CURSOR cursor; @@ -156,7 +156,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs, for (;;) { - if (lfind(head, cs, node->hashnr, node->key, node->keylen, + if (l_find(head, cs, node->hashnr, node->key, node->keylen, &cursor, pins) && (flags & LF_HASH_UNIQUE)) { @@ -200,7 +200,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs, NOTE it uses pins[0..2], on return all pins are removed. */ -static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, +static int l_delete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, const uchar *key, uint keylen, LF_PINS *pins) { CURSOR cursor; @@ -208,7 +208,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, for (;;) { - if (!lfind(head, cs, hashnr, key, keylen, &cursor, pins)) + if (!l_find(head, cs, hashnr, key, keylen, &cursor, pins)) { res= 1; /* not found */ break; @@ -232,7 +232,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, (to ensure the number of "set DELETED flag" actions is equal to the number of "remove from the list" actions) */ - lfind(head, cs, hashnr, key, keylen, &cursor, pins); + l_find(head, cs, hashnr, key, keylen, &cursor, pins); } res= 0; break; @@ -258,12 +258,12 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, it uses pins[0..2], on return the pin[2] keeps the node found all other pins are removed. */ -static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs, +static LF_SLIST *l_search(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, const uchar *key, uint keylen, LF_PINS *pins) { CURSOR cursor; - int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins); + int res= l_find(head, cs, hashnr, key, keylen, &cursor, pins); if (res) _lf_pin(pins, 2, cursor.curr); else @@ -363,7 +363,7 @@ void lf_hash_destroy(LF_HASH *hash) -1 - out of memory NOTE - see linsert() for pin usage notes + see l_insert() for pin usage notes */ int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data) { @@ -384,7 +384,7 @@ int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data) if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins))) return -1; node->hashnr= my_reverse_bits(hashnr) | 1; /* normal node */ - if (linsert(el, hash->charset, node, pins, hash->flags)) + if (l_insert(el, hash->charset, node, pins, hash->flags)) { _lf_alloc_free(pins, node); lf_rwunlock_by_pins(pins); @@ -407,7 +407,7 @@ int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data) 1 - didn't (not found) -1 - out of memory NOTE - see ldelete() for pin usage notes + see l_delete() for pin usage notes */ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) { @@ -427,7 +427,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) */ if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins))) return -1; - if (ldelete(el, hash->charset, my_reverse_bits(hashnr) | 1, + if (l_delete(el, hash->charset, my_reverse_bits(hashnr) | 1, (uchar *)key, keylen, pins)) { lf_rwunlock_by_pins(pins); @@ -446,7 +446,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) MY_ERRPTR if OOM NOTE - see lsearch() for pin usage notes + see l_search() for pin usage notes */ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) { @@ -460,7 +460,7 @@ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) return MY_ERRPTR; if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins))) return MY_ERRPTR; - found= lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1, + found= l_search(el, hash->charset, my_reverse_bits(hashnr) | 1, (uchar *)key, keylen, pins); lf_rwunlock_by_pins(pins); return found ? found+1 : 0; @@ -488,16 +488,16 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node, dummy->hashnr= my_reverse_bits(bucket) | 0; /* dummy node */ dummy->key= dummy_key; dummy->keylen= 0; - if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE))) + if ((cur= l_insert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE))) { my_free(dummy); dummy= cur; } my_atomic_casptr((void **)node, (void **)(char*) &tmp, dummy); /* - note that if the CAS above failed (after linsert() succeeded), - it would mean that some other thread has executed linsert() for - the same dummy node, its linsert() failed, it picked up our + note that if the CAS above failed (after l_insert() succeeded), + it would mean that some other thread has executed l_insert() for + the same dummy node, its l_insert() failed, it picked up our dummy node (in "dummy= cur") and executed the same CAS as above. Which means that even if CAS above failed we don't need to retry, and we should not free(dummy) - there's no memory leak here diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 7e47856ce2d..d7d4a127a75 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -3725,7 +3725,8 @@ mariadb_dyncol_check(DYNAMIC_COLUMN *str) /* It is not first entry */ if (prev_data_offset > data_offset || ((prev_type != DYN_COL_INT && - prev_type != DYN_COL_UINT) && prev_data_offset == data_offset)) + prev_type != DYN_COL_UINT && + prev_type != DYN_COL_DECIMAL) && prev_data_offset == data_offset)) { DBUG_PRINT("info", ("Field order: %u Previous data offset: %u" " >(=) Current data offset: %u", @@ -3837,14 +3838,12 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val, return ER_DYNCOL_RESOURCE; break; case DYN_COL_DOUBLE: - len= my_snprintf(buff, sizeof(buff), "%g", val->x.double_value); + + len= my_gcvt(val->x.double_value, MY_GCVT_ARG_DOUBLE, + sizeof(buff) - 1, buff, NULL); if (dynstr_realloc(str, len + (quote ? 2 : 0))) return ER_DYNCOL_RESOURCE; - if (quote) - str->str[str->length++]= quote; dynstr_append_mem(str, buff, len); - if (quote) - str->str[str->length++]= quote; break; case DYN_COL_DYNCOL: case DYN_COL_STRING: diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 2e97417340d..2a4557118b0 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -1,6 +1,6 @@ /* Copyright (c) 2002, 2013, Oracle and/or its affiliates - Copyright (c) 2009, 2013, Monty Program Ab + Copyright (c) 2009, 2015, MariaDB 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 diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c index 028c7f810d4..ad11e8c6a6c 100644 --- a/mysys/my_rdtsc.c +++ b/mysys/my_rdtsc.c @@ -129,6 +129,31 @@ ulonglong my_timer_cycles_il_x86_64(); clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms, or on read_real_time for aix platforms. There is nothing for Alpha platforms, they would be tricky. + + On the platforms that do not have a CYCLE timer, + "wait" events are initialized to use NANOSECOND instead of CYCLE + during performance_schema initialization (at the server startup). + + Linux performance monitor (see "man perf_event_open") can + provide cycle counter on the platforms that do not have + other kinds of cycle counters. But we don't use it so far. + + ARM notes + --------- + During tests on ARMv7 Debian, perf_even_open() based cycle counter provided + too low frequency with too high overhead: + MariaDB [performance_schema]> SELECT * FROM performance_timers; + +-------------+-----------------+------------------+----------------+ + | TIMER_NAME | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD | + +-------------+-----------------+------------------+----------------+ + | CYCLE | 689368159 | 1 | 970 | + | NANOSECOND | 1000000000 | 1 | 308 | + | MICROSECOND | 1000000 | 1 | 417 | + | MILLISECOND | 1000 | 1000 | 407 | + | TICK | 127 | 1 | 612 | + +-------------+-----------------+------------------+----------------+ + Therefore, it was decided not to use perf_even_open() on ARM + (i.e. go without CYCLE and have "wait" events use NANOSECOND by default). */ ulonglong my_timer_cycles(void) diff --git a/mysys/my_static.c b/mysys/my_static.c index 84d2dc64fc6..4aca78e30a9 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -72,7 +72,6 @@ ulong my_time_to_wait_for_lock=2; /* In seconds */ #ifdef SHARED_LIBRARY const char *globerrs[GLOBERRS]; /* my_error_messages is here */ #endif -void (*my_abort_hook)(int) = (void(*)(int)) exit; void (*error_handler_hook)(uint error, const char *str, myf MyFlags)= my_message_stderr; void (*fatal_error_handler_hook)(uint error, const char *str, myf MyFlags)= diff --git a/mysys/string.c b/mysys/string.c index 42fe83ed4e1..cc73d18c601 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -208,7 +208,8 @@ my_bool dynstr_append_quoted(DYNAMIC_STRING *str, void dynstr_free(DYNAMIC_STRING *str) { - my_free(str->str); + if (str->str) /* Safety to allow double free */ + my_free(str->str); str->str= NULL; } |