summaryrefslogtreecommitdiffstats
path: root/databases/mariadb55-server/files/patch-MDEV-12230
blob: 1a7b2b48347f1c2788bd79b032bfbab18b1cdb0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
From 4fe65ca33a6012ec60c665f6eeb5ff08969fb267 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik <serg@mariadb.org>
Date: Tue, 18 Apr 2017 12:35:05 +0200
Subject: [PATCH] =?UTF-8?q?MDEV-12230=20include/my=5Fsys.h:600:43:=20error?=
 =?UTF-8?q?:=20unknown=20type=20name=20=E2=80=98PSI=5Ffile=5Fkey=E2=80=99"?=
 =?UTF-8?q?=20when=20-DWITHOUT=5FSERVER=3D1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

cherry-pick 2c2bd8c155 (MDEV-12261 build failure without P_S) from 10.0
---
 include/my_sys.h                 |  3 +--
 include/mysql/psi/mysql_file.h   | 47 ++++++++++++++++++++++++++++++++++++++++
 mysys/my_symlink2.c              | 14 +++++-------
 sql/handler.cc                   |  2 +-
 sql/sql_db.cc                    |  4 ++--
 storage/maria/ma_delete_table.c  |  4 ++--
 storage/myisam/mi_delete_table.c |  4 ++--
 7 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/include/my_sys.h b/include/my_sys.h
index 10551e1..2794068 100644
--- include/my_sys.h.orig
+++ include/my_sys.h
@@ -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,
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index 4a0f3fd..aa3ed7e 100644
--- include/mysql/psi/mysql_file.h.orig
+++ include/mysql/psi/mysql_file.h
@@ -435,6 +435,20 @@
 #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.
   @c mysql_file_rename_with_symlink is a replacement
@@ -1305,6 +1319,7 @@ inline_mysql_file_rename(
   return result;
 }
 
+
 static inline File
 inline_mysql_file_create_with_symlink(
 #ifdef HAVE_PSI_INTERFACE
@@ -1335,6 +1350,38 @@ inline_mysql_file_create_with_symlink(
 }
 
 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
   PSI_file_key key, const char *src_file, uint src_line,
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index 5fe7b8f..c851468 100644
--- mysys/my_symlink2.c.orig
+++ mysys/my_symlink2.c
@@ -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);
 }
diff --git a/sql/handler.cc b/sql/handler.cc
index 2ae144a..dc40e34 100644
--- sql/handler.cc.orig
+++ sql/handler.cc
@@ -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)
       {
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 7bb4f0f..580590b 100644
--- sql/sql_db.cc.orig
+++ sql/sql_db.cc
@@ -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);
@@ -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;
     }
diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c
index c4bcd5b..f80ec13 100644
--- storage/maria/ma_delete_table.c.orig
+++ storage/maria/ma_delete_table.c
@@ -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);
 }
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c
index ebedfbd..ca395ff 100644
--- storage/myisam/mi_delete_table.c.orig
+++ storage/myisam/mi_delete_table.c
@@ -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);
 }
OpenPOWER on IntegriCloud