| 2123 | |
| 2124 | |
| 2125 | bool check_db_dir_existence(const char *db_name) |
| 2126 | { |
| 2127 | char db_dir_path[FN_REFLEN + 1]; |
| 2128 | uint db_dir_path_len; |
| 2129 | |
| 2130 | if (dbname_cache->contains(db_name)) |
| 2131 | return 0; |
| 2132 | |
| 2133 | db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path) - 1, |
| 2134 | db_name, "", "", 0); |
| 2135 | |
| 2136 | if (db_dir_path_len && db_dir_path[db_dir_path_len - 1] == FN_LIBCHAR) |
| 2137 | db_dir_path[db_dir_path_len - 1]= 0; |
| 2138 | |
| 2139 | /* |
| 2140 | Check access. |
| 2141 | |
| 2142 | The locking is to prevent creating permanent stale |
| 2143 | entries for deleted databases, in case of |
| 2144 | race condition with my_rmdir. |
| 2145 | */ |
| 2146 | mysql_rwlock_rdlock(&rmdir_lock); |
| 2147 | int ret= my_access(db_dir_path, F_OK); |
| 2148 | if (!ret) |
| 2149 | dbname_cache->insert(db_name); |
| 2150 | mysql_rwlock_unlock(&rmdir_lock); |
| 2151 | return ret; |
| 2152 | } |
no test coverage detected