diff options
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 900b5f91f32..f68243ff544 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -745,6 +745,35 @@ typedef struct system_status_var void mark_transaction_to_rollback(THD *thd, bool all); + +/** + Get collation by name, send error to client on failure. + @param name Collation name + @param name_cs Character set of the name string + @return + @retval NULL on error + @retval Pointter to CHARSET_INFO with the given name on success +*/ +inline CHARSET_INFO * +mysqld_collation_get_by_name(const char *name, + CHARSET_INFO *name_cs= system_charset_info) +{ + CHARSET_INFO *cs; + MY_CHARSET_LOADER loader; + my_charset_loader_init_mysys(&loader); + if (!(cs= my_collation_get_by_name(&loader, name, MYF(0)))) + { + ErrConvString err(name, name_cs); + my_error(ER_UNKNOWN_COLLATION, MYF(0), err.ptr()); + if (loader.error[0]) + push_warning_printf(current_thd, + Sql_condition::WARN_LEVEL_WARN, + ER_UNKNOWN_COLLATION, "%s", loader.error); + } + return cs; +} + + #ifdef MYSQL_SERVER void free_tmp_table(THD *thd, TABLE *entry); |