summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@booka.>2006-07-27 17:57:43 +0400
committerunknown <anozdrin/alik@booka.>2006-07-27 17:57:43 +0400
commit3c108584740ca89fb77c7f002c67982abb86651c (patch)
tree3a62fb0611cd97599fba47d89d0a7be1ba566c11 /sql/sql_show.cc
parent49d721d7cff6f613ab3a87fe3065edf16b7288ea (diff)
downloadmariadb-git-3c108584740ca89fb77c7f002c67982abb86651c.tar.gz
Fix for BUG#16211: Stored function return type for strings is ignored.
Fix for BUG#16676: Database CHARSET not used for stored procedures The problem in BUG#16211 is that CHARSET-clause of the return type for stored functions is just ignored. The problem in BUG#16676 is that if character set is not explicitly specified for sp-variable, the server character set is used instead of the database one. The fix has two parts: - always store CHARSET-clause of the return type along with the type definition in mysql.proc.returns column. "Always" means that CHARSET-clause is appended even if it has not been explicitly specified in CREATE FUNCTION statement (this affects BUG#16211 only). Storing CHARSET-clause if it is not specified is essential to avoid changing character set if the database character set is altered in the future. NOTE: this change is not backward compatible with the previous releases. - use database default character set if CHARSET-clause is not explicitly specified (this affects both BUG#16211 and BUG#16676). NOTE: this also breaks backward compatibility. mysql-test/r/mysqldump.result: Updated result file. mysql-test/r/sp.result: Updated result file. mysql-test/t/sp.test: Provided test cases for BUG#16211, BUG#16676. sql/mysql_priv.h: Added two convenient functions for work with databases. sql/sp.cc: 1. Add CHARSET-clause to CREATE-statement if it has been explicitly specified. 2. Polishing -- provided some comments. sql/sp_head.cc: Use database charset as default charset of sp-variable. sql/sp_head.h: Move init_sp_name() out of init_strings(). sql/sql_db.cc: Two new functions created: - load_db_opt_by_name(); - check_db_dir_existence(); sql/sql_show.cc: Eliminate duplicated code by using check_db_dir_existence() and load_db_opt_by_name() sql/sql_table.cc: Eliminate duplicated code by using check_db_dir_existence() and load_db_opt_by_name() sql/sql_yacc.yy: Call sp_head::init_sp_name() to initialize stored routine name.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc40
1 files changed, 10 insertions, 30 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index cabb04c5f16..1a42ef81487 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -439,13 +439,11 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
{
Security_context *sctx= thd->security_ctx;
int length;
- char path[FN_REFLEN];
char buff[2048];
String buffer(buff, sizeof(buff), system_charset_info);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint db_access;
#endif
- bool found_libchar;
HA_CREATE_INFO create;
uint create_options = create_info ? create_info->options : 0;
Protocol *protocol=thd->protocol;
@@ -480,23 +478,13 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
}
else
{
- (void) sprintf(path,"%s/%s",mysql_data_home, dbname);
- length=unpack_dirname(path,path); // Convert if not unix
- found_libchar= 0;
- if (length && path[length-1] == FN_LIBCHAR)
- {
- found_libchar= 1;
- path[length-1]=0; // remove ending '\'
- }
- if (access(path,F_OK))
+ if (check_db_dir_existence(dbname))
{
my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
DBUG_RETURN(TRUE);
}
- if (found_libchar)
- path[length-1]= FN_LIBCHAR;
- strmov(path+length, MY_DB_OPT_FILE);
- load_db_opt(thd, path, &create);
+
+ load_db_opt_by_name(thd, dbname, &create);
}
List<Item> field_list;
field_list.push_back(new Item_empty_string("Database",NAME_LEN));
@@ -2319,8 +2307,11 @@ bool store_schema_shemata(THD* thd, TABLE *table, const char *db_name,
int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
{
- char path[FN_REFLEN];
- bool found_libchar;
+ /*
+ TODO: fill_schema_shemata() is called when new client is connected.
+ Returning error status in this case leads to client hangup.
+ */
+
INDEX_FIELD_VALUES idx_field_vals;
List<char> files;
char *file_name;
@@ -2352,20 +2343,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
(grant_option && !check_grant_db(thd, file_name)))
#endif
{
- strxmov(path, mysql_data_home, "/", file_name, NullS);
- length=unpack_dirname(path,path); // Convert if not unix
- found_libchar= 0;
- if (length && path[length-1] == FN_LIBCHAR)
- {
- found_libchar= 1;
- path[length-1]=0; // remove ending '\'
- }
+ load_db_opt_by_name(thd, file_name, &create);
- if (found_libchar)
- path[length-1]= FN_LIBCHAR;
- strmov(path+length, MY_DB_OPT_FILE);
- load_db_opt(thd, path, &create);
- if (store_schema_shemata(thd, table, file_name,
+ if (store_schema_shemata(thd, table, file_name,
create.default_table_charset))
DBUG_RETURN(1);
}