summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-07-20 19:26:31 +0300
committerMonty <monty@mariadb.org>2020-07-23 10:54:33 +0300
commitdbcd3384e0799ee99a966edaff2c0f135ef51a29 (patch)
tree9beee5052a706dd721c044edf0de971f868d15e3 /include
parent46ffd47f422147cd748119eba19ad248bd7356db (diff)
downloadmariadb-git-dbcd3384e0799ee99a966edaff2c0f135ef51a29.tar.gz
MDEV-7947 strcmp() takes 0.37% in OLTP RO
This patch ensures that all identical character sets shares the same cs->csname. This allows us to replace strcmp() in my_charset_same() with comparisons of pointers. This fixes a long standing performance issue that could cause as strcmp() for every item sent trough the protocol class to the end user. One consequence of this patch is that we don't allow one to add a character definition in the Index.xml file that changes the csname of an existing character set. This is by design as changing character set names of existing ones is extremely dangerous, especially as some storage engines just records character set numbers. As we now have a hash over character set's csname, we can in the future use that for faster access to a specific character set. This could be done by changing the hash to non unique and use the hash to find the next character set with same csname.
Diffstat (limited to 'include')
-rw-r--r--include/my_sys.h6
-rw-r--r--include/mysys_err.h3
2 files changed, 7 insertions, 2 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index 29d019d96b8..3acc1487f95 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1049,9 +1049,13 @@ extern my_bool resolve_collation(const char *cl_name,
CHARSET_INFO **cl);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
-extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
+static inline my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2)
+{
+ return (cs1->csname == cs2->csname);
+}
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(struct charset_info_st *cs);
+extern void add_compiled_extra_collation(struct charset_info_st *cs);
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
const char *from, size_t length);
diff --git a/include/mysys_err.h b/include/mysys_err.h
index 08463c9fedb..e0e97d0284a 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -72,7 +72,8 @@ extern const char *globerrs[]; /* my_error_messages is here */
#define EE_BADMEMORYRELEASE 36
#define EE_PERM_LOCK_MEMORY 37
#define EE_MEMCNTL 38
-#define EE_ERROR_LAST 38 /* Copy last error nr */
+#define EE_DUPLICATE_CHARSET 39
+#define EE_ERROR_LAST 39 /* Copy last error nr */
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */