diff options
author | unknown <anozdrin/alik@ibm.> | 2007-06-14 19:23:55 +0400 |
---|---|---|
committer | unknown <anozdrin/alik@ibm.> | 2007-06-14 19:23:55 +0400 |
commit | 83de46bcf71f05580cf664f02569290a8fa214dd (patch) | |
tree | b54dd9543e107094f780c4a99b8dde4aa0213024 /mysys | |
parent | c7aeb8f37b007dfdd4d5339a7dd4b0083282be4e (diff) | |
download | mariadb-git-83de46bcf71f05580cf664f02569290a8fa214dd.tar.gz |
This the 4-th patch in scope of CS patch (BUG#11986).
The patch contains the following changes:
- Introduce auxilary functions to convenient work with character sets:
- resolve_charset();
- resolve_collation();
- get_default_db_collation();
- Introduce lex_string_set();
- Refactor Table_trigger_list::process_triggers() &
sp_head::execute_trigger() to be consistent with other code;
- Move reusable code from add_table_for_trigger() into
build_trn_path(), check_trn_exists() and load_table_name_for_trigger()
to be used in the following patch.
- Rename triggers_file_ext and trigname_file_ext into TRN_EXT and
TRG_EXT respectively.
include/my_sys.h:
Introduced auxilary functions (to be used in the following patch).
mysys/charset.c:
Introduced auxilary functions (to be used in the following patch).
sql/handler.cc:
Rename triggers_file_ext -> TRG_EXT;
Rename trigname_file_ext -> TRN_EXT.
sql/mysql_priv.h:
1. Fix typo;
2. Introduce auxilary functions (set_lex_string() will be used
in the following patch);
3. Rename triggers_file_ext -> TRG_EXT;
Rename trigname_file_ext -> TRN_EXT.
sql/sp_head.cc:
Make sp_head::execute_trigger() consistent with
sp_head::execute_function() and sp_head::execute_procedure().
sql/sp_head.h:
Make sp_head::execute_trigger() consistent with
sp_head::execute_function() and sp_head::execute_procedure().
sql/sql_db.cc:
1. Introduce auxilary function.
2. Polishing.
sql/sql_trigger.cc:
1. Move common code from add_table_for_trigger() into
- build_trn_path();
- check_trn_exists();
- load_table_name_for_trigger();
2. Polishing.
sql/sql_trigger.h:
1. Move common code from add_table_for_trigger() into
- build_trn_path();
- check_trn_exists();
- load_table_name_for_trigger();
2. Polishing.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/charset.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index c6065f87df3..5f9521eeab8 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -573,6 +573,70 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, } +/** + Resolve character set by the character set name (utf8, latin1, ...). + + The function tries to resolve character set by the specified name. If + there is character set with the given name, it is assigned to the "cs" + parameter and FALSE is returned. If there is no such character set, + "default_cs" is assigned to the "cs" and TRUE is returned. + + @param[out] cs Variable to store character set. + @param[in] cs_name Character set name. + @param[in] default_cs Default character set. + + @return FALSE if character set was resolved successfully; TRUE if there + is no character set with given name. +*/ + +bool resolve_charset(CHARSET_INFO **cs, + const char *cs_name, + CHARSET_INFO *default_cs) +{ + *cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0)); + + if (*cs == NULL) + { + *cs= default_cs; + return TRUE; + } + + return FALSE; +} + + +/** + Resolve collation by the collation name (utf8_general_ci, ...). + + The function tries to resolve collation by the specified name. If there + is collation with the given name, it is assigned to the "cl" parameter + and FALSE is returned. If there is no such collation, "default_cl" is + assigned to the "cl" and TRUE is returned. + + @param[out] cl Variable to store collation. + @param[in] cl_name Collation name. + @param[in] default_cl Default collation. + + @return FALSE if collation was resolved successfully; TRUE if there is no + collation with given name. +*/ + +bool resolve_collation(CHARSET_INFO **cl, + const char *cl_name, + CHARSET_INFO *default_cl) +{ + *cl= get_charset_by_name(cl_name, MYF(0)); + + if (*cl == NULL) + { + *cl= default_cl; + return TRUE; + } + + return FALSE; +} + + /* Escape string with backslashes (\) |