Skip to content

Commit

Permalink
MDEV-12230 include/my_sys.h:600:43: error: unknown type name ‘PSI_fil…
Browse files Browse the repository at this point in the history
…e_key’" when -DWITHOUT_SERVER=1

cherry-pick 2c2bd8c (MDEV-12261 build failure without P_S) from 10.0
  • Loading branch information
vuvova committed Apr 20, 2017
1 parent 0001049 commit 4fe65ca
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 17 deletions.
3 changes: 1 addition & 2 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,7 @@ extern File my_create_with_symlink(const char *linkname, const char *filename,
myf MyFlags);
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
extern int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
const char *ext, myf sync_dir);
extern int my_handler_delete_with_symlink(const char *filename, myf sync_dir);

extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,
Expand Down
47 changes: 47 additions & 0 deletions include/mysql/psi/mysql_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,20 @@
inline_mysql_file_create_with_symlink(P1, P2, P3, P4, P5)
#endif

/**
@def mysql_file_delete_with_symlink(K, P1, P2, P3)
Instrumented delete with symbolic link.
@c mysql_file_delete_with_symlink is a replacement
for @c my_handler_delete_with_symlink.
*/
#ifdef HAVE_PSI_INTERFACE
#define mysql_file_delete_with_symlink(K, P1, P2, P3) \
inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
#else
#define mysql_file_delete_with_symlink(K, P1, P2, P3) \
inline_mysql_file_delete_with_symlink(P1, P2, P3)
#endif

/**
@def mysql_file_rename_with_symlink(K, P1, P2, P3)
Instrumented rename with symbolic link.
Expand Down Expand Up @@ -1305,6 +1319,7 @@ inline_mysql_file_rename(
return result;
}


static inline File
inline_mysql_file_create_with_symlink(
#ifdef HAVE_PSI_INTERFACE
Expand Down Expand Up @@ -1334,6 +1349,38 @@ inline_mysql_file_create_with_symlink(
return file;
}

static inline int
inline_mysql_file_delete_with_symlink(
#ifdef HAVE_PSI_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *name, const char *ext, myf flags)
{
int result;
char fullname[FN_REFLEN];
#ifdef HAVE_PSI_INTERFACE
struct PSI_file_locker *locker= NULL;
PSI_file_locker_state state;
#endif
fn_format(fullname, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
#ifdef HAVE_PSI_INTERFACE
if (likely(PSI_server != NULL))
{
locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE,
fullname, &locker);
if (likely(locker != NULL))
PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
}
#endif
result= my_handler_delete_with_symlink(fullname, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_file_wait(locker, (size_t) 0);
#endif
return result;
}


static inline int
inline_mysql_file_rename_with_symlink(
#ifdef HAVE_PSI_INTERFACE
Expand Down
14 changes: 6 additions & 8 deletions mysys/my_symlink2.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,20 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
in this case both the symlink and the symlinked file are deleted,
but only if the symlinked file is not in the datadir.
*/
int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
const char *ext, myf sync_dir)
int my_handler_delete_with_symlink(const char *filename, myf sync_dir)
{
char orig[FN_REFLEN], real[FN_REFLEN];
char real[FN_REFLEN];
int res= 0;
DBUG_ENTER("my_handler_delete_with_symlink");

fn_format(orig, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
if (my_is_symlink(orig))
if (my_is_symlink(filename))
{
/*
Delete the symlinked file only if the symlink is not
pointing into datadir.
*/
if (!(my_realpath(real, orig, MYF(0)) || mysys_test_invalid_symlink(real)))
res= mysql_file_delete(key, real, MYF(MY_NOSYMLINKS | MY_WME | sync_dir));
if (!(my_realpath(real, filename, MYF(0)) || mysys_test_invalid_symlink(real)))
res= my_delete(real, MYF(MY_NOSYMLINKS | sync_dir));
}
DBUG_RETURN(mysql_file_delete(key, orig, MYF(MY_WME | sync_dir)) || res);
DBUG_RETURN(my_delete(filename, MYF(sync_dir)) || res);
}
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3381,7 +3381,7 @@ int handler::delete_table(const char *name)

for (const char **ext=bas_ext(); *ext ; ext++)
{
if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0))
if (mysql_file_delete_with_symlink(key_file_misc, name, *ext, 0))
{
if (my_errno != ENOENT)
{
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
We ignore ENOENT error in order to skip files that was deleted
by concurrently running statement like REPAIR TABLE ...
*/
if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) &&
if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) &&
my_errno != ENOENT)
{
my_error(EE_DELETE, MYF(0), filePath, my_errno);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
continue;
}
strxmov(filePath, org_path, "/", file->name, NullS);
if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME)))
if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME)))
{
goto err;
}
Expand Down
4 changes: 2 additions & 2 deletions storage/maria/ma_delete_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int maria_delete_table_files(const char *name, myf sync_dir)
{
DBUG_ENTER("maria_delete_table_files");

if (my_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) ||
my_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir))
if (mysql_file_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) ||
mysql_file_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir))
DBUG_RETURN(my_errno);
DBUG_RETURN(0);
}
4 changes: 2 additions & 2 deletions storage/myisam/mi_delete_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int mi_delete_table(const char *name)
check_table_is_closed(name,"delete");
#endif

if (my_handler_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) ||
my_handler_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0))
if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) ||
mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0))
DBUG_RETURN(my_errno);
DBUG_RETURN(0);
}

0 comments on commit 4fe65ca

Please sign in to comment.