134
135
return (*str != '\0');
137
/***************************************************************************
138
** List all table types supported
139
***************************************************************************/
144
* Find files in a given directory.
141
* Find subdirectories (schemas) in a given directory (datadir).
146
143
* @param[in] session Thread handler
147
* @param[out] files Put found files in this list
148
* @param[in] db Used in error message when directory is not found
144
* @param[out] files Put found entries in this list
149
145
* @param[in] path Path to database
150
* @param[in] wild Filter for found files
151
* @param[in] dir Read databases in path if true, read .frm files in
146
* @param[in] wild Filter for found entries
154
* @retval FIND_FILES_OK Success
155
* @retval FIND_FILES_OOM Out of memory error
156
* @retval FIND_FILES_DIR No such directory or directory can't be read
148
* @retval false Success
158
find_files_result find_files(Session *session, vector<LEX_STRING*> &files,
159
const char *db, const char *path, const char *wild,
151
static bool find_schemas(Session *session, vector<LEX_STRING*> &files,
152
const char *path, const char *wild)
162
154
if (wild && (wild[0] == '\0'))
165
MY_DIR *dirp= my_dir(path, MYF(dir ? MY_WANT_STAT : 0));
157
CachedDirectory directory(path);
159
if (directory.fail())
168
if (my_errno == ENOENT)
169
my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db);
171
my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno);
173
return(FIND_FILES_DIR);
161
my_errno= directory.getError();
162
my_error(ER_CANT_READ_DIR, MYF(0), path, my_errno);
176
for (unsigned i= 0; i < dirp->number_off_files; i++)
166
CachedDirectory::Entries entries= directory.getEntries();
167
CachedDirectory::Entries::iterator entry_iter= entries.begin();
169
while (entry_iter != entries.end())
178
171
uint32_t file_name_len;
179
172
char uname[NAME_LEN + 1]; /* Unencoded name */
180
FILEINFO *file= dirp->dir_entry+i;
183
{ /* Return databases */
184
if ((file->name[0] == '.' &&
185
((file->name[1] == '.' && file->name[2] == '\0') ||
186
file->name[1] == '\0')))
187
continue; /* . or .. */
189
if (!S_ISDIR(file->mystat->st_mode))
192
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
193
if (wild && wild_compare(uname, wild, 0))
198
// Return only .frm files which aren't temp files.
199
char *ext= fn_rext(file->name);
200
if (my_strcasecmp(system_charset_info, ext, ".dfe") ||
201
is_prefix(file->name, TMP_FILE_PREFIX))
205
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
208
if (wild_case_compare(files_charset_info, uname, wild))
173
struct stat entry_stat;
174
CachedDirectory::Entry *entry= *entry_iter;
176
if ((entry->filename == ".") || (entry->filename == ".."))
182
if (stat(entry->filename.c_str(), &entry_stat))
185
my_error(ER_CANT_GET_STAT, MYF(0), entry->filename.c_str(), my_errno);
189
if (! S_ISDIR(entry_stat.st_mode))
195
file_name_len= filename_to_tablename(entry->filename.c_str(), uname,
197
if (wild && wild_compare(uname, wild, 0))
213
203
LEX_STRING *file_name= 0;
214
204
file_name= session->make_lex_string(file_name, uname, file_name_len, true);
215
205
if (file_name == NULL)
218
return(FIND_FILES_OOM);
221
208
files.push_back(file_name);
226
return(FIND_FILES_OK);
2114
2125
lex->sql_command= SQLCOM_SHOW_FIELDS;
2115
2126
show_table_list->i_s_requested_object=
2116
2127
schema_table->getRequestedObject();
2117
res= session->open_normal_and_derived_tables(show_table_list, DRIZZLE_LOCK_IGNORE_FLUSH);
2128
res= session->openTables(show_table_list, DRIZZLE_LOCK_IGNORE_FLUSH);
2118
2129
lex->sql_command= save_sql_command;
2120
2131
XXX-> show_table_list has a flag i_is_requested,
2121
and when it's set, open_normal_and_derived_tables()
2132
and when it's set, openTables()
2122
2133
can return an error without setting an error message
2123
2134
in Session, which is a hack. This is why we have to
2124
2135
check for res, then for session->is_error() only then