MySQL 8.3.0
Source Code Documentation
mysql_file.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23/**
24 @file include/mysql/psi/mysql_file.h
25 Instrumentation helpers for mysys file io.
26 This header file provides the necessary declarations
27 to use the mysys file API with the performance schema instrumentation.
28 In some compilers (SunStudio), 'static inline' functions, when declared
29 but not used, are not optimized away (because they are unused) by default,
30 so that including a static inline function from a header file does
31 create unwanted dependencies, causing unresolved symbols at link time.
32 Other compilers, like gcc, optimize these dependencies by default.
33
34 Since the instrumented APIs declared here are wrapper on top
35 of mysys file io APIs, including mysql/psi/mysql_file.h assumes that
36 the dependency on my_sys already exists.
37*/
38
39#ifndef MYSQL_FILE_H
40#define MYSQL_FILE_H
41
42/* For strlen() */
43#include <assert.h>
44#include <string.h>
45
46/* HAVE_PSI_*_INTERFACE */
47#include "my_psi_config.h" // IWYU pragma: keep
48
49/* For MY_STAT */
50#include "my_dir.h"
51#include "my_inttypes.h"
52/* For my_chsize */
53#include "my_sys.h"
54#include "mysql/psi/psi_file.h"
56
57#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
58/* PSI_FILE_CALL() as direct call. */
59#include "pfs_file_provider.h" // IWYU pragma: keep
60#endif
61
62#ifndef PSI_FILE_CALL
63#define PSI_FILE_CALL(M) psi_file_service->M
64#endif
65
66/**
67 @defgroup psi_api_file File Instrumentation (API)
68 @ingroup psi_api
69 @{
70*/
71
72/**
73 @def mysql_file_register(P1, P2, P3)
74 File registration.
75*/
76#define mysql_file_register(P1, P2, P3) inline_mysql_file_register(P1, P2, P3)
77
78/**
79 @def mysql_file_fgets(P1, P2, F)
80 Instrumented fgets.
81 @c mysql_file_fgets is a replacement for @c fgets.
82*/
83#ifdef HAVE_PSI_FILE_INTERFACE
84#define mysql_file_fgets(P1, P2, F) \
85 inline_mysql_file_fgets(__FILE__, __LINE__, P1, P2, F)
86#else
87#define mysql_file_fgets(P1, P2, F) inline_mysql_file_fgets(P1, P2, F)
88#endif
89
90/**
91 @def mysql_file_fgetc(F)
92 Instrumented fgetc.
93 @c mysql_file_fgetc is a replacement for @c fgetc.
94*/
95#ifdef HAVE_PSI_FILE_INTERFACE
96#define mysql_file_fgetc(F) inline_mysql_file_fgetc(__FILE__, __LINE__, F)
97#else
98#define mysql_file_fgetc(F) inline_mysql_file_fgetc(F)
99#endif
100
101/**
102 @def mysql_file_fputs(P1, F)
103 Instrumented fputs.
104 @c mysql_file_fputs is a replacement for @c fputs.
105*/
106#ifdef HAVE_PSI_FILE_INTERFACE
107#define mysql_file_fputs(P1, F) \
108 inline_mysql_file_fputs(__FILE__, __LINE__, P1, F)
109#else
110#define mysql_file_fputs(P1, F) inline_mysql_file_fputs(P1, F)
111#endif
112
113/**
114 @def mysql_file_fputc(P1, F)
115 Instrumented fputc.
116 @c mysql_file_fputc is a replacement for @c fputc.
117*/
118#ifdef HAVE_PSI_FILE_INTERFACE
119#define mysql_file_fputc(P1, F) \
120 inline_mysql_file_fputc(__FILE__, __LINE__, P1, F)
121#else
122#define mysql_file_fputc(P1, F) inline_mysql_file_fputc(P1, F)
123#endif
124
125/**
126 @def mysql_file_fprintf
127 Instrumented fprintf.
128 @c mysql_file_fprintf is a replacement for @c fprintf.
129*/
130#define mysql_file_fprintf inline_mysql_file_fprintf
131
132/**
133 @def mysql_file_vfprintf(F, P1, P2)
134 Instrumented vfprintf.
135 @c mysql_file_vfprintf is a replacement for @c vfprintf.
136*/
137#ifdef HAVE_PSI_FILE_INTERFACE
138#define mysql_file_vfprintf(F, P1, P2) \
139 inline_mysql_file_vfprintf(__FILE__, __LINE__, F, P1, P2)
140#else
141#define mysql_file_vfprintf(F, P1, P2) inline_mysql_file_vfprintf(F, P1, P2)
142#endif
143
144/**
145 @def mysql_file_fflush(F, P1, P2)
146 Instrumented fflush.
147 @c mysql_file_fflush is a replacement for @c fflush.
148*/
149#ifdef HAVE_PSI_FILE_INTERFACE
150#define mysql_file_fflush(F) inline_mysql_file_fflush(__FILE__, __LINE__, F)
151#else
152#define mysql_file_fflush(F) inline_mysql_file_fflush(F)
153#endif
154
155/**
156 @def mysql_file_feof(F)
157 Instrumented feof.
158 @c mysql_file_feof is a replacement for @c feof.
159*/
160#define mysql_file_feof(F) inline_mysql_file_feof(F)
161
162/**
163 @def mysql_file_fstat(FN, S)
164 Instrumented fstat.
165 @c mysql_file_fstat is a replacement for @c my_fstat.
166*/
167#ifdef HAVE_PSI_FILE_INTERFACE
168#define mysql_file_fstat(FN, S) \
169 inline_mysql_file_fstat(__FILE__, __LINE__, FN, S)
170#else
171#define mysql_file_fstat(FN, S) inline_mysql_file_fstat(FN, S)
172#endif
173
174/**
175 @def mysql_file_stat(K, FN, S, FL)
176 Instrumented stat.
177 @c mysql_file_stat is a replacement for @c my_stat.
178*/
179#ifdef HAVE_PSI_FILE_INTERFACE
180#define mysql_file_stat(K, FN, S, FL) \
181 inline_mysql_file_stat(K, __FILE__, __LINE__, FN, S, FL)
182#else
183#define mysql_file_stat(K, FN, S, FL) inline_mysql_file_stat(FN, S, FL)
184#endif
185
186/**
187 @def mysql_file_chsize(F, P1, P2, P3)
188 Instrumented chsize.
189 @c mysql_file_chsize is a replacement for @c my_chsize.
190*/
191#ifdef HAVE_PSI_FILE_INTERFACE
192#define mysql_file_chsize(F, P1, P2, P3) \
193 inline_mysql_file_chsize(__FILE__, __LINE__, F, P1, P2, P3)
194#else
195#define mysql_file_chsize(F, P1, P2, P3) inline_mysql_file_chsize(F, P1, P2, P3)
196#endif
197
198/**
199 @def mysql_file_fopen(K, N, F1, F2)
200 Instrumented fopen.
201 @c mysql_file_fopen is a replacement for @c my_fopen.
202*/
203#ifdef HAVE_PSI_FILE_INTERFACE
204#define mysql_file_fopen(K, N, F1, F2) \
205 inline_mysql_file_fopen(K, __FILE__, __LINE__, N, F1, F2)
206#else
207#define mysql_file_fopen(K, N, F1, F2) inline_mysql_file_fopen(N, F1, F2)
208#endif
209
210/**
211 @def mysql_file_fclose(FD, FL)
212 Instrumented fclose.
213 @c mysql_file_fclose is a replacement for @c my_fclose.
214 Without the instrumentation, this call will have the same behavior as the
215 undocumented and possibly platform specific my_fclose(NULL, ...) behavior.
216 With the instrumentation, mysql_fclose(NULL, ...) will safely return 0,
217 which is an extension compared to my_fclose and is therefore compliant.
218 mysql_fclose is on purpose *not* implementing
219 @code assert(file != NULL) @endcode,
220 since doing so could introduce regressions.
221*/
222#ifdef HAVE_PSI_FILE_INTERFACE
223#define mysql_file_fclose(FD, FL) \
224 inline_mysql_file_fclose(__FILE__, __LINE__, FD, FL)
225#else
226#define mysql_file_fclose(FD, FL) inline_mysql_file_fclose(FD, FL)
227#endif
228
229/**
230 @def mysql_file_fread(FD, P1, P2, P3)
231 Instrumented fread.
232 @c mysql_file_fread is a replacement for @c my_fread.
233*/
234#ifdef HAVE_PSI_FILE_INTERFACE
235#define mysql_file_fread(FD, P1, P2, P3) \
236 inline_mysql_file_fread(__FILE__, __LINE__, FD, P1, P2, P3)
237#else
238#define mysql_file_fread(FD, P1, P2, P3) inline_mysql_file_fread(FD, P1, P2, P3)
239#endif
240
241/**
242 @def mysql_file_fwrite(FD, P1, P2, P3)
243 Instrumented fwrite.
244 @c mysql_file_fwrite is a replacement for @c my_fwrite.
245*/
246#ifdef HAVE_PSI_FILE_INTERFACE
247#define mysql_file_fwrite(FD, P1, P2, P3) \
248 inline_mysql_file_fwrite(__FILE__, __LINE__, FD, P1, P2, P3)
249#else
250#define mysql_file_fwrite(FD, P1, P2, P3) \
251 inline_mysql_file_fwrite(FD, P1, P2, P3)
252#endif
253
254/**
255 @def mysql_file_fseek(FD, P, W)
256 Instrumented fseek.
257 @c mysql_file_fseek is a replacement for @c my_fseek.
258*/
259#ifdef HAVE_PSI_FILE_INTERFACE
260#define mysql_file_fseek(FD, P, W) \
261 inline_mysql_file_fseek(__FILE__, __LINE__, FD, P, W)
262#else
263#define mysql_file_fseek(FD, P, W) inline_mysql_file_fseek(FD, P, W)
264#endif
265
266/**
267 @def mysql_file_ftell(FD)
268 Instrumented ftell.
269 @c mysql_file_ftell is a replacement for @c my_ftell.
270*/
271#ifdef HAVE_PSI_FILE_INTERFACE
272#define mysql_file_ftell(FD) inline_mysql_file_ftell(__FILE__, __LINE__, FD)
273#else
274#define mysql_file_ftell(FD) inline_mysql_file_ftell(FD)
275#endif
276
277/**
278 @def mysql_file_create(K, N, F1, F2, F3)
279 Instrumented create.
280 @c mysql_file_create is a replacement for @c my_create.
281*/
282#ifdef HAVE_PSI_FILE_INTERFACE
283#define mysql_file_create(K, N, F1, F2, F3) \
284 inline_mysql_file_create(K, __FILE__, __LINE__, N, F1, F2, F3)
285#else
286#define mysql_file_create(K, N, F1, F2, F3) \
287 inline_mysql_file_create(N, F1, F2, F3)
288#endif
289
290/**
291 @def mysql_file_create_temp(K, T, D, P, M, U, F)
292 Instrumented create_temp_file.
293 @c mysql_file_create_temp is a replacement for @c create_temp_file.
294*/
295#ifdef HAVE_PSI_FILE_INTERFACE
296#define mysql_file_create_temp(K, T, D, P, M, U, F) \
297 inline_mysql_file_create_temp(K, __FILE__, __LINE__, T, D, P, M, U, F)
298#else
299#define mysql_file_create_temp(K, T, D, P, M, U, F) \
300 inline_mysql_file_create_temp(T, D, P, M, U, F)
301#endif
302
303/**
304 @def mysql_file_open(K, N, F1, F2)
305 Instrumented open.
306 @c mysql_file_open is a replacement for @c my_open.
307*/
308#ifdef HAVE_PSI_FILE_INTERFACE
309#define mysql_file_open(K, N, F1, F2) \
310 inline_mysql_file_open(K, __FILE__, __LINE__, N, F1, F2)
311#else
312#define mysql_file_open(K, N, F1, F2) inline_mysql_file_open(N, F1, F2)
313#endif
314
315/**
316 @def mysql_file_close(FD, F)
317 Instrumented close.
318 @c mysql_file_close is a replacement for @c my_close.
319*/
320#ifdef HAVE_PSI_FILE_INTERFACE
321#define mysql_file_close(FD, F) \
322 inline_mysql_file_close(__FILE__, __LINE__, FD, F)
323#else
324#define mysql_file_close(FD, F) inline_mysql_file_close(FD, F)
325#endif
326
327/**
328 @def mysql_file_read(FD, B, S, F)
329 Instrumented read.
330 @c mysql_read is a replacement for @c my_read.
331*/
332#ifdef HAVE_PSI_FILE_INTERFACE
333#define mysql_file_read(FD, B, S, F) \
334 inline_mysql_file_read(__FILE__, __LINE__, FD, B, S, F)
335#else
336#define mysql_file_read(FD, B, S, F) inline_mysql_file_read(FD, B, S, F)
337#endif
338
339/**
340 @def mysql_file_write(FD, B, S, F)
341 Instrumented write.
342 @c mysql_file_write is a replacement for @c my_write.
343*/
344#ifdef HAVE_PSI_FILE_INTERFACE
345#define mysql_file_write(FD, B, S, F) \
346 inline_mysql_file_write(__FILE__, __LINE__, FD, B, S, F)
347#else
348#define mysql_file_write(FD, B, S, F) inline_mysql_file_write(FD, B, S, F)
349#endif
350
351/**
352 @def mysql_file_pread(FD, B, S, O, F)
353 Instrumented pread.
354 @c mysql_pread is a replacement for @c my_pread.
355*/
356#ifdef HAVE_PSI_FILE_INTERFACE
357#define mysql_file_pread(FD, B, S, O, F) \
358 inline_mysql_file_pread(__FILE__, __LINE__, FD, B, S, O, F)
359#else
360#define mysql_file_pread(FD, B, S, O, F) inline_mysql_file_pread(FD, B, S, O, F)
361#endif
362
363/**
364 @def mysql_file_pwrite(FD, B, S, O, F)
365 Instrumented pwrite.
366 @c mysql_file_pwrite is a replacement for @c my_pwrite.
367*/
368#ifdef HAVE_PSI_FILE_INTERFACE
369#define mysql_file_pwrite(FD, B, S, O, F) \
370 inline_mysql_file_pwrite(__FILE__, __LINE__, FD, B, S, O, F)
371#else
372#define mysql_file_pwrite(FD, B, S, O, F) \
373 inline_mysql_file_pwrite(FD, B, S, O, F)
374#endif
375
376/**
377 @def mysql_file_seek(FD, P, W, F)
378 Instrumented seek.
379 @c mysql_file_seek is a replacement for @c my_seek.
380*/
381#ifdef HAVE_PSI_FILE_INTERFACE
382#define mysql_file_seek(FD, P, W, F) \
383 inline_mysql_file_seek(__FILE__, __LINE__, FD, P, W, F)
384#else
385#define mysql_file_seek(FD, P, W, F) inline_mysql_file_seek(FD, P, W, F)
386#endif
387
388/**
389 @def mysql_file_tell(FD, F)
390 Instrumented tell.
391 @c mysql_file_tell is a replacement for @c my_tell.
392*/
393#ifdef HAVE_PSI_FILE_INTERFACE
394#define mysql_file_tell(FD, F) inline_mysql_file_tell(__FILE__, __LINE__, FD, F)
395#else
396#define mysql_file_tell(FD, F) inline_mysql_file_tell(FD, F)
397#endif
398
399/**
400 @def mysql_file_delete(K, P1, P2)
401 Instrumented delete.
402 @c mysql_file_delete is a replacement for @c my_delete.
403*/
404#ifdef HAVE_PSI_FILE_INTERFACE
405#define mysql_file_delete(K, P1, P2) \
406 inline_mysql_file_delete(K, __FILE__, __LINE__, P1, P2)
407#else
408#define mysql_file_delete(K, P1, P2) inline_mysql_file_delete(P1, P2)
409#endif
410
411/**
412 @def mysql_file_rename(K, P1, P2, P3)
413 Instrumented rename.
414 @c mysql_file_rename is a replacement for @c my_rename.
415*/
416#ifdef HAVE_PSI_FILE_INTERFACE
417#define mysql_file_rename(K, P1, P2, P3) \
418 inline_mysql_file_rename(K, __FILE__, __LINE__, P1, P2, P3)
419#else
420#define mysql_file_rename(K, P1, P2, P3) inline_mysql_file_rename(P1, P2, P3)
421#endif
422
423/**
424 @def mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5)
425 Instrumented create with symbolic link.
426 @c mysql_file_create_with_symlink is a replacement
427 for @c my_create_with_symlink.
428*/
429#ifdef HAVE_PSI_FILE_INTERFACE
430#define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \
431 inline_mysql_file_create_with_symlink(K, __FILE__, __LINE__, P1, P2, P3, P4, \
432 P5)
433#else
434#define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \
435 inline_mysql_file_create_with_symlink(P1, P2, P3, P4, P5)
436#endif
437
438/**
439 @def mysql_file_delete_with_symlink(K, P1, P2)
440 Instrumented delete with symbolic link.
441 @c mysql_file_delete_with_symlink is a replacement
442 for @c my_delete_with_symlink.
443*/
444#ifdef HAVE_PSI_FILE_INTERFACE
445#define mysql_file_delete_with_symlink(K, P1, P2) \
446 inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2)
447#else
448#define mysql_file_delete_with_symlink(K, P1, P2) \
449 inline_mysql_file_delete_with_symlink(P1, P2)
450#endif
451
452/**
453 @def mysql_file_rename_with_symlink(K, P1, P2, P3)
454 Instrumented rename with symbolic link.
455 @c mysql_file_rename_with_symlink is a replacement
456 for @c my_rename_with_symlink.
457*/
458#ifdef HAVE_PSI_FILE_INTERFACE
459#define mysql_file_rename_with_symlink(K, P1, P2, P3) \
460 inline_mysql_file_rename_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
461#else
462#define mysql_file_rename_with_symlink(K, P1, P2, P3) \
463 inline_mysql_file_rename_with_symlink(P1, P2, P3)
464#endif
465
466/**
467 @def mysql_file_sync(P1, P2)
468 Instrumented file sync.
469 @c mysql_file_sync is a replacement for @c my_sync.
470*/
471#ifdef HAVE_PSI_FILE_INTERFACE
472#define mysql_file_sync(P1, P2) \
473 inline_mysql_file_sync(__FILE__, __LINE__, P1, P2)
474#else
475#define mysql_file_sync(P1, P2) inline_mysql_file_sync(P1, P2)
476#endif
477
478/**
479 An instrumented FILE structure.
480 @c MYSQL_FILE is a drop-in replacement for @c FILE.
481 @sa mysql_file_open
482*/
484 /** The real file. */
486 /**
487 The instrumentation hook.
488 Note that this hook is not conditionally defined,
489 for binary compatibility of the @c MYSQL_FILE interface.
490 */
492};
493
494static inline void inline_mysql_file_register(
496 const char *category, PSI_file_info *info, int count
497#else
498 const char *category [[maybe_unused]], void *info [[maybe_unused]],
499 int count [[maybe_unused]]
500#endif
501) {
502#ifdef HAVE_PSI_FILE_INTERFACE
503 PSI_FILE_CALL(register_file)(category, info, count);
504#endif
505}
506
507static inline char *inline_mysql_file_fgets(
509 const char *src_file, uint src_line,
510#endif
511 char *str, int size, MYSQL_FILE *file) {
512 char *result;
513#ifdef HAVE_PSI_FILE_INTERFACE
514 struct PSI_file_locker *locker;
516 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
518 if (likely(locker != nullptr)) {
519 PSI_FILE_CALL(start_file_wait)(locker, (size_t)size, src_file, src_line);
520 result = fgets(str, size, file->m_file);
521 PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
522 return result;
523 }
524#endif
525
526 result = fgets(str, size, file->m_file);
527 return result;
528}
529
530static inline int inline_mysql_file_fgetc(
532 const char *src_file, uint src_line,
533#endif
534 MYSQL_FILE *file) {
535 int result;
536#ifdef HAVE_PSI_FILE_INTERFACE
537 struct PSI_file_locker *locker;
539 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
541 if (likely(locker != nullptr)) {
542 PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
543 result = fgetc(file->m_file);
544 PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
545 return result;
546 }
547#endif
548
549 result = fgetc(file->m_file);
550 return result;
551}
552
553static inline int inline_mysql_file_fputs(
555 const char *src_file, uint src_line,
556#endif
557 const char *str, MYSQL_FILE *file) {
558 int result;
559#ifdef HAVE_PSI_FILE_INTERFACE
560 struct PSI_file_locker *locker;
562 size_t bytes;
563 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
565 if (likely(locker != nullptr)) {
566 bytes = str ? strlen(str) : 0;
567 PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line);
568 result = fputs(str, file->m_file);
569 PSI_FILE_CALL(end_file_wait)(locker, bytes);
570 return result;
571 }
572#endif
573
574 result = fputs(str, file->m_file);
575 return result;
576}
577
578static inline int inline_mysql_file_fputc(
580 const char *src_file, uint src_line,
581#endif
582 char c, MYSQL_FILE *file) {
583 int result;
584#ifdef HAVE_PSI_FILE_INTERFACE
585 struct PSI_file_locker *locker;
587 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
589 if (likely(locker != nullptr)) {
590 PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
591 result = fputc(c, file->m_file);
592 PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
593 return result;
594 }
595#endif
596
597 result = fputc(c, file->m_file);
598 return result;
599}
600
601static inline int inline_mysql_file_fprintf(MYSQL_FILE *file,
602 const char *format, ...)
603 MY_ATTRIBUTE((format(printf, 2, 3)));
604
606 const char *format, ...) {
607 /*
608 TODO: figure out how to pass src_file and src_line from the caller.
609 */
610 int result;
611 va_list args;
612#ifdef HAVE_PSI_FILE_INTERFACE
613 struct PSI_file_locker *locker;
615 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
617 if (likely(locker != nullptr)) {
618 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, __FILE__, __LINE__);
619 va_start(args, format);
620 result = vfprintf(file->m_file, format, args);
621 va_end(args);
622 PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
623 return result;
624 }
625#endif
626
627 va_start(args, format);
628 result = vfprintf(file->m_file, format, args);
629 va_end(args);
630 return result;
631}
632
633static inline int inline_mysql_file_vfprintf(
635 const char *src_file, uint src_line,
636#endif
637 MYSQL_FILE *file, const char *format, va_list args)
638#ifdef HAVE_PSI_FILE_INTERFACE
639 MY_ATTRIBUTE((format(printf, 4, 0)));
640#else
641 MY_ATTRIBUTE((format(printf, 2, 0)));
642#endif
643
646 const char *src_file, uint src_line,
647#endif
648 MYSQL_FILE *file, const char *format, va_list args) {
649 int result;
650#ifdef HAVE_PSI_FILE_INTERFACE
651 struct PSI_file_locker *locker;
653 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
655 if (likely(locker != nullptr)) {
656 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
657 result = vfprintf(file->m_file, format, args);
658 PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
659 return result;
660 }
661#endif
662
663 result = vfprintf(file->m_file, format, args);
664 return result;
665}
666
667static inline int inline_mysql_file_fflush(
669 const char *src_file, uint src_line,
670#endif
671 MYSQL_FILE *file) {
672 int result;
673#ifdef HAVE_PSI_FILE_INTERFACE
674 struct PSI_file_locker *locker;
676 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
678 if (likely(locker != nullptr)) {
679 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
680 result = fflush(file->m_file);
681 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
682 return result;
683 }
684#endif
685
686 result = fflush(file->m_file);
687 return result;
688}
689
691 /* Not instrumented, there is no wait involved */
692 return feof(file->m_file);
693}
694
695static inline int inline_mysql_file_fstat(
697 const char *src_file, uint src_line,
698#endif
699 int filenr, MY_STAT *stat_area) {
700 int result;
701#ifdef HAVE_PSI_FILE_INTERFACE
702 struct PSI_file_locker *locker;
704 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr,
706 if (likely(locker != nullptr)) {
707 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
708 result = my_fstat(filenr, stat_area);
709 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
710 return result;
711 }
712#endif
713
714 result = my_fstat(filenr, stat_area);
715 return result;
716}
717
720 PSI_file_key key, const char *src_file, uint src_line,
721#endif
722 const char *path, MY_STAT *stat_area, myf flags) {
724#ifdef HAVE_PSI_FILE_INTERFACE
725 struct PSI_file_locker *locker;
727 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
728 &state, key, PSI_FILE_STAT, path, &locker);
729 if (likely(locker != nullptr)) {
730 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
731 result = my_stat(path, stat_area, flags);
732 PSI_FILE_CALL(end_file_open_wait)(locker, result);
733 return result;
734 }
735#endif
736
737 result = my_stat(path, stat_area, flags);
738 return result;
739}
740
741static inline int inline_mysql_file_chsize(
743 const char *src_file, uint src_line,
744#endif
745 File file, my_off_t newlength, int filler, myf flags) {
746 int result;
747#ifdef HAVE_PSI_FILE_INTERFACE
748 struct PSI_file_locker *locker;
750 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
752 if (likely(locker != nullptr)) {
753 PSI_FILE_CALL(start_file_wait)
754 (locker, (size_t)newlength, src_file, src_line);
755 result = my_chsize(file, newlength, filler, flags);
756 PSI_FILE_CALL(end_file_wait)(locker, (size_t)newlength);
757 return result;
758 }
759#endif
760
761 result = my_chsize(file, newlength, filler, flags);
762 return result;
763}
764
767 PSI_file_key key, const char *src_file, uint src_line,
768#endif
769 const char *filename, int flags, myf myFlags) {
770 MYSQL_FILE *that;
772 MYF(MY_WME));
773 if (likely(that != nullptr)) {
774#ifdef HAVE_PSI_FILE_INTERFACE
775 struct PSI_file_locker *locker;
777 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
778 &state, key, PSI_FILE_STREAM_OPEN, filename, that);
779 if (likely(locker != nullptr)) {
780 PSI_FILE_CALL(start_file_open_wait)
781 (locker, src_file, src_line);
782 that->m_file = my_fopen(filename, flags, myFlags);
783 that->m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
784 if (unlikely(that->m_file == nullptr)) {
785 my_free(that);
786 return nullptr;
787 }
788 return that;
789 }
790#endif
791
792 that->m_psi = nullptr;
793 that->m_file = my_fopen(filename, flags, myFlags);
794 if (unlikely(that->m_file == nullptr)) {
795 my_free(that);
796 return nullptr;
797 }
798 }
799 return that;
800}
801
802static inline int inline_mysql_file_fclose(
804 const char *src_file, uint src_line,
805#endif
807 int result = 0;
808 if (likely(file != nullptr)) {
809#ifdef HAVE_PSI_FILE_INTERFACE
810 struct PSI_file_locker *locker;
812 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(
813 &state, file->m_psi, PSI_FILE_STREAM_CLOSE);
814 if (likely(locker != nullptr)) {
815 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
816 result = my_fclose(file->m_file, flags);
817 PSI_FILE_CALL(end_file_close_wait)(locker, result);
818 my_free(file);
819 return result;
820 }
821#endif
822
823 result = my_fclose(file->m_file, flags);
824 my_free(file);
825 }
826 return result;
827}
828
829static inline size_t inline_mysql_file_fread(
831 const char *src_file, uint src_line,
832#endif
833 MYSQL_FILE *file, uchar *buffer, size_t count, myf flags) {
834 size_t result;
835#ifdef HAVE_PSI_FILE_INTERFACE
836 struct PSI_file_locker *locker;
838 size_t bytes_read;
839 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
841 if (likely(locker != nullptr)) {
842 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
843 result = my_fread(file->m_file, buffer, count, flags);
844 if (flags & (MY_NABP | MY_FNABP)) {
845 bytes_read = (result == 0) ? count : 0;
846 } else {
847 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
848 }
849 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
850 return result;
851 }
852#endif
853
854 result = my_fread(file->m_file, buffer, count, flags);
855 return result;
856}
857
858static inline size_t inline_mysql_file_fwrite(
860 const char *src_file, uint src_line,
861#endif
862 MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags) {
863 size_t result;
864#ifdef HAVE_PSI_FILE_INTERFACE
865 struct PSI_file_locker *locker;
867 size_t bytes_written;
868 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
870 if (likely(locker != nullptr)) {
871 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
872 result = my_fwrite(file->m_file, buffer, count, flags);
873 if (flags & (MY_NABP | MY_FNABP)) {
874 bytes_written = (result == 0) ? count : 0;
875 } else {
876 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
877 }
878 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
879 return result;
880 }
881#endif
882
883 result = my_fwrite(file->m_file, buffer, count, flags);
884 return result;
885}
886
889 const char *src_file, uint src_line,
890#endif
891 MYSQL_FILE *file, my_off_t pos, int whence) {
893#ifdef HAVE_PSI_FILE_INTERFACE
894 struct PSI_file_locker *locker;
896 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
898 if (likely(locker != nullptr)) {
899 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
900 result = my_fseek(file->m_file, pos, whence);
901 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
902 return result;
903 }
904#endif
905
906 result = my_fseek(file->m_file, pos, whence);
907 return result;
908}
909
912 const char *src_file, uint src_line,
913#endif
914 MYSQL_FILE *file) {
916#ifdef HAVE_PSI_FILE_INTERFACE
917 struct PSI_file_locker *locker;
919 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
921 if (likely(locker != nullptr)) {
922 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
923 result = my_ftell(file->m_file);
924 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
925 return result;
926 }
927#endif
928
929 result = my_ftell(file->m_file);
930 return result;
931}
932
935 PSI_file_key key, const char *src_file, uint src_line,
936#endif
937 const char *filename, int create_flags, int access_flags, myf myFlags) {
938 File file;
939#ifdef HAVE_PSI_FILE_INTERFACE
940 struct PSI_file_locker *locker;
942 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
943 &state, key, PSI_FILE_CREATE, filename, &locker);
944 if (likely(locker != nullptr)) {
945 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
946 file = my_create(filename, create_flags, access_flags, myFlags);
947 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
948 return file;
949 }
950#endif
951
952 file = my_create(filename, create_flags, access_flags, myFlags);
953 return file;
954}
955
958 PSI_file_key key, const char *src_file, uint src_line,
959#endif
960 char *to, const char *dir, const char *pfx, int mode,
961 UnlinkOrKeepFile unlink_or_keep, myf myFlags) {
962 File file;
963#ifdef HAVE_PSI_FILE_INTERFACE
964 struct PSI_file_locker *locker;
966 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
967 &state, key, PSI_FILE_CREATE, nullptr, &locker);
968 if (likely(locker != nullptr)) {
969 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
970 /* The file name is generated by create_temp_file(). */
971 file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
972 PSI_FILE_CALL(end_temp_file_open_wait_and_bind_to_descriptor)
973 (locker, file, (const char *)to);
974 return file;
975 }
976#endif
977
978 file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
979 return file;
980}
981
984 PSI_file_key key, const char *src_file, uint src_line,
985#endif
986 const char *filename, int flags, myf myFlags) {
987 File file;
988#ifdef HAVE_PSI_FILE_INTERFACE
989 struct PSI_file_locker *locker;
991 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
992 &state, key, PSI_FILE_OPEN, filename, &locker);
993 if (likely(locker != nullptr)) {
994 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
995 file = my_open(filename, flags, myFlags);
996 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
997 return file;
998 }
999#endif
1000
1001 file = my_open(filename, flags, myFlags);
1002 return file;
1003}
1004
1005static inline int inline_mysql_file_close(
1007 const char *src_file, uint src_line,
1008#endif
1009 File file, myf flags) {
1010 int result;
1011#ifdef HAVE_PSI_FILE_INTERFACE
1012 struct PSI_file_locker *locker;
1014 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1016 if (likely(locker != nullptr)) {
1017 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1019 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1020 return result;
1021 }
1022#endif
1023
1025 return result;
1026}
1027
1028static inline size_t inline_mysql_file_read(
1030 const char *src_file, uint src_line,
1031#endif
1032 File file, uchar *buffer, size_t count, myf flags) {
1033 size_t result;
1034#ifdef HAVE_PSI_FILE_INTERFACE
1035 struct PSI_file_locker *locker;
1037 size_t bytes_read;
1038 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1040 if (likely(locker != nullptr)) {
1041 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1043 if (flags & (MY_NABP | MY_FNABP)) {
1044 bytes_read = (result == 0) ? count : 0;
1045 } else {
1046 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1047 }
1048 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1049 return result;
1050 }
1051#endif
1052
1054 return result;
1055}
1056
1057static inline size_t inline_mysql_file_write(
1059 const char *src_file, uint src_line,
1060#endif
1061 File file, const uchar *buffer, size_t count, myf flags) {
1062 size_t result;
1063#ifdef HAVE_PSI_FILE_INTERFACE
1064 struct PSI_file_locker *locker;
1066 size_t bytes_written;
1067 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1069 if (likely(locker != nullptr)) {
1070 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1072 if (flags & (MY_NABP | MY_FNABP)) {
1073 bytes_written = (result == 0) ? count : 0;
1074 } else {
1075 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1076 }
1077 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1078 return result;
1079 }
1080#endif
1081
1083 return result;
1084}
1085
1086static inline size_t inline_mysql_file_pread(
1088 const char *src_file, uint src_line,
1089#endif
1090 File file, uchar *buffer, size_t count, my_off_t offset, myf flags) {
1091 size_t result;
1092#ifdef HAVE_PSI_FILE_INTERFACE
1093 struct PSI_file_locker *locker;
1095 size_t bytes_read;
1096 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1098 if (likely(locker != nullptr)) {
1099 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1100 result = my_pread(file, buffer, count, offset, flags);
1101 if (flags & (MY_NABP | MY_FNABP)) {
1102 bytes_read = (result == 0) ? count : 0;
1103 } else {
1104 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1105 }
1106 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1107 return result;
1108 }
1109#endif
1110
1111 result = my_pread(file, buffer, count, offset, flags);
1112 return result;
1113}
1114
1115static inline size_t inline_mysql_file_pwrite(
1117 const char *src_file, uint src_line,
1118#endif
1119 File file, const uchar *buffer, size_t count, my_off_t offset, myf flags) {
1120 size_t result;
1121#ifdef HAVE_PSI_FILE_INTERFACE
1122 struct PSI_file_locker *locker;
1124 size_t bytes_written;
1125 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1127 if (likely(locker != nullptr)) {
1128 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1129 result = my_pwrite(file, buffer, count, offset, flags);
1130 if (flags & (MY_NABP | MY_FNABP)) {
1131 bytes_written = (result == 0) ? count : 0;
1132 } else {
1133 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1134 }
1135 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1136 return result;
1137 }
1138#endif
1139
1140 result = my_pwrite(file, buffer, count, offset, flags);
1141 return result;
1142}
1143
1146 const char *src_file, uint src_line,
1147#endif
1148 File file, my_off_t pos, int whence, myf flags) {
1150#ifdef HAVE_PSI_FILE_INTERFACE
1151 struct PSI_file_locker *locker;
1153 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1155 if (likely(locker != nullptr)) {
1156 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1157 result = my_seek(file, pos, whence, flags);
1158 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1159 return result;
1160 }
1161#endif
1162
1163 result = my_seek(file, pos, whence, flags);
1164 return result;
1165}
1166
1169 const char *src_file, uint src_line,
1170#endif
1171 File file, myf flags) {
1173#ifdef HAVE_PSI_FILE_INTERFACE
1174 struct PSI_file_locker *locker;
1176 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1178 if (likely(locker != nullptr)) {
1179 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1181 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1182 return result;
1183 }
1184#endif
1185
1187 return result;
1188}
1189
1192 PSI_file_key key, const char *src_file, uint src_line,
1193#endif
1194 const char *name, myf flags) {
1195 int result;
1196#ifdef HAVE_PSI_FILE_INTERFACE
1197 struct PSI_file_locker *locker;
1199 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1200 &state, key, PSI_FILE_DELETE, name, &locker);
1201 if (likely(locker != nullptr)) {
1202 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1204 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1205 return result;
1206 }
1207#endif
1208
1210 return result;
1211}
1212
1215 PSI_file_key key, const char *src_file, uint src_line,
1216#endif
1217 const char *from, const char *to, myf flags) {
1218 int result;
1219#ifdef HAVE_PSI_FILE_INTERFACE
1220 struct PSI_file_locker *locker;
1222 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1223 &state, key, PSI_FILE_RENAME, from, &locker);
1224 if (likely(locker != nullptr)) {
1225 PSI_FILE_CALL(start_file_rename_wait)
1226 (locker, (size_t)0, from, to, src_file, src_line);
1227 result = my_rename(from, to, flags);
1228 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1229 return result;
1230 }
1231#endif
1232
1233 result = my_rename(from, to, flags);
1234 return result;
1235}
1236
1239 PSI_file_key key, const char *src_file, uint src_line,
1240#endif
1241 const char *linkname, const char *filename, int create_flags,
1242 int access_flags, myf flags) {
1243 File file;
1244#ifdef HAVE_PSI_FILE_INTERFACE
1245 struct PSI_file_locker *locker;
1247 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1248 &state, key, PSI_FILE_CREATE, filename, &locker);
1249 if (likely(locker != nullptr)) {
1250 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
1251 file = my_create_with_symlink(linkname, filename, create_flags,
1252 access_flags, flags);
1253 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
1254 return file;
1255 }
1256#endif
1257
1258 file = my_create_with_symlink(linkname, filename, create_flags, access_flags,
1259 flags);
1260 return file;
1261}
1262
1265 PSI_file_key key, const char *src_file, uint src_line,
1266#endif
1267 const char *name, myf flags) {
1268 int result;
1269#ifdef HAVE_PSI_FILE_INTERFACE
1270 struct PSI_file_locker *locker;
1272 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1273 &state, key, PSI_FILE_DELETE, name, &locker);
1274 if (likely(locker != nullptr)) {
1275 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1277 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1278 return result;
1279 }
1280#endif
1281
1283 return result;
1284}
1285
1288 PSI_file_key key, const char *src_file, uint src_line,
1289#endif
1290 const char *from, const char *to, myf flags) {
1291 int result;
1292#ifdef HAVE_PSI_FILE_INTERFACE
1293 struct PSI_file_locker *locker;
1295 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1296 &state, key, PSI_FILE_RENAME, from, &locker);
1297 if (likely(locker != nullptr)) {
1298 PSI_FILE_CALL(start_file_rename_wait)
1299 (locker, (size_t)0, from, to, src_file, src_line);
1300 result = my_rename_with_symlink(from, to, flags);
1301 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1302 return result;
1303 }
1304#endif
1305
1306 result = my_rename_with_symlink(from, to, flags);
1307 return result;
1308}
1309
1310static inline int inline_mysql_file_sync(
1312 const char *src_file, uint src_line,
1313#endif
1314 File fd, myf flags) {
1315 int result = 0;
1316#ifdef HAVE_PSI_FILE_INTERFACE
1317 struct PSI_file_locker *locker;
1319 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd,
1321 if (likely(locker != nullptr)) {
1322 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1323 result = my_sync(fd, flags);
1324 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1325 return result;
1326 }
1327#endif
1328
1329 result = my_sync(fd, flags);
1330 return result;
1331}
1332
1333/** @} (end of group psi_api_file) */
1334
1335#endif
#define PSI_FILE_CALL(M)
Definition: psi_file.h:35
int my_sync(File fd, myf my_flags)
Definition: my_sync.cc:84
int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
Change size of file.
Definition: my_chsize.cc:65
int my_delete_with_symlink(const char *name, myf MyFlags)
Definition: my_symlink2.cc:126
int my_rename(const char *from, const char *to, myf MyFlags)
Definition: my_rename.cc:46
File my_create(const char *FileName, int CreateFlags, int AccessFlags, myf MyFlags)
Create a new file.
Definition: my_create.cc:63
size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
Read a chunk of bytes from a file with retry's if needed If flag MY_FULL_IO is set then keep reading ...
Definition: my_read.cc:72
my_off_t my_fseek(FILE *stream, my_off_t pos, int whence)
Seek to position in FILE stream.
Definition: my_fstream.cc:156
my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags)
Seek to a position in a file.
Definition: my_seek.cc:68
File my_open(const char *filename, int Flags, myf MyFlags)
Open a file.
Definition: my_open.cc:65
File create_temp_file(char *to, const char *dir, const char *pfx, int mode, UnlinkOrKeepFile unlink_or_keep, myf MyFlags)
Definition: mf_tempfile.cc:219
my_off_t my_ftell(FILE *stream)
Portable ftell() wrapper.
Definition: my_fstream.cc:165
#define MY_NABP
Definition: my_sys.h:125
my_off_t my_tell(File fd, myf MyFlags)
Definition: my_seek.cc:93
size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, myf MyFlags)
Read a chunk of bytes from a file from a given position.
Definition: my_pread.cc:78
int my_delete(const char *name, myf MyFlags)
Definition: my_delete.cc:45
int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
Definition: my_symlink2.cc:153
#define MY_WME
Definition: my_sys.h:127
File my_create_with_symlink(const char *linkname, const char *filename, int createflags, int access_flags, myf MyFlags)
Definition: my_symlink2.cc:53
#define MY_FNABP
Definition: my_sys.h:124
size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
Write a chunk of bytes to a FILE stream.
Definition: my_fstream.cc:102
size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
Write a chunk of bytes to a file.
Definition: my_write.cc:78
int my_close(File fd, myf MyFlags)
Close a file.
Definition: my_open.cc:98
UnlinkOrKeepFile
Definition: my_sys.h:781
#define MY_FILE_ERROR
Definition: my_sys.h:120
size_t my_fread(FILE *stream, uchar *Buffer, size_t Count, myf MyFlags)
Read a chunk of bytes from a FILE stream.
Definition: my_fstream.cc:72
FILE * my_fopen(const char *filename, int Flags, myf MyFlags)
Open a file as stream.
Definition: my_fopen.cc:108
size_t my_pwrite(File Filedes, const uchar *Buffer, size_t Count, my_off_t offset, myf MyFlags)
Write a chunk of bytes to a file at a given position.
Definition: my_pread.cc:140
int my_fclose(FILE *stream, myf MyFlags)
Close a stream.
Definition: my_fopen.cc:174
struct PSI_file PSI_file
Definition: psi_file_bits.h:54
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:47
struct PSI_file_locker PSI_file_locker
Definition: psi_file_bits.h:61
@ PSI_FILE_OPEN
File open, as in open().
Definition: psi_file_bits.h:70
@ PSI_FILE_STREAM_CLOSE
File close, as in fclose().
Definition: psi_file_bits.h:76
@ PSI_FILE_WRITE
Generic file write, such as fputs(), fputc(), fprintf(), vfprintf(), fwrite(), write(),...
Definition: psi_file_bits.h:86
@ PSI_FILE_CHSIZE
File chsize, as in my_chsize().
Definition: psi_file_bits.h:98
@ PSI_FILE_CLOSE
File close, as in close().
Definition: psi_file_bits.h:74
@ PSI_FILE_SEEK
Generic file seek, such as fseek() or seek().
Definition: psi_file_bits.h:88
@ PSI_FILE_TELL
Generic file tell, such as ftell() or tell().
Definition: psi_file_bits.h:90
@ PSI_FILE_STREAM_OPEN
File open, as in fopen().
Definition: psi_file_bits.h:72
@ PSI_FILE_CREATE
File creation, as in create().
Definition: psi_file_bits.h:66
@ PSI_FILE_FSTAT
File stat, as in fstat().
Definition: psi_file_bits.h:96
@ PSI_FILE_RENAME
File rename, such as my_rename() or my_rename_with_symlink().
Definition: psi_file_bits.h:102
@ PSI_FILE_STAT
File stat, as in stat().
Definition: psi_file_bits.h:94
@ PSI_FILE_DELETE
File delete, such as my_delete() or my_delete_with_symlink().
Definition: psi_file_bits.h:100
@ PSI_FILE_FLUSH
File flush, as in fflush().
Definition: psi_file_bits.h:92
@ PSI_FILE_READ
Generic file read, such as fgets(), fgetc(), fread(), read(), pread().
Definition: psi_file_bits.h:81
@ PSI_FILE_SYNC
File sync, as in fsync() or my_sync().
Definition: psi_file_bits.h:104
static int inline_mysql_file_fclose(const char *src_file, uint src_line, MYSQL_FILE *file, myf flags)
Definition: mysql_file.h:802
static int inline_mysql_file_delete_with_symlink(PSI_file_key key, const char *src_file, uint src_line, const char *name, myf flags)
Definition: mysql_file.h:1263
static File inline_mysql_file_open(PSI_file_key key, const char *src_file, uint src_line, const char *filename, int flags, myf myFlags)
Definition: mysql_file.h:982
static int inline_mysql_file_chsize(const char *src_file, uint src_line, File file, my_off_t newlength, int filler, myf flags)
Definition: mysql_file.h:741
static size_t inline_mysql_file_pread(const char *src_file, uint src_line, File file, uchar *buffer, size_t count, my_off_t offset, myf flags)
Definition: mysql_file.h:1086
static size_t inline_mysql_file_fwrite(const char *src_file, uint src_line, MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags)
Definition: mysql_file.h:858
static File inline_mysql_file_create_temp(PSI_file_key key, const char *src_file, uint src_line, char *to, const char *dir, const char *pfx, int mode, UnlinkOrKeepFile unlink_or_keep, myf myFlags)
Definition: mysql_file.h:956
static my_off_t inline_mysql_file_seek(const char *src_file, uint src_line, File file, my_off_t pos, int whence, myf flags)
Definition: mysql_file.h:1144
static File inline_mysql_file_create(PSI_file_key key, const char *src_file, uint src_line, const char *filename, int create_flags, int access_flags, myf myFlags)
Definition: mysql_file.h:933
static int inline_mysql_file_rename_with_symlink(PSI_file_key key, const char *src_file, uint src_line, const char *from, const char *to, myf flags)
Definition: mysql_file.h:1286
static MYSQL_FILE * inline_mysql_file_fopen(PSI_file_key key, const char *src_file, uint src_line, const char *filename, int flags, myf myFlags)
Definition: mysql_file.h:765
static int inline_mysql_file_vfprintf(const char *src_file, uint src_line, MYSQL_FILE *file, const char *format, va_list args)
Definition: mysql_file.h:644
static size_t inline_mysql_file_write(const char *src_file, uint src_line, File file, const uchar *buffer, size_t count, myf flags)
Definition: mysql_file.h:1057
static int inline_mysql_file_delete(PSI_file_key key, const char *src_file, uint src_line, const char *name, myf flags)
Definition: mysql_file.h:1190
static File inline_mysql_file_create_with_symlink(PSI_file_key key, const char *src_file, uint src_line, const char *linkname, const char *filename, int create_flags, int access_flags, myf flags)
Definition: mysql_file.h:1237
static int inline_mysql_file_close(const char *src_file, uint src_line, File file, myf flags)
Definition: mysql_file.h:1005
static int inline_mysql_file_fputs(const char *src_file, uint src_line, const char *str, MYSQL_FILE *file)
Definition: mysql_file.h:553
static my_off_t inline_mysql_file_tell(const char *src_file, uint src_line, File file, myf flags)
Definition: mysql_file.h:1167
static MY_STAT * inline_mysql_file_stat(PSI_file_key key, const char *src_file, uint src_line, const char *path, MY_STAT *stat_area, myf flags)
Definition: mysql_file.h:718
static size_t inline_mysql_file_read(const char *src_file, uint src_line, File file, uchar *buffer, size_t count, myf flags)
Definition: mysql_file.h:1028
static int inline_mysql_file_rename(PSI_file_key key, const char *src_file, uint src_line, const char *from, const char *to, myf flags)
Definition: mysql_file.h:1213
static size_t inline_mysql_file_pwrite(const char *src_file, uint src_line, File file, const uchar *buffer, size_t count, my_off_t offset, myf flags)
Definition: mysql_file.h:1115
static int inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format,...)
Definition: mysql_file.h:605
static my_off_t inline_mysql_file_fseek(const char *src_file, uint src_line, MYSQL_FILE *file, my_off_t pos, int whence)
Definition: mysql_file.h:887
static void inline_mysql_file_register(const char *category, PSI_file_info *info, int count)
Definition: mysql_file.h:494
static int inline_mysql_file_fstat(const char *src_file, uint src_line, int filenr, MY_STAT *stat_area)
Definition: mysql_file.h:695
static size_t inline_mysql_file_fread(const char *src_file, uint src_line, MYSQL_FILE *file, uchar *buffer, size_t count, myf flags)
Definition: mysql_file.h:829
static my_off_t inline_mysql_file_ftell(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:910
static int inline_mysql_file_fgetc(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:530
static int inline_mysql_file_fputc(const char *src_file, uint src_line, char c, MYSQL_FILE *file)
Definition: mysql_file.h:578
static int inline_mysql_file_fflush(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:667
static int inline_mysql_file_sync(const char *src_file, uint src_line, File fd, myf flags)
Definition: mysql_file.h:1310
static char * inline_mysql_file_fgets(const char *src_file, uint src_line, char *str, int size, MYSQL_FILE *file)
Definition: mysql_file.h:507
static int inline_mysql_file_feof(MYSQL_FILE *file)
Definition: mysql_file.h:690
static int flags[50]
Definition: hp_test1.cc:39
static const char * whence(const Item_field *cached_field)
Get the name of the cached field of an Item_cache_json instance.
Definition: item.cc:10121
constexpr bool likely(bool expr)
Definition: my_compiler.h:56
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:57
int my_fstat(int filenr, MY_STAT *stat_area)
Definition: my_lib.cc:294
#define MY_STAT
Definition: my_dir.h:70
MY_STAT * my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
Definition: my_lib.cc:304
Some integer typedefs for easier portability.
int myf
Definition: my_inttypes.h:93
ulonglong my_off_t
Definition: my_inttypes.h:71
unsigned char uchar
Definition: my_inttypes.h:51
#define MYF(v)
Definition: my_inttypes.h:96
int File
Definition: my_io_bits.h:50
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:56
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:80
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define HAVE_PSI_FILE_INTERFACE
Definition: my_psi_config.h:104
Common header for many mysys elements.
static int count
Definition: myisam_ftdump.cc:44
static char * path
Definition: mysqldump.cc:148
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1065
const std::string FILE("FILE")
std::string dir
Double write files location.
Definition: buf0dblwr.cc:76
Definition: os0file.h:88
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
static const char * category
Definition: sha2_password.cc:169
mode
Definition: file_handle.h:59
const char * filename
Definition: pfs_example_component_population.cc:66
Performance schema instrumentation (declarations).
struct result result
Definition: result.h:33
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:59
case opt name
Definition: sslopt-case.h:32
An instrumented FILE structure.
Definition: mysql_file.h:483
FILE * m_file
The real file.
Definition: mysql_file.h:485
struct PSI_file * m_psi
The instrumentation hook.
Definition: mysql_file.h:491
File instrument information.
Definition: psi_file_bits.h:113
State data storage for get_thread_file_name_locker_v1_t.
Definition: psi_file_bits.h:145
Definition: result.h:29
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:41