92
92
if (!memcmp(from, TMP_FILE_PREFIX, TMP_FILE_PREFIX_LENGTH))
94
94
/* Temporary table name. */
95
res= (my_stpncpy(to, from, to_length) - to);
95
res= strlen(strncpy(to, from, to_length));
174
174
build_tmptable_filename() for them.
177
path length on success, 0 on failure
180
180
uint32_t build_table_filename(char *buff, size_t bufflen, const char *db,
181
181
const char *table_name, const char *ext, uint32_t flags)
183
std::string table_path;
183
184
char dbbuff[FN_REFLEN];
184
185
char tbbuff[FN_REFLEN];
186
int rootdir_len= strlen(FN_ROOTDIR);
186
188
if (flags & FN_IS_TMP) // FN_FROM_IS_TMP | FN_TO_IS_TMP
187
my_stpncpy(tbbuff, table_name, sizeof(tbbuff));
189
strncpy(tbbuff, table_name, sizeof(tbbuff));
189
191
tablename_to_filename(table_name, tbbuff, sizeof(tbbuff));
191
193
tablename_to_filename(db, dbbuff, sizeof(dbbuff));
194
table_path= drizzle_data_home;
195
int without_rootdir= table_path.length()-rootdir_len;
193
char *end = buff + bufflen;
194
197
/* Don't add FN_ROOTDIR if dirzzle_data_home already includes it */
195
char *pos = my_stpncpy(buff, drizzle_data_home, bufflen);
196
int rootdir_len= strlen(FN_ROOTDIR);
197
if (pos - rootdir_len >= buff &&
198
memcmp(pos - rootdir_len, FN_ROOTDIR, rootdir_len) != 0)
199
pos= my_stpncpy(pos, FN_ROOTDIR, end - pos);
200
pos= my_stpncpy(pos, dbbuff, end-pos);
201
pos= my_stpncpy(pos, FN_ROOTDIR, end-pos);
198
if (without_rootdir >= 0)
200
char *tmp= (char*)table_path.c_str()+without_rootdir;
201
if (memcmp(tmp, FN_ROOTDIR, rootdir_len) != 0)
202
table_path.append(FN_ROOTDIR);
205
table_path.append(dbbuff);
206
table_path.append(FN_ROOTDIR);
202
207
#ifdef USE_SYMDIR
203
unpack_dirname(buff, buff);
206
pos= my_stpncpy(pos, tbbuff, end - pos);
207
pos= my_stpncpy(pos, ext, end - pos);
210
table_path.append(tbbuff);
211
table_path.append(ext);
213
if (bufflen < table_path.length())
216
strcpy(buff, table_path.c_str());
217
return table_path.length();
225
233
a file name in drizzle_tmpdir.
236
path length on success, 0 on failure
231
239
uint32_t build_tmptable_filename(Session* session, char *buff, size_t bufflen)
242
std::ostringstream path_str, post_tmpdir_str;
234
char *p= my_stpncpy(buff, drizzle_tmpdir, bufflen);
235
snprintf(p, bufflen - (p - buff), "/%s%lx_%"PRIx64"_%x%s",
236
TMP_FILE_PREFIX, (unsigned long)current_pid,
237
session->thread_id, session->tmp_table++, reg_ext);
245
path_str << drizzle_tmpdir;
246
post_tmpdir_str << "/" << TMP_FILE_PREFIX << current_pid;
247
post_tmpdir_str << session->thread_id << session->tmp_table++ << reg_ext;
248
tmp= post_tmpdir_str.str();
239
250
if (lower_case_table_names)
241
/* Convert all except tmpdir to lower case */
242
my_casedn_str(files_charset_info, p);
245
uint32_t length= unpack_filename(buff, buff);
251
std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
255
if (bufflen < path_str.str().length())
258
length= unpack_filename(buff, path_str.str().c_str());
4393
4407
uint32_t order_num, order_st *order, bool ignore)
4395
4409
Table *table, *new_table=0, *name_lock= 0;;
4410
std::string new_name_str;
4397
4412
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
4398
4413
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
4428
4443
/* Conditionally writes to binlog. */
4429
4444
return(mysql_discard_or_import_tablespace(session,table_list,
4430
4445
alter_info->tablespace_op));
4431
char* pos= new_name_buff;
4432
char* pos_end= pos+strlen(new_name_buff)-1;
4433
pos= my_stpncpy(new_name_buff, drizzle_data_home, pos_end-pos);
4434
pos= my_stpncpy(new_name_buff, "/", pos_end-pos);
4435
pos= my_stpncpy(new_name_buff, db, pos_end-pos);
4436
pos= my_stpncpy(new_name_buff, "/", pos_end-pos);
4437
pos= my_stpncpy(new_name_buff, table_name, pos_end-pos);
4438
pos= my_stpncpy(new_name_buff, reg_ext, pos_end-pos);
4446
std::ostringstream oss;
4447
oss << drizzle_data_home << "/" << db << "/" << table_name << reg_ext;
4440
(void) unpack_filename(new_name_buff, new_name_buff);
4449
(void) unpack_filename(new_name_buff, oss.str().c_str());
4442
4451
If this is just a rename of a view, short cut to the
4443
4452
following scenario: 1) lock LOCK_open 2) do a RENAME