mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge bodhi.local:/opt/local/work/tmp_merge
into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-im_options_set.result~59278f56be61d921: Auto merged BitKeeper/deleted/.del-mysqld.dsp~ffdbf2d234e23e56: Auto merged BitKeeper/deleted/.del-mysys.dsp~32695fee91189326: Auto merged BitKeeper/deleted/.del-im_options_set.imtest~b53d9d60e5684833: Auto merged BitKeeper/deleted/.del-im_options_unset.imtest~768eb186b51d0048: Auto merged BitKeeper/deleted/.del-im_options_unset.result~20a4790cd3c70a4f: Auto merged client/mysql.cc: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqlcheck.c: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged dbug/dbug.c: Auto merged extra/perror.c: Auto merged extra/yassl/src/yassl_imp.cpp: Auto merged extra/yassl/src/yassl_int.cpp: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged libmysql/libmysql.c: Auto merged mysql-test/r/cast.result: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/federated.result: Auto merged mysql-test/r/func_compress.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/gis-rtree.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/im_daemon_life_cycle.result: Auto merged mysql-test/r/im_utils.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/mysqlcheck.result: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/rpl_trigger.result: Auto merged mysql-test/r/sp-code.result: Auto merged mysql-test/r/sp-security.result: Auto merged mysql-test/r/strict.result: Auto merged mysql-test/r/type_blob.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/r/type_ranges.result: Auto merged mysql-test/r/udf.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/t/cast.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/im_life_cycle.imtest: Auto merged mysql-test/t/im_utils.imtest: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqlcheck.test: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/rpl_trigger.test: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/strict.test: Auto merged mysql-test/t/udf.test: Auto merged sql/field.cc: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_udf.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged sql-common/my_time.c: Auto merged sql/table.h: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged mysql-test/r/im_life_cycle.result: e use local mysql-test/r/ps.result: use local client/Makefile.am: Manual merge. client/mysqlimport.c: Manual merge. configure.in: Manual merge. mysql-test/mysql-test-run.pl: Manual merge. mysql-test/r/mysqldump.result: Manual merge. mysql-test/r/mysqltest.result: Manual merge. mysql-test/r/ndb_basic.result: Manual merge. mysql-test/r/rpl_view.result: Manual merge. mysql-test/r/show_check.result: Manual merge. mysql-test/r/sp-error.result: Manual merge. mysql-test/r/sp.result: Manual merge. mysql-test/r/union.result: Manual merge. mysql-test/t/mysqldump.test: Manual merge. mysql-test/t/mysqltest.test: Manual merge. mysql-test/t/ndb_basic.test: Manual merge. mysql-test/t/rpl_sp.test: Manual merge. mysql-test/t/rpl_view.test: Manual merge. mysql-test/t/show_check.test: Manual merge. mysql-test/t/sp-error.test: Manual merge. mysql-test/t/sp.test: Manual merge. sql/item_sum.cc: Manual merge. sql/mysql_priv.h: Manual merge. sql/sp_head.cc: Manual merge. sql/sql_db.cc: Manual merge. sql/sql_delete.cc: Manual merge. sql/sql_lex.h: Manual merge. sql/sql_show.cc: Manual merge. sql/sql_table.cc: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_yacc.yy: Manual merge. tests/mysql_client_test.c: Manual merge.
This commit is contained in:
121
sql/sql_show.cc
121
sql/sql_show.cc
@ -455,9 +455,35 @@ bool mysqld_show_column_types(THD *thd)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
const char *wild, bool dir)
|
||||
/*
|
||||
find_files() - find files in a given directory.
|
||||
|
||||
SYNOPSIS
|
||||
find_files()
|
||||
thd thread handler
|
||||
files put found files in this list
|
||||
db database name to set in TABLE_LIST structure
|
||||
path path to database
|
||||
wild filter for found files
|
||||
dir read databases in path if TRUE, read .frm files in
|
||||
database otherwise
|
||||
|
||||
RETURN
|
||||
FIND_FILES_OK success
|
||||
FIND_FILES_OOM out of memory error
|
||||
FIND_FILES_DIR no such directory, or directory can't be read
|
||||
*/
|
||||
|
||||
enum find_files_result {
|
||||
FIND_FILES_OK,
|
||||
FIND_FILES_OOM,
|
||||
FIND_FILES_DIR
|
||||
};
|
||||
|
||||
static
|
||||
find_files_result
|
||||
find_files(THD *thd, List<char> *files, const char *db,
|
||||
const char *path, const char *wild, bool dir)
|
||||
{
|
||||
uint i;
|
||||
char *ext;
|
||||
@ -468,7 +494,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
#endif
|
||||
TABLE_LIST table_list;
|
||||
char tbbuff[FN_REFLEN];
|
||||
DBUG_ENTER("mysql_find_files");
|
||||
DBUG_ENTER("find_files");
|
||||
|
||||
if (wild && !wild[0])
|
||||
wild=0;
|
||||
@ -481,7 +507,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db);
|
||||
else
|
||||
my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno);
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(FIND_FILES_DIR);
|
||||
}
|
||||
|
||||
VOID(tablename_to_filename(tmp_file_prefix, tbbuff, sizeof(tbbuff)));
|
||||
@ -555,7 +581,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
if (files->push_back(thd->strdup(file->name)))
|
||||
{
|
||||
my_dirend(dirp);
|
||||
DBUG_RETURN(-1);
|
||||
DBUG_RETURN(FIND_FILES_OOM);
|
||||
}
|
||||
}
|
||||
DBUG_PRINT("info",("found: %d files", files->elements));
|
||||
@ -563,7 +589,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
|
||||
|
||||
VOID(ha_find_files(thd,db,path,wild,dir,files));
|
||||
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(FIND_FILES_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -657,13 +683,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;
|
||||
@ -692,7 +716,8 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
|
||||
}
|
||||
else
|
||||
{
|
||||
length= build_table_filename(path, sizeof(path), dbname, "", "");
|
||||
(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)
|
||||
{
|
||||
@ -700,14 +725,20 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
|
||||
path[length-1]=0; // remove ending '\'
|
||||
}
|
||||
if (access(path,F_OK))
|
||||
length= build_table_filename(path, sizeof(path), dbname, "", "");
|
||||
found_libchar= 0;
|
||||
if (length && path[length-1] == FN_LIBCHAR)
|
||||
{
|
||||
found_libchar= 1;
|
||||
path[length-1]=0; // remove ending '\'
|
||||
}
|
||||
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));
|
||||
@ -2356,8 +2387,8 @@ enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table)
|
||||
wild string otherwise it's db name;
|
||||
|
||||
RETURN
|
||||
1 error
|
||||
0 success
|
||||
zero success
|
||||
non-zero error
|
||||
*/
|
||||
|
||||
int make_db_list(THD *thd, List<char> *files,
|
||||
@ -2383,8 +2414,8 @@ int make_db_list(THD *thd, List<char> *files,
|
||||
if (files->push_back(thd->strdup(information_schema_name.str)))
|
||||
return 1;
|
||||
}
|
||||
return mysql_find_files(thd, files, NullS, mysql_data_home,
|
||||
idx_field_vals->db_value, 1);
|
||||
return (find_files(thd, files, NullS, mysql_data_home,
|
||||
idx_field_vals->db_value, 1) != FIND_FILES_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2410,7 +2441,8 @@ int make_db_list(THD *thd, List<char> *files,
|
||||
if (files->push_back(thd->strdup(information_schema_name.str)))
|
||||
return 1;
|
||||
*with_i_schema= 1;
|
||||
return mysql_find_files(thd, files, NullS, mysql_data_home, NullS, 1);
|
||||
return (find_files(thd, files, NullS,
|
||||
mysql_data_home, NullS, 1) != FIND_FILES_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -2561,9 +2593,28 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
len= build_table_filename(path, sizeof(path), base_name, "", "");
|
||||
end= path + len;
|
||||
len= FN_LEN - len;
|
||||
if (mysql_find_files(thd, &files, base_name,
|
||||
path, idx_field_vals.table_value, 0))
|
||||
goto err;
|
||||
find_files_result res= find_files(thd, &files, base_name,
|
||||
path, idx_field_vals.table_value, 0);
|
||||
if (res != FIND_FILES_OK)
|
||||
{
|
||||
/*
|
||||
Downgrade errors about problems with database directory to
|
||||
warnings if this is not a 'SHOW' command. Another thread
|
||||
may have dropped database, and we may still have a name
|
||||
for that directory.
|
||||
*/
|
||||
if (res == FIND_FILES_DIR && lex->orig_sql_command == SQLCOM_END)
|
||||
{
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
thd->net.last_errno, thd->net.last_error);
|
||||
thd->clear_error();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (lower_case_table_names)
|
||||
orig_base_name= thd->strdup(base_name);
|
||||
}
|
||||
@ -2679,8 +2730,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;
|
||||
@ -2712,19 +2766,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
(grant_option && !check_grant_db(thd, file_name)))
|
||||
#endif
|
||||
{
|
||||
length= build_table_filename(path, sizeof(path), file_name, "", "");
|
||||
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);
|
||||
}
|
||||
@ -5114,7 +5158,12 @@ bool get_schema_tables_result(JOIN *join)
|
||||
|
||||
if (table_list->schema_table->fill_table(thd, table_list,
|
||||
tab->select_cond))
|
||||
{
|
||||
result= 1;
|
||||
join->error= 1;
|
||||
table_list->is_schema_table_processed= TRUE;
|
||||
break;
|
||||
}
|
||||
table_list->is_schema_table_processed= TRUE;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user