Lines 1-236
Link Here
|
1 |
From 2c2bd8c1556b081fccd0fc3e010dc3ea2c38fffb Mon Sep 17 00:00:00 2001 |
|
|
2 |
From: Sergei Golubchik <serg@mariadb.org> |
3 |
Date: Wed, 15 Mar 2017 11:46:54 +0100 |
4 |
Subject: [PATCH] MDEV-12261 build failure without P_S |
5 |
|
6 |
restore mysql_file_delete_with_symlink() but let it use |
7 |
new my_handler_delete_with_symlink() mysys helper. |
8 |
--- |
9 |
include/my_sys.h | 3 +-- |
10 |
include/mysql/psi/mysql_file.h | 44 ++++++++++++++++++++++++++++++++++++++++ |
11 |
mysys/my_symlink2.c | 14 ++++++------- |
12 |
sql/handler.cc | 2 +- |
13 |
sql/sql_db.cc | 6 +++--- |
14 |
sql/table.cc | 2 +- |
15 |
storage/maria/ma_delete_table.c | 8 ++++---- |
16 |
storage/myisam/mi_delete_table.c | 8 ++++---- |
17 |
8 files changed, 64 insertions(+), 23 deletions(-) |
18 |
|
19 |
diff --git a/include/my_sys.h b/include/my_sys.h |
20 |
index 4e129cc..5b0a114 100644 |
21 |
--- include/my_sys.h.orig |
22 |
+++ include/my_sys.h |
23 |
@@ -597,8 +597,7 @@ extern File my_create_with_symlink(const char *linkname, const char *filename, |
24 |
myf MyFlags); |
25 |
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); |
26 |
extern int my_symlink(const char *content, const char *linkname, myf MyFlags); |
27 |
-extern int my_handler_delete_with_symlink(PSI_file_key key, const char *name, |
28 |
- const char *ext, myf sync_dir); |
29 |
+extern int my_handler_delete_with_symlink(const char *filename, myf sync_dir); |
30 |
|
31 |
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags); |
32 |
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset, |
33 |
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h |
34 |
index aca66bd..df94603 100644 |
35 |
--- include/mysql/psi/mysql_file.h.orig |
36 |
+++ include/mysql/psi/mysql_file.h |
37 |
@@ -442,6 +442,20 @@ |
38 |
#endif |
39 |
|
40 |
/** |
41 |
+ @def mysql_file_delete_with_symlink(K, P1, P2, P3) |
42 |
+ Instrumented delete with symbolic link. |
43 |
+ @c mysql_file_delete_with_symlink is a replacement |
44 |
+ for @c my_handler_delete_with_symlink. |
45 |
+*/ |
46 |
+#ifdef HAVE_PSI_FILE_INTERFACE |
47 |
+ #define mysql_file_delete_with_symlink(K, P1, P2, P3) \ |
48 |
+ inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2, P3) |
49 |
+#else |
50 |
+ #define mysql_file_delete_with_symlink(K, P1, P2, P3) \ |
51 |
+ inline_mysql_file_delete_with_symlink(P1, P2, P3) |
52 |
+#endif |
53 |
+ |
54 |
+/** |
55 |
@def mysql_file_rename_with_symlink(K, P1, P2, P3) |
56 |
Instrumented rename with symbolic link. |
57 |
@c mysql_file_rename_with_symlink is a replacement |
58 |
@@ -1294,6 +1308,7 @@ inline_mysql_file_rename( |
59 |
return result; |
60 |
} |
61 |
|
62 |
+ |
63 |
static inline File |
64 |
inline_mysql_file_create_with_symlink( |
65 |
#ifdef HAVE_PSI_FILE_INTERFACE |
66 |
@@ -1325,6 +1340,35 @@ inline_mysql_file_create_with_symlink( |
67 |
|
68 |
|
69 |
static inline int |
70 |
+inline_mysql_file_delete_with_symlink( |
71 |
+#ifdef HAVE_PSI_FILE_INTERFACE |
72 |
+ PSI_file_key key, const char *src_file, uint src_line, |
73 |
+#endif |
74 |
+ const char *name, const char *ext, myf flags) |
75 |
+{ |
76 |
+ int result; |
77 |
+ char fullname[FN_REFLEN]; |
78 |
+ fn_format(fullname, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); |
79 |
+#ifdef HAVE_PSI_FILE_INTERFACE |
80 |
+ struct PSI_file_locker *locker; |
81 |
+ PSI_file_locker_state state; |
82 |
+ locker= PSI_FILE_CALL(get_thread_file_name_locker) |
83 |
+ (&state, key, PSI_FILE_DELETE, fullname, &locker); |
84 |
+ if (likely(locker != NULL)) |
85 |
+ { |
86 |
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line); |
87 |
+ result= my_handler_delete_with_symlink(fullname, flags); |
88 |
+ PSI_FILE_CALL(end_file_close_wait)(locker, result); |
89 |
+ return result; |
90 |
+ } |
91 |
+#endif |
92 |
+ |
93 |
+ result= my_handler_delete_with_symlink(fullname, flags); |
94 |
+ return result; |
95 |
+} |
96 |
+ |
97 |
+ |
98 |
+static inline int |
99 |
inline_mysql_file_rename_with_symlink( |
100 |
#ifdef HAVE_PSI_FILE_INTERFACE |
101 |
PSI_file_key key, const char *src_file, uint src_line, |
102 |
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c |
103 |
index defcb59..c851468 100644 |
104 |
--- mysys/my_symlink2.c.orig |
105 |
+++ mysys/my_symlink2.c |
106 |
@@ -170,22 +170,20 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) |
107 |
in this case both the symlink and the symlinked file are deleted, |
108 |
but only if the symlinked file is not in the datadir. |
109 |
*/ |
110 |
-int my_handler_delete_with_symlink(PSI_file_key key, const char *name, |
111 |
- const char *ext, myf sync_dir) |
112 |
+int my_handler_delete_with_symlink(const char *filename, myf sync_dir) |
113 |
{ |
114 |
- char orig[FN_REFLEN], real[FN_REFLEN]; |
115 |
+ char real[FN_REFLEN]; |
116 |
int res= 0; |
117 |
DBUG_ENTER("my_handler_delete_with_symlink"); |
118 |
|
119 |
- fn_format(orig, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); |
120 |
- if (my_is_symlink(orig)) |
121 |
+ if (my_is_symlink(filename)) |
122 |
{ |
123 |
/* |
124 |
Delete the symlinked file only if the symlink is not |
125 |
pointing into datadir. |
126 |
*/ |
127 |
- if (!(my_realpath(real, orig, MYF(0)) || mysys_test_invalid_symlink(real))) |
128 |
- res= mysql_file_delete(key, real, MYF(MY_NOSYMLINKS | sync_dir)); |
129 |
+ if (!(my_realpath(real, filename, MYF(0)) || mysys_test_invalid_symlink(real))) |
130 |
+ res= my_delete(real, MYF(MY_NOSYMLINKS | sync_dir)); |
131 |
} |
132 |
- DBUG_RETURN(mysql_file_delete(key, orig, MYF(sync_dir)) || res); |
133 |
+ DBUG_RETURN(my_delete(filename, MYF(sync_dir)) || res); |
134 |
} |
135 |
diff --git a/sql/handler.cc b/sql/handler.cc |
136 |
index 7fa8afd..fc70ed5 100644 |
137 |
--- sql/handler.cc.orig |
138 |
+++ sql/handler.cc |
139 |
@@ -3850,7 +3850,7 @@ int handler::delete_table(const char *name) |
140 |
|
141 |
for (const char **ext=bas_ext(); *ext ; ext++) |
142 |
{ |
143 |
- if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0)) |
144 |
+ if (mysql_file_delete_with_symlink(key_file_misc, name, *ext, 0)) |
145 |
{ |
146 |
if (my_errno != ENOENT) |
147 |
{ |
148 |
diff --git a/sql/sql_db.cc b/sql/sql_db.cc |
149 |
index 3f43a33..6c8c384 100644 |
150 |
--- sql/sql_db.cc.orig |
151 |
+++ sql/sql_db.cc |
152 |
@@ -815,7 +815,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) |
153 |
if there exists a table with the name 'db', so let's just do it |
154 |
separately. We know this file exists and needs to be deleted anyway. |
155 |
*/ |
156 |
- if (my_handler_delete_with_symlink(key_file_misc, path, "", MYF(0)) && |
157 |
+ if (mysql_file_delete_with_symlink(key_file_misc, path, "", MYF(0)) && |
158 |
my_errno != ENOENT) |
159 |
{ |
160 |
my_error(EE_DELETE, MYF(0), path, my_errno); |
161 |
@@ -1119,7 +1119,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, |
162 |
We ignore ENOENT error in order to skip files that was deleted |
163 |
by concurrently running statement like REPAIR TABLE ... |
164 |
*/ |
165 |
- if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) && |
166 |
+ if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) && |
167 |
my_errno != ENOENT) |
168 |
{ |
169 |
my_error(EE_DELETE, MYF(0), filePath, my_errno); |
170 |
@@ -1235,7 +1235,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path) |
171 |
continue; |
172 |
} |
173 |
strxmov(filePath, org_path, "/", file->name, NullS); |
174 |
- if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME))) |
175 |
+ if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME))) |
176 |
{ |
177 |
goto err; |
178 |
} |
179 |
diff --git a/sql/table.cc b/sql/table.cc |
180 |
index 80d0e02..975d9d5 100644 |
181 |
--- sql/table.cc.orig |
182 |
+++ sql/table.cc |
183 |
@@ -569,7 +569,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags) |
184 |
{ |
185 |
DBUG_ASSERT(flags & GTS_TABLE); |
186 |
DBUG_ASSERT(flags & GTS_USE_DISCOVERY); |
187 |
- my_handler_delete_with_symlink(key_file_frm, path, "", MYF(0)); |
188 |
+ mysql_file_delete_with_symlink(key_file_frm, path, "", MYF(0)); |
189 |
file= -1; |
190 |
} |
191 |
else |
192 |
diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c |
193 |
index a9ab8e5..186075d 100644 |
194 |
--- storage/maria/ma_delete_table.c.orig |
195 |
+++ storage/maria/ma_delete_table.c |
196 |
@@ -86,13 +86,13 @@ int maria_delete_table_files(const char |
197 |
{ |
198 |
DBUG_ENTER("maria_delete_table_files"); |
199 |
|
200 |
- if (my_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, MYF(MY_WME | sync_dir)) || |
201 |
- my_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, MYF(MY_WME | sync_dir))) |
202 |
+ if (mysql_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, MYF(MY_WME | sync_dir)) || |
203 |
+ mysql_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, MYF(MY_WME | sync_dir))) |
204 |
DBUG_RETURN(my_errno); |
205 |
|
206 |
if (!temporary) { |
207 |
- my_handler_delete_with_symlink(key_file_dfile, name, ".TMD", MYF(0)); |
208 |
- my_handler_delete_with_symlink(key_file_dfile, name, ".OLD", MYF(0)); |
209 |
+ mysql_handler_delete_with_symlink(key_file_dfile, name, ".TMD", MYF(0)); |
210 |
+ mysql_handler_delete_with_symlink(key_file_dfile, name, ".OLD", MYF(0)); |
211 |
} |
212 |
DBUG_RETURN(0); |
213 |
} |
214 |
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c |
215 |
index 3422e6b..d766fb2 100644 |
216 |
--- storage/myisam/mi_delete_table.c.orig |
217 |
+++ storage/myisam/mi_delete_table.c |
218 |
@@ -34,14 +34,14 @@ int mi_delete_table(const char *name) |
219 |
check_table_is_closed(name,"delete"); |
220 |
#endif |
221 |
|
222 |
- if (my_handler_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, MYF(MY_WME)) || |
223 |
- my_handler_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, MYF(MY_WME))) |
224 |
+ if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, MYF(MY_WME)) || |
225 |
+ mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, MYF(MY_WME))) |
226 |
DBUG_RETURN(my_errno); |
227 |
|
228 |
|
229 |
// optionally present: |
230 |
- my_handler_delete_with_symlink(mi_key_file_dfile, name, ".OLD", MYF(0)); |
231 |
- my_handler_delete_with_symlink(mi_key_file_dfile, name, ".TMD", MYF(0)); |
232 |
+ mysql_file_delete_with_symlink(mi_key_file_dfile, name, ".OLD", MYF(0)); |
233 |
+ mysql_file_delete_with_symlink(mi_key_file_dfile, name, ".TMD", MYF(0)); |
234 |
|
235 |
DBUG_RETURN(0); |
236 |
} |