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