diff options
author | Daniel Fischer <df@sun.com> | 2010-04-21 14:58:09 +0200 |
---|---|---|
committer | Daniel Fischer <df@sun.com> | 2010-04-21 14:58:09 +0200 |
commit | 50edf454b14a5094603688b4eaf1c50ed280ba90 (patch) | |
tree | 4fad82e285f056995b626f0a62b5fa0488294c19 /include | |
parent | 7fcf60b80e66b6a7c037d89e3b266b7a9d68bc48 (diff) | |
parent | c6c992e1cb817401f5a09fd7f6cf4eaebf448fab (diff) | |
download | mariadb-git-50edf454b14a5094603688b4eaf1c50ed280ba90.tar.gz |
Merge
Diffstat (limited to 'include')
-rw-r--r-- | include/atomic/x86-gcc.h | 2 | ||||
-rw-r--r-- | include/config-win.h | 3 | ||||
-rw-r--r-- | include/m_ctype.h | 80 | ||||
-rw-r--r-- | include/my_atomic.h | 4 | ||||
-rw-r--r-- | include/my_base.h | 6 | ||||
-rw-r--r-- | include/my_global.h | 27 | ||||
-rw-r--r-- | include/my_pthread.h | 110 | ||||
-rw-r--r-- | include/my_sys.h | 3 | ||||
-rw-r--r-- | include/mysql/psi/mysql_thread.h | 282 | ||||
-rw-r--r-- | include/mysql/psi/psi.h | 7 | ||||
-rw-r--r-- | include/mysql/psi/psi_abi_v1.h.pp | 2 | ||||
-rw-r--r-- | include/mysql_com.h | 8 | ||||
-rw-r--r-- | include/thr_lock.h | 15 |
13 files changed, 513 insertions, 36 deletions
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 77c32f8d70c..61b94a48568 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -88,7 +88,7 @@ */ #define make_atomic_add_body64 \ int64 tmp=*a; \ - while (!my_atomic_cas64(a, &tmp, tmp+v)); \ + while (!my_atomic_cas64(a, &tmp, tmp+v)) ; \ v=tmp; /* diff --git a/include/config-win.h b/include/config-win.h index 57d4ed26307..269ec0e925a 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -432,6 +432,9 @@ inline ulonglong double2ulonglong(double d) #define HAVE_CHARSET_ucs2 1 #define HAVE_CHARSET_ujis 1 #define HAVE_CHARSET_utf8 1 +#define HAVE_CHARSET_utf8mb4 1 +#define HAVE_CHARSET_utf16 1 +#define HAVE_CHARSET_utf32 1 #define HAVE_UCA_COLLATIONS 1 #define HAVE_BOOL 1 diff --git a/include/m_ctype.h b/include/m_ctype.h index 35d40e8bfa4..7c01ebe7e5a 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -38,6 +38,24 @@ extern "C" { #define my_wc_t ulong +#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD + +/* + On i386 we store Unicode->CS conversion tables for + some character sets using Big-endian order, + to copy two bytes at onces. + This gives some performance improvement. +*/ +#ifdef __i386__ +#define MB2(x) (((x) >> 8) + (((x) & 0xFF) << 8)) +#define MY_PUT_MB2(s, code) { *((uint16*)(s))= (code); } +#else +#define MB2(x) (x) +#define MY_PUT_MB2(s, code) { (s)[0]= code >> 8; (s)[1]= code & 0xFF; } +#endif + + + typedef struct unicase_info_st { uint32 toupper; @@ -81,13 +99,14 @@ extern MY_UNI_CTYPE my_uni_ctype[256]; #define MY_CS_BINSORT 16 /* if binary sort order */ #define MY_CS_PRIMARY 32 /* if primary collation */ #define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ -#define MY_CS_UNICODE 128 /* is a charset is full unicode */ +#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */ #define MY_CS_READY 256 /* if a charset is initialized */ #define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ #define MY_CS_CSSORT 1024 /* if case sensitive sort order */ #define MY_CS_HIDDEN 2048 /* don't display in SHOW */ #define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */ #define MY_CS_NONASCII 8192 /* if not ASCII-compatible */ +#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */ #define MY_CHARSET_UNDEFINED 0 /* Character repertoire flags */ @@ -95,7 +114,6 @@ extern MY_UNI_CTYPE my_uni_ctype[256]; #define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */ #define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */ - typedef struct my_uni_idx_st { uint16 from; @@ -287,10 +305,14 @@ typedef struct charset_info_st extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin; +extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1; +extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename; + extern CHARSET_INFO my_charset_big5_chinese_ci; extern CHARSET_INFO my_charset_big5_bin; extern CHARSET_INFO my_charset_cp932_japanese_ci; extern CHARSET_INFO my_charset_cp932_bin; +extern CHARSET_INFO my_charset_cp1250_czech_ci; extern CHARSET_INFO my_charset_eucjpms_japanese_ci; extern CHARSET_INFO my_charset_eucjpms_bin; extern CHARSET_INFO my_charset_euckr_korean_ci; @@ -299,7 +321,6 @@ extern CHARSET_INFO my_charset_gb2312_chinese_ci; extern CHARSET_INFO my_charset_gb2312_bin; extern CHARSET_INFO my_charset_gbk_chinese_ci; extern CHARSET_INFO my_charset_gbk_bin; -extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1; extern CHARSET_INFO my_charset_latin1_german2_ci; extern CHARSET_INFO my_charset_latin1_bin; extern CHARSET_INFO my_charset_latin2_czech_ci; @@ -312,11 +333,22 @@ extern CHARSET_INFO my_charset_ucs2_bin; extern CHARSET_INFO my_charset_ucs2_unicode_ci; extern CHARSET_INFO my_charset_ujis_japanese_ci; extern CHARSET_INFO my_charset_ujis_bin; +extern CHARSET_INFO my_charset_utf16_bin; +extern CHARSET_INFO my_charset_utf16_general_ci; +extern CHARSET_INFO my_charset_utf16_unicode_ci; +extern CHARSET_INFO my_charset_utf32_bin; +extern CHARSET_INFO my_charset_utf32_general_ci; +extern CHARSET_INFO my_charset_utf32_unicode_ci; + extern CHARSET_INFO my_charset_utf8_general_ci; extern CHARSET_INFO my_charset_utf8_unicode_ci; extern CHARSET_INFO my_charset_utf8_bin; -extern CHARSET_INFO my_charset_cp1250_czech_ci; -extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename; +extern CHARSET_INFO my_charset_utf8mb4_bin; +extern CHARSET_INFO my_charset_utf8mb4_general_ci; +extern CHARSET_INFO my_charset_utf8mb4_unicode_ci; +#define MY_UTF8MB3 "utf8" +#define MY_UTF8MB4 "utf8mb4" + /* declarations for simple charsets */ extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t, @@ -413,6 +445,19 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, char *min_str, char *max_str, size_t *min_length, size_t *max_length); +my_bool my_like_range_utf16(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length); + +my_bool my_like_range_utf32(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length); int my_wildcmp_8bit(CHARSET_INFO *, const char *str,const char *str_end, @@ -463,6 +508,31 @@ uint my_instr_mb(struct charset_info_st *, const char *s, size_t s_length, my_match_t *match, uint nmatch); +int my_strnncoll_mb_bin(CHARSET_INFO * cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix); + +int my_strnncollsp_mb_bin(CHARSET_INFO *cs, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + my_bool diff_if_only_endspace_difference); + +int my_wildcmp_mb_bin(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many); + +int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const char *s, const char *t); + +void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), + const uchar *key, size_t len,ulong *nr1, ulong *nr2); + +size_t my_strnxfrm_unicode(CHARSET_INFO *, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen); + int my_wildcmp_unicode(CHARSET_INFO *cs, const char *str, const char *str_end, const char *wildstr, const char *wildend, diff --git a/include/my_atomic.h b/include/my_atomic.h index 9914fd2428f..8ba3e201730 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -77,13 +77,13 @@ #ifndef make_atomic_add_body #define make_atomic_add_body(S) \ int ## S tmp=*a; \ - while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \ + while (!my_atomic_cas ## S(a, &tmp, tmp+v)) ; \ v=tmp; #endif #ifndef make_atomic_fas_body #define make_atomic_fas_body(S) \ int ## S tmp=*a; \ - while (!my_atomic_cas ## S(a, &tmp, v)); \ + while (!my_atomic_cas ## S(a, &tmp, v)) ; \ v=tmp; #endif #ifndef make_atomic_load_body diff --git a/include/my_base.h b/include/my_base.h index 226a6c44733..7766d4165a2 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -191,10 +191,11 @@ enum ha_extra_function { /* Inform handler that we will do a rename */ HA_EXTRA_PREPARE_FOR_RENAME, /* - Orders MERGE handler to attach or detach its child tables. Used at - begin and end of a statement. + Special actions for MERGE tables. */ + HA_EXTRA_ADD_CHILDREN_LIST, HA_EXTRA_ATTACH_CHILDREN, + HA_EXTRA_IS_ATTACHED_CHILDREN, HA_EXTRA_DETACH_CHILDREN }; @@ -272,6 +273,7 @@ enum ha_base_keytype { #define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */ #define HA_VAR_LENGTH_KEY 8 #define HA_NULL_PART_KEY 64 +#define HA_USES_COMMENT 4096 #define HA_USES_PARSER 16384 /* Fulltext index uses [pre]parser */ #define HA_USES_BLOCK_SIZE ((uint) 32768) #define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */ diff --git a/include/my_global.h b/include/my_global.h index d71ab89e008..b4bc61e0a48 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -83,12 +83,6 @@ #endif #endif /* _WIN32... */ -#ifdef EMBEDDED_LIBRARY -#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE -#undef WITH_PERFSCHEMA_STORAGE_ENGINE -#endif -#endif /* EMBEDDED_LIBRARY */ - #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #define HAVE_PSI_INTERFACE #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ @@ -1681,7 +1675,7 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } #if !defined(max) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) -#endif +#endif /* Only Linux is known to need an explicit sync of the directory to make sure a file creation/deletion/renaming in(from,to) this directory durable. @@ -1694,6 +1688,25 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } #define bool In_C_you_should_use_my_bool_instead() #endif +/* Provide __func__ macro definition for platforms that miss it. */ +#if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "<unknown>" +# endif +#elif defined(_MSC_VER) +# if _MSC_VER < 1300 +# define __func__ "<unknown>" +# else +# define __func__ __FUNCTION__ +# endif +#elif defined(__BORLANDC__) +# define __func__ __FUNC__ +#else +# define __func__ "<unknown>" +#endif + #ifndef HAVE_RINT /** All integers up to this number can be represented exactly as double precision diff --git a/include/my_pthread.h b/include/my_pthread.h index f2df7f4c198..0b55c70b0fa 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -102,6 +102,19 @@ struct timespec { (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ } +/** + Compare two timespec structs. + + @retval 1 If TS1 ends after TS2. + + @retval 0 If TS1 is equal to TS2. + + @retval -1 If TS1 ends before TS2. +*/ +#define cmp_timespec(TS1, TS2) \ + ((TS1.tv.i64 > TS2.tv.i64) ? 1 : \ + ((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0)) + int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *); @@ -417,6 +430,33 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif /* !set_timespec_nsec */ #endif /* HAVE_TIMESPEC_TS_SEC */ +/** + Compare two timespec structs. + + @retval 1 If TS1 ends after TS2. + + @retval 0 If TS1 is equal to TS2. + + @retval -1 If TS1 ends before TS2. +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef cmp_timespec +#define cmp_timespec(TS1, TS2) \ + ((TS1.ts_sec > TS2.ts_sec || \ + (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec > TS2.ts_nsec)) ? 1 : \ + ((TS1.ts_sec < TS2.ts_sec || \ + (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec < TS2.ts_nsec)) ? -1 : 0)) +#endif /* !cmp_timespec */ +#else +#ifndef cmp_timespec +#define cmp_timespec(TS1, TS2) \ + ((TS1.tv_sec > TS2.tv_sec || \ + (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec > TS2.tv_nsec)) ? 1 : \ + ((TS1.tv_sec < TS2.tv_sec || \ + (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec < TS2.tv_nsec)) ? -1 : 0)) +#endif /* !cmp_timespec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) @@ -560,30 +600,76 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp); #define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0) #else /* Use our own version of read/write locks */ -typedef struct _my_rw_lock_t { - pthread_mutex_t lock; /* lock for structure */ - pthread_cond_t readers; /* waiting readers */ - pthread_cond_t writers; /* waiting writers */ - int state; /* -1:writer,0:free,>0:readers */ - int waiters; /* number of waiting writers */ -} my_rw_lock_t; - +#define NEED_MY_RW_LOCK 1 #define rw_lock_t my_rw_lock_t +#define my_rwlock_init(A,B) my_rw_init((A), 0) #define rw_rdlock(A) my_rw_rdlock((A)) #define rw_wrlock(A) my_rw_wrlock((A)) #define rw_tryrdlock(A) my_rw_tryrdlock((A)) #define rw_trywrlock(A) my_rw_trywrlock((A)) #define rw_unlock(A) my_rw_unlock((A)) -#define rwlock_destroy(A) my_rwlock_destroy((A)) +#define rwlock_destroy(A) my_rw_destroy((A)) +#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ + + +/* + Portable read-write locks which prefer readers. + + Required by some algorithms in order to provide correctness. +*/ -extern int my_rwlock_init(my_rw_lock_t *, void *); -extern int my_rwlock_destroy(my_rw_lock_t *); +#if defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) +/* + On systems which have a way to specify that readers should + be preferred through attribute mechanism (e.g. Linux) we use + system implementation of read/write locks. +*/ +#define rw_pr_lock_t pthread_rwlock_t +extern int rw_pr_init(rw_pr_lock_t *); +#define rw_pr_rdlock(A) pthread_rwlock_rdlock(A) +#define rw_pr_wrlock(A) pthread_rwlock_wrlock(A) +#define rw_pr_tryrdlock(A) pthread_rwlock_tryrdlock(A) +#define rw_pr_trywrlock(A) pthread_rwlock_trywrlock(A) +#define rw_pr_unlock(A) pthread_rwlock_unlock(A) +#define rw_pr_destroy(A) pthread_rwlock_destroy(A) +#else +/* Otherwise we have to use our own implementation of read/write locks. */ +#define NEED_MY_RW_LOCK 1 +struct st_my_rw_lock_t; +#define rw_pr_lock_t my_rw_lock_t +extern int rw_pr_init(struct st_my_rw_lock_t *); +#define rw_pr_rdlock(A) my_rw_rdlock((A)) +#define rw_pr_wrlock(A) my_rw_wrlock((A)) +#define rw_pr_tryrdlock(A) my_rw_tryrdlock((A)) +#define rw_pr_trywrlock(A) my_rw_trywrlock((A)) +#define rw_pr_unlock(A) my_rw_unlock((A)) +#define rw_pr_destroy(A) my_rw_destroy((A)) +#endif /* defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) */ + + +#ifdef NEED_MY_RW_LOCK +/* + On systems which don't support native read/write locks, or don't support + read/write locks which prefer readers we have to use own implementation. +*/ +typedef struct st_my_rw_lock_t { + pthread_mutex_t lock; /* lock for structure */ + pthread_cond_t readers; /* waiting readers */ + pthread_cond_t writers; /* waiting writers */ + int state; /* -1:writer,0:free,>0:readers */ + int waiters; /* number of waiting writers */ + my_bool prefer_readers; +} my_rw_lock_t; + +extern int my_rw_init(my_rw_lock_t *, my_bool *); +extern int my_rw_destroy(my_rw_lock_t *); extern int my_rw_rdlock(my_rw_lock_t *); extern int my_rw_wrlock(my_rw_lock_t *); extern int my_rw_unlock(my_rw_lock_t *); extern int my_rw_tryrdlock(my_rw_lock_t *); extern int my_rw_trywrlock(my_rw_lock_t *); -#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ +#endif /* NEED_MY_RW_LOCK */ + #define GETHOSTBYADDR_BUFF_SIZE 2048 diff --git a/include/my_sys.h b/include/my_sys.h index 645463714d1..a3665d43b50 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -238,6 +238,9 @@ extern void (*fatal_error_handler_hook)(uint my_err, const char *str, extern uint my_file_limit; extern ulong my_thread_stack_size; +extern const char *(*proc_info_hook)(void *, const char *, const char *, + const char *, const unsigned int); + #ifdef HAVE_LARGE_PAGES extern my_bool my_use_large_pages; extern uint my_large_page_size; diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 18c4daa0cf2..4e839c7cf6a 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -107,6 +107,22 @@ struct st_mysql_rwlock }; /** + An instrumented prlock structure. + @sa mysql_prlock_t +*/ +struct st_mysql_prlock +{ + /** The real prlock */ + rw_pr_lock_t m_prlock; + /** + The instrumentation hook. + Note that this hook is not conditionally defined, + for binary compatibility of the @c mysql_rwlock_t interface. + */ + struct PSI_rwlock *m_psi; +}; + +/** Type of an instrumented rwlock. @c mysql_rwlock_t is a drop-in replacement for @c pthread_rwlock_t. @sa mysql_rwlock_init @@ -120,6 +136,20 @@ struct st_mysql_rwlock typedef struct st_mysql_rwlock mysql_rwlock_t; /** + Type of an instrumented prlock. + A prlock is a read write lock that 'prefers readers' (pr). + @c mysql_prlock_t is a drop-in replacement for @c rw_pr_lock_t. + @sa mysql_prlock_init + @sa mysql_prlock_rdlock + @sa mysql_prlock_tryrdlock + @sa mysql_prlock_wrlock + @sa mysql_prlock_trywrlock + @sa mysql_prlock_unlock + @sa mysql_prlock_destroy +*/ +typedef struct st_mysql_prlock mysql_prlock_t; + +/** An instrumented cond structure. @sa mysql_cond_t */ @@ -162,6 +192,8 @@ typedef struct st_mysql_cond mysql_cond_t; on some platforms. The proper fix would be to cut these extra dependencies in the calling code. DISABLE_MYSQL_THREAD_H is a work around to limit dependencies. + DISABLE_MYSQL_PRLOCK_H is similar, and is used to disable specifically + the prlock wrappers. */ #ifndef DISABLE_MYSQL_THREAD_H @@ -282,6 +314,19 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_init(K, RW) + Instrumented rw_pr_init. + @c mysql_prlock_init is a replacement for @c rw_pr_init. + @param K The PSI_rwlock_key for this instrumented prlock + @param RW The prlock to initialize +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(K, RW) +#else + #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(RW) +#endif + +/** @def mysql_rwlock_destroy(RW) Instrumented rwlock_destroy. @c mysql_rwlock_destroy is a drop-in replacement @@ -290,6 +335,14 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_rwlock_destroy(RW) inline_mysql_rwlock_destroy(RW) /** + @def mysql_prlock_destroy(RW) + Instrumented rw_pr_destroy. + @c mysql_prlock_destroy is a drop-in replacement + for @c rw_pr_destroy. +*/ +#define mysql_prlock_destroy(RW) inline_mysql_prlock_destroy(RW) + +/** @def mysql_rwlock_rdlock(RW) Instrumented rwlock_rdlock. @c mysql_rwlock_rdlock is a drop-in replacement @@ -304,6 +357,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_rdlock(RW) + Instrumented rw_pr_rdlock. + @c mysql_prlock_rdlock is a drop-in replacement + for @c rw_pr_rdlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_rdlock(RW) \ + inline_mysql_prlock_rdlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_rdlock(RW) \ + inline_mysql_prlock_rdlock(RW) +#endif + +/** @def mysql_rwlock_wrlock(RW) Instrumented rwlock_wrlock. @c mysql_rwlock_wrlock is a drop-in replacement @@ -318,6 +385,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_wrlock(RW) + Instrumented rw_pr_wrlock. + @c mysql_prlock_wrlock is a drop-in replacement + for @c rw_pr_wrlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_wrlock(RW) \ + inline_mysql_prlock_wrlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_wrlock(RW) \ + inline_mysql_prlock_wrlock(RW) +#endif + +/** @def mysql_rwlock_tryrdlock(RW) Instrumented rwlock_tryrdlock. @c mysql_rwlock_tryrdlock is a drop-in replacement @@ -332,6 +413,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_tryrdlock(RW) + Instrumented rw_pr_tryrdlock. + @c mysql_prlock_tryrdlock is a drop-in replacement + for @c rw_pr_tryrdlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_tryrdlock(RW) \ + inline_mysql_prlock_tryrdlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_tryrdlock(RW) \ + inline_mysql_prlock_tryrdlock(RW) +#endif + +/** @def mysql_rwlock_trywrlock(RW) Instrumented rwlock_trywrlock. @c mysql_rwlock_trywrlock is a drop-in replacement @@ -346,6 +441,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_trywrlock(RW) + Instrumented rw_pr_trywrlock. + @c mysql_prlock_trywrlock is a drop-in replacement + for @c rw_pr_trywrlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_trywrlock(RW) \ + inline_mysql_prlock_trywrlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_trywrlock(RW) \ + inline_mysql_prlock_trywrlock(RW) +#endif + +/** @def mysql_rwlock_unlock(RW) Instrumented rwlock_unlock. @c mysql_rwlock_unlock is a drop-in replacement @@ -354,8 +463,16 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_rwlock_unlock(RW) inline_mysql_rwlock_unlock(RW) /** + @def mysql_prlock_unlock(RW) + Instrumented rw_pr_unlock. + @c mysql_prlock_unlock is a drop-in replacement + for @c rw_pr_unlock. +*/ +#define mysql_prlock_unlock(RW) inline_mysql_prlock_unlock(RW) + +/** @def mysql_cond_init(K, C, A) - Instrumented rwlock_init. + Instrumented cond_init. @c mysql_cond_init is a replacement for @c pthread_cond_init. @param C The cond to initialize @param K The PSI_cond_key for this instrumented cond @@ -599,6 +716,23 @@ static inline int inline_mysql_rwlock_init( return my_rwlock_init(&that->m_rwlock, NULL); } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_init( +#ifdef HAVE_PSI_INTERFACE + PSI_rwlock_key key, +#endif + mysql_prlock_t *that) +{ +#ifdef HAVE_PSI_INTERFACE + that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_prlock) + : NULL); +#else + that->m_psi= NULL; +#endif + return rw_pr_init(&that->m_prlock); +} +#endif + static inline int inline_mysql_rwlock_destroy( mysql_rwlock_t *that) { @@ -612,6 +746,21 @@ static inline int inline_mysql_rwlock_destroy( return rwlock_destroy(&that->m_rwlock); } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_destroy( + mysql_prlock_t *that) +{ +#ifdef HAVE_PSI_INTERFACE + if (likely(PSI_server && that->m_psi)) + { + PSI_server->destroy_rwlock(that->m_psi); + that->m_psi= NULL; + } +#endif + return rw_pr_destroy(&that->m_prlock); +} +#endif + static inline int inline_mysql_rwlock_rdlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -638,6 +787,34 @@ static inline int inline_mysql_rwlock_rdlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_rdlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_READLOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + } +#endif + result= rw_pr_rdlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_rdwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_wrlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -664,6 +841,34 @@ static inline int inline_mysql_rwlock_wrlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_wrlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_WRITELOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + } +#endif + result= rw_pr_wrlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_wrwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_tryrdlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -690,6 +895,34 @@ static inline int inline_mysql_rwlock_tryrdlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_tryrdlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_TRYREADLOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + } +#endif + result= rw_pr_tryrdlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_rdwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_trywrlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -716,6 +949,34 @@ static inline int inline_mysql_rwlock_trywrlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_trywrlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_TRYWRITELOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + } +#endif + result= rw_pr_trywrlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_wrwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_unlock( mysql_rwlock_t *that) { @@ -733,6 +994,25 @@ static inline int inline_mysql_rwlock_unlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_unlock( + mysql_prlock_t *that) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_thread *thread; + if (likely(PSI_server && that->m_psi)) + { + thread= PSI_server->get_thread(); + if (likely(thread != NULL)) + PSI_server->unlock_rwlock(thread, that->m_psi); + } +#endif + result= rw_pr_unlock(&that->m_prlock); + return result; +} +#endif + static inline int inline_mysql_cond_init( #ifdef HAVE_PSI_INTERFACE PSI_cond_key key, diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index a9277cd18bd..51446fa83a5 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2009 Sun Microsystems, Inc +/* Copyright (C) 2008-2010 Sun Microsystems, Inc 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 @@ -614,6 +614,9 @@ typedef void (*set_thread_v1_t)(struct PSI_thread *thread); /** Delete the current thread instrumentation. */ typedef void (*delete_current_thread_v1_t)(void); +/** Delete a thread instrumentation. */ +typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); + /** Get a mutex instrumentation locker. @param mutex the instrumented mutex to lock @@ -890,6 +893,8 @@ struct PSI_v1 set_thread_v1_t set_thread; /** @sa delete_current_thread_v1_t. */ delete_current_thread_v1_t delete_current_thread; + /** @sa delete_thread_v1_t. */ + delete_thread_v1_t delete_thread; /** @sa get_thread_mutex_locker_v1_t. */ get_thread_mutex_locker_v1_t get_thread_mutex_locker; /** @sa get_thread_rwlock_locker_v1_t. */ diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index aedf28ba694..6ecd0f3098d 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -127,6 +127,7 @@ typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread, typedef struct PSI_thread* (*get_thread_v1_t)(void); typedef void (*set_thread_v1_t)(struct PSI_thread *thread); typedef void (*delete_current_thread_v1_t)(void); +typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t) (struct PSI_mutex *mutex, enum PSI_mutex_operation op); typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t) @@ -204,6 +205,7 @@ struct PSI_v1 get_thread_v1_t get_thread; set_thread_v1_t set_thread; delete_current_thread_v1_t delete_current_thread; + delete_thread_v1_t delete_thread; get_thread_mutex_locker_v1_t get_thread_mutex_locker; get_thread_rwlock_locker_v1_t get_thread_rwlock_locker; get_thread_cond_locker_v1_t get_thread_cond_locker; diff --git a/include/mysql_com.h b/include/mysql_com.h index 3f1ac948423..e4e34141d43 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -33,6 +33,14 @@ #define SQLSTATE_LENGTH 5 /* + Maximum length of comments +*/ +#define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 characters */ +#define TABLE_COMMENT_MAXLEN 2048 +#define COLUMN_COMMENT_MAXLEN 1024 +#define INDEX_COMMENT_MAXLEN 1024 + +/* USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain username and hostname parts of the user identifier with trailing zero in MySQL standard format: diff --git a/include/thr_lock.h b/include/thr_lock.h index d669d2dd2ab..1f4072ca0c5 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -83,7 +83,6 @@ enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1, extern ulong max_write_lock_count; -extern ulong table_lock_wait_timeout; extern my_bool thr_lock_inited; extern enum thr_lock_type thr_upgraded_concurrent_insert_lock; @@ -156,19 +155,25 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *status_param); enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, - enum thr_lock_type lock_type); + enum thr_lock_type lock_type, + ulong lock_wait_timeout); void thr_unlock(THR_LOCK_DATA *data); enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data, - uint count, THR_LOCK_OWNER *owner); + uint count, THR_LOCK_OWNER *owner, + ulong lock_wait_timeout); void thr_multi_unlock(THR_LOCK_DATA **data,uint count); +void +thr_lock_merge_status(THR_LOCK_DATA **data, uint count); void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock); my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread); void thr_print_locks(void); /* For debugging */ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data, - enum thr_lock_type new_lock_type); + enum thr_lock_type new_lock_type, + ulong lock_wait_timeout); void thr_downgrade_write_lock(THR_LOCK_DATA *data, enum thr_lock_type new_lock_type); -my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data); +my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data, + ulong lock_wait_timeout); #ifdef __cplusplus } #endif |