Skip to content

Commit 4fe65ca

Browse files
committed
MDEV-12230 include/my_sys.h:600:43: error: unknown type name ‘PSI_file_key’" when -DWITHOUT_SERVER=1
cherry-pick 2c2bd8c (MDEV-12261 build failure without P_S) from 10.0
1 parent 0001049 commit 4fe65ca

File tree

7 files changed

+61
-17
lines changed

7 files changed

+61
-17
lines changed

include/my_sys.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ extern File my_create_with_symlink(const char *linkname, const char *filename,
580580
myf MyFlags);
581581
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
582582
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
583-
extern int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
584-
const char *ext, myf sync_dir);
583+
extern int my_handler_delete_with_symlink(const char *filename, myf sync_dir);
585584

586585
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
587586
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,

include/mysql/psi/mysql_file.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,20 @@
434434
inline_mysql_file_create_with_symlink(P1, P2, P3, P4, P5)
435435
#endif
436436

437+
/**
438+
@def mysql_file_delete_with_symlink(K, P1, P2, P3)
439+
Instrumented delete with symbolic link.
440+
@c mysql_file_delete_with_symlink is a replacement
441+
for @c my_handler_delete_with_symlink.
442+
*/
443+
#ifdef HAVE_PSI_INTERFACE
444+
#define mysql_file_delete_with_symlink(K, P1, P2, P3) \
445+
inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
446+
#else
447+
#define mysql_file_delete_with_symlink(K, P1, P2, P3) \
448+
inline_mysql_file_delete_with_symlink(P1, P2, P3)
449+
#endif
450+
437451
/**
438452
@def mysql_file_rename_with_symlink(K, P1, P2, P3)
439453
Instrumented rename with symbolic link.
@@ -1305,6 +1319,7 @@ inline_mysql_file_rename(
13051319
return result;
13061320
}
13071321

1322+
13081323
static inline File
13091324
inline_mysql_file_create_with_symlink(
13101325
#ifdef HAVE_PSI_INTERFACE
@@ -1334,6 +1349,38 @@ inline_mysql_file_create_with_symlink(
13341349
return file;
13351350
}
13361351

1352+
static inline int
1353+
inline_mysql_file_delete_with_symlink(
1354+
#ifdef HAVE_PSI_INTERFACE
1355+
PSI_file_key key, const char *src_file, uint src_line,
1356+
#endif
1357+
const char *name, const char *ext, myf flags)
1358+
{
1359+
int result;
1360+
char fullname[FN_REFLEN];
1361+
#ifdef HAVE_PSI_INTERFACE
1362+
struct PSI_file_locker *locker= NULL;
1363+
PSI_file_locker_state state;
1364+
#endif
1365+
fn_format(fullname, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
1366+
#ifdef HAVE_PSI_INTERFACE
1367+
if (likely(PSI_server != NULL))
1368+
{
1369+
locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE,
1370+
fullname, &locker);
1371+
if (likely(locker != NULL))
1372+
PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
1373+
}
1374+
#endif
1375+
result= my_handler_delete_with_symlink(fullname, flags);
1376+
#ifdef HAVE_PSI_INTERFACE
1377+
if (likely(locker != NULL))
1378+
PSI_server->end_file_wait(locker, (size_t) 0);
1379+
#endif
1380+
return result;
1381+
}
1382+
1383+
13371384
static inline int
13381385
inline_mysql_file_rename_with_symlink(
13391386
#ifdef HAVE_PSI_INTERFACE

mysys/my_symlink2.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,20 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
170170
in this case both the symlink and the symlinked file are deleted,
171171
but only if the symlinked file is not in the datadir.
172172
*/
173-
int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
174-
const char *ext, myf sync_dir)
173+
int my_handler_delete_with_symlink(const char *filename, myf sync_dir)
175174
{
176-
char orig[FN_REFLEN], real[FN_REFLEN];
175+
char real[FN_REFLEN];
177176
int res= 0;
178177
DBUG_ENTER("my_handler_delete_with_symlink");
179178

180-
fn_format(orig, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
181-
if (my_is_symlink(orig))
179+
if (my_is_symlink(filename))
182180
{
183181
/*
184182
Delete the symlinked file only if the symlink is not
185183
pointing into datadir.
186184
*/
187-
if (!(my_realpath(real, orig, MYF(0)) || mysys_test_invalid_symlink(real)))
188-
res= mysql_file_delete(key, real, MYF(MY_NOSYMLINKS | MY_WME | sync_dir));
185+
if (!(my_realpath(real, filename, MYF(0)) || mysys_test_invalid_symlink(real)))
186+
res= my_delete(real, MYF(MY_NOSYMLINKS | sync_dir));
189187
}
190-
DBUG_RETURN(mysql_file_delete(key, orig, MYF(MY_WME | sync_dir)) || res);
188+
DBUG_RETURN(my_delete(filename, MYF(sync_dir)) || res);
191189
}

sql/handler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3381,7 +3381,7 @@ int handler::delete_table(const char *name)
33813381

33823382
for (const char **ext=bas_ext(); *ext ; ext++)
33833383
{
3384-
if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0))
3384+
if (mysql_file_delete_with_symlink(key_file_misc, name, *ext, 0))
33853385
{
33863386
if (my_errno != ENOENT)
33873387
{

sql/sql_db.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
10851085
We ignore ENOENT error in order to skip files that was deleted
10861086
by concurrently running statement like REPAIR TABLE ...
10871087
*/
1088-
if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) &&
1088+
if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) &&
10891089
my_errno != ENOENT)
10901090
{
10911091
my_error(EE_DELETE, MYF(0), filePath, my_errno);
@@ -1206,7 +1206,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
12061206
continue;
12071207
}
12081208
strxmov(filePath, org_path, "/", file->name, NullS);
1209-
if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME)))
1209+
if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME)))
12101210
{
12111211
goto err;
12121212
}

storage/maria/ma_delete_table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ int maria_delete_table_files(const char *name, myf sync_dir)
8686
{
8787
DBUG_ENTER("maria_delete_table_files");
8888

89-
if (my_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) ||
90-
my_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir))
89+
if (mysql_file_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) ||
90+
mysql_file_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir))
9191
DBUG_RETURN(my_errno);
9292
DBUG_RETURN(0);
9393
}

storage/myisam/mi_delete_table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ int mi_delete_table(const char *name)
2828
check_table_is_closed(name,"delete");
2929
#endif
3030

31-
if (my_handler_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) ||
32-
my_handler_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0))
31+
if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) ||
32+
mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0))
3333
DBUG_RETURN(my_errno);
3434
DBUG_RETURN(0);
3535
}

0 commit comments

Comments
 (0)