MySQL 8.0.33
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/* For my_chsize */
52#include "my_sys.h"
53#include "mysql/psi/psi_file.h"
55
56#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
57/* PSI_FILE_CALL() as direct call. */
58#include "pfs_file_provider.h" // IWYU pragma: keep
59#endif
60
61#ifndef PSI_FILE_CALL
62#define PSI_FILE_CALL(M) psi_file_service->M
63#endif
64
65/**
66 @defgroup psi_api_file File Instrumentation (API)
67 @ingroup psi_api
68 @{
69*/
70
71/**
72 @def mysql_file_register(P1, P2, P3)
73 File registration.
74*/
75#define mysql_file_register(P1, P2, P3) inline_mysql_file_register(P1, P2, P3)
76
77/**
78 @def mysql_file_fgets(P1, P2, F)
79 Instrumented fgets.
80 @c mysql_file_fgets is a replacement for @c fgets.
81*/
82#ifdef HAVE_PSI_FILE_INTERFACE
83#define mysql_file_fgets(P1, P2, F) \
84 inline_mysql_file_fgets(__FILE__, __LINE__, P1, P2, F)
85#else
86#define mysql_file_fgets(P1, P2, F) inline_mysql_file_fgets(P1, P2, F)
87#endif
88
89/**
90 @def mysql_file_fgetc(F)
91 Instrumented fgetc.
92 @c mysql_file_fgetc is a replacement for @c fgetc.
93*/
94#ifdef HAVE_PSI_FILE_INTERFACE
95#define mysql_file_fgetc(F) inline_mysql_file_fgetc(__FILE__, __LINE__, F)
96#else
97#define mysql_file_fgetc(F) inline_mysql_file_fgetc(F)
98#endif
99
100/**
101 @def mysql_file_fputs(P1, F)
102 Instrumented fputs.
103 @c mysql_file_fputs is a replacement for @c fputs.
104*/
105#ifdef HAVE_PSI_FILE_INTERFACE
106#define mysql_file_fputs(P1, F) \
107 inline_mysql_file_fputs(__FILE__, __LINE__, P1, F)
108#else
109#define mysql_file_fputs(P1, F) inline_mysql_file_fputs(P1, F)
110#endif
111
112/**
113 @def mysql_file_fputc(P1, F)
114 Instrumented fputc.
115 @c mysql_file_fputc is a replacement for @c fputc.
116*/
117#ifdef HAVE_PSI_FILE_INTERFACE
118#define mysql_file_fputc(P1, F) \
119 inline_mysql_file_fputc(__FILE__, __LINE__, P1, F)
120#else
121#define mysql_file_fputc(P1, F) inline_mysql_file_fputc(P1, F)
122#endif
123
124/**
125 @def mysql_file_fprintf
126 Instrumented fprintf.
127 @c mysql_file_fprintf is a replacement for @c fprintf.
128*/
129#define mysql_file_fprintf inline_mysql_file_fprintf
130
131/**
132 @def mysql_file_vfprintf(F, P1, P2)
133 Instrumented vfprintf.
134 @c mysql_file_vfprintf is a replacement for @c vfprintf.
135*/
136#ifdef HAVE_PSI_FILE_INTERFACE
137#define mysql_file_vfprintf(F, P1, P2) \
138 inline_mysql_file_vfprintf(__FILE__, __LINE__, F, P1, P2)
139#else
140#define mysql_file_vfprintf(F, P1, P2) inline_mysql_file_vfprintf(F, P1, P2)
141#endif
142
143/**
144 @def mysql_file_fflush(F, P1, P2)
145 Instrumented fflush.
146 @c mysql_file_fflush is a replacement for @c fflush.
147*/
148#ifdef HAVE_PSI_FILE_INTERFACE
149#define mysql_file_fflush(F) inline_mysql_file_fflush(__FILE__, __LINE__, F)
150#else
151#define mysql_file_fflush(F) inline_mysql_file_fflush(F)
152#endif
153
154/**
155 @def mysql_file_feof(F)
156 Instrumented feof.
157 @c mysql_file_feof is a replacement for @c feof.
158*/
159#define mysql_file_feof(F) inline_mysql_file_feof(F)
160
161/**
162 @def mysql_file_fstat(FN, S)
163 Instrumented fstat.
164 @c mysql_file_fstat is a replacement for @c my_fstat.
165*/
166#ifdef HAVE_PSI_FILE_INTERFACE
167#define mysql_file_fstat(FN, S) \
168 inline_mysql_file_fstat(__FILE__, __LINE__, FN, S)
169#else
170#define mysql_file_fstat(FN, S) inline_mysql_file_fstat(FN, S)
171#endif
172
173/**
174 @def mysql_file_stat(K, FN, S, FL)
175 Instrumented stat.
176 @c mysql_file_stat is a replacement for @c my_stat.
177*/
178#ifdef HAVE_PSI_FILE_INTERFACE
179#define mysql_file_stat(K, FN, S, FL) \
180 inline_mysql_file_stat(K, __FILE__, __LINE__, FN, S, FL)
181#else
182#define mysql_file_stat(K, FN, S, FL) inline_mysql_file_stat(FN, S, FL)
183#endif
184
185/**
186 @def mysql_file_chsize(F, P1, P2, P3)
187 Instrumented chsize.
188 @c mysql_file_chsize is a replacement for @c my_chsize.
189*/
190#ifdef HAVE_PSI_FILE_INTERFACE
191#define mysql_file_chsize(F, P1, P2, P3) \
192 inline_mysql_file_chsize(__FILE__, __LINE__, F, P1, P2, P3)
193#else
194#define mysql_file_chsize(F, P1, P2, P3) inline_mysql_file_chsize(F, P1, P2, P3)
195#endif
196
197/**
198 @def mysql_file_fopen(K, N, F1, F2)
199 Instrumented fopen.
200 @c mysql_file_fopen is a replacement for @c my_fopen.
201*/
202#ifdef HAVE_PSI_FILE_INTERFACE
203#define mysql_file_fopen(K, N, F1, F2) \
204 inline_mysql_file_fopen(K, __FILE__, __LINE__, N, F1, F2)
205#else
206#define mysql_file_fopen(K, N, F1, F2) inline_mysql_file_fopen(N, F1, F2)
207#endif
208
209/**
210 @def mysql_file_fclose(FD, FL)
211 Instrumented fclose.
212 @c mysql_file_fclose is a replacement for @c my_fclose.
213 Without the instrumentation, this call will have the same behavior as the
214 undocumented and possibly platform specific my_fclose(NULL, ...) behavior.
215 With the instrumentation, mysql_fclose(NULL, ...) will safely return 0,
216 which is an extension compared to my_fclose and is therefore compliant.
217 mysql_fclose is on purpose *not* implementing
218 @code assert(file != NULL) @endcode,
219 since doing so could introduce regressions.
220*/
221#ifdef HAVE_PSI_FILE_INTERFACE
222#define mysql_file_fclose(FD, FL) \
223 inline_mysql_file_fclose(__FILE__, __LINE__, FD, FL)
224#else
225#define mysql_file_fclose(FD, FL) inline_mysql_file_fclose(FD, FL)
226#endif
227
228/**
229 @def mysql_file_fread(FD, P1, P2, P3)
230 Instrumented fread.
231 @c mysql_file_fread is a replacement for @c my_fread.
232*/
233#ifdef HAVE_PSI_FILE_INTERFACE
234#define mysql_file_fread(FD, P1, P2, P3) \
235 inline_mysql_file_fread(__FILE__, __LINE__, FD, P1, P2, P3)
236#else
237#define mysql_file_fread(FD, P1, P2, P3) inline_mysql_file_fread(FD, P1, P2, P3)
238#endif
239
240/**
241 @def mysql_file_fwrite(FD, P1, P2, P3)
242 Instrumented fwrite.
243 @c mysql_file_fwrite is a replacement for @c my_fwrite.
244*/
245#ifdef HAVE_PSI_FILE_INTERFACE
246#define mysql_file_fwrite(FD, P1, P2, P3) \
247 inline_mysql_file_fwrite(__FILE__, __LINE__, FD, P1, P2, P3)
248#else
249#define mysql_file_fwrite(FD, P1, P2, P3) \
250 inline_mysql_file_fwrite(FD, P1, P2, P3)
251#endif
252
253/**
254 @def mysql_file_fseek(FD, P, W)
255 Instrumented fseek.
256 @c mysql_file_fseek is a replacement for @c my_fseek.
257*/
258#ifdef HAVE_PSI_FILE_INTERFACE
259#define mysql_file_fseek(FD, P, W) \
260 inline_mysql_file_fseek(__FILE__, __LINE__, FD, P, W)
261#else
262#define mysql_file_fseek(FD, P, W) inline_mysql_file_fseek(FD, P, W)
263#endif
264
265/**
266 @def mysql_file_ftell(FD)
267 Instrumented ftell.
268 @c mysql_file_ftell is a replacement for @c my_ftell.
269*/
270#ifdef HAVE_PSI_FILE_INTERFACE
271#define mysql_file_ftell(FD) inline_mysql_file_ftell(__FILE__, __LINE__, FD)
272#else
273#define mysql_file_ftell(FD) inline_mysql_file_ftell(FD)
274#endif
275
276/**
277 @def mysql_file_create(K, N, F1, F2, F3)
278 Instrumented create.
279 @c mysql_file_create is a replacement for @c my_create.
280*/
281#ifdef HAVE_PSI_FILE_INTERFACE
282#define mysql_file_create(K, N, F1, F2, F3) \
283 inline_mysql_file_create(K, __FILE__, __LINE__, N, F1, F2, F3)
284#else
285#define mysql_file_create(K, N, F1, F2, F3) \
286 inline_mysql_file_create(N, F1, F2, F3)
287#endif
288
289/**
290 @def mysql_file_create_temp(K, T, D, P, M, U, F)
291 Instrumented create_temp_file.
292 @c mysql_file_create_temp is a replacement for @c create_temp_file.
293*/
294#ifdef HAVE_PSI_FILE_INTERFACE
295#define mysql_file_create_temp(K, T, D, P, M, U, F) \
296 inline_mysql_file_create_temp(K, __FILE__, __LINE__, T, D, P, M, U, F)
297#else
298#define mysql_file_create_temp(K, T, D, P, M, U, F) \
299 inline_mysql_file_create_temp(T, D, P, M, U, F)
300#endif
301
302/**
303 @def mysql_file_open(K, N, F1, F2)
304 Instrumented open.
305 @c mysql_file_open is a replacement for @c my_open.
306*/
307#ifdef HAVE_PSI_FILE_INTERFACE
308#define mysql_file_open(K, N, F1, F2) \
309 inline_mysql_file_open(K, __FILE__, __LINE__, N, F1, F2)
310#else
311#define mysql_file_open(K, N, F1, F2) inline_mysql_file_open(N, F1, F2)
312#endif
313
314/**
315 @def mysql_file_close(FD, F)
316 Instrumented close.
317 @c mysql_file_close is a replacement for @c my_close.
318*/
319#ifdef HAVE_PSI_FILE_INTERFACE
320#define mysql_file_close(FD, F) \
321 inline_mysql_file_close(__FILE__, __LINE__, FD, F)
322#else
323#define mysql_file_close(FD, F) inline_mysql_file_close(FD, F)
324#endif
325
326/**
327 @def mysql_file_read(FD, B, S, F)
328 Instrumented read.
329 @c mysql_read is a replacement for @c my_read.
330*/
331#ifdef HAVE_PSI_FILE_INTERFACE
332#define mysql_file_read(FD, B, S, F) \
333 inline_mysql_file_read(__FILE__, __LINE__, FD, B, S, F)
334#else
335#define mysql_file_read(FD, B, S, F) inline_mysql_file_read(FD, B, S, F)
336#endif
337
338/**
339 @def mysql_file_write(FD, B, S, F)
340 Instrumented write.
341 @c mysql_file_write is a replacement for @c my_write.
342*/
343#ifdef HAVE_PSI_FILE_INTERFACE
344#define mysql_file_write(FD, B, S, F) \
345 inline_mysql_file_write(__FILE__, __LINE__, FD, B, S, F)
346#else
347#define mysql_file_write(FD, B, S, F) inline_mysql_file_write(FD, B, S, F)
348#endif
349
350/**
351 @def mysql_file_pread(FD, B, S, O, F)
352 Instrumented pread.
353 @c mysql_pread is a replacement for @c my_pread.
354*/
355#ifdef HAVE_PSI_FILE_INTERFACE
356#define mysql_file_pread(FD, B, S, O, F) \
357 inline_mysql_file_pread(__FILE__, __LINE__, FD, B, S, O, F)
358#else
359#define mysql_file_pread(FD, B, S, O, F) inline_mysql_file_pread(FD, B, S, O, F)
360#endif
361
362/**
363 @def mysql_file_pwrite(FD, B, S, O, F)
364 Instrumented pwrite.
365 @c mysql_file_pwrite is a replacement for @c my_pwrite.
366*/
367#ifdef HAVE_PSI_FILE_INTERFACE
368#define mysql_file_pwrite(FD, B, S, O, F) \
369 inline_mysql_file_pwrite(__FILE__, __LINE__, FD, B, S, O, F)
370#else
371#define mysql_file_pwrite(FD, B, S, O, F) \
372 inline_mysql_file_pwrite(FD, B, S, O, F)
373#endif
374
375/**
376 @def mysql_file_seek(FD, P, W, F)
377 Instrumented seek.
378 @c mysql_file_seek is a replacement for @c my_seek.
379*/
380#ifdef HAVE_PSI_FILE_INTERFACE
381#define mysql_file_seek(FD, P, W, F) \
382 inline_mysql_file_seek(__FILE__, __LINE__, FD, P, W, F)
383#else
384#define mysql_file_seek(FD, P, W, F) inline_mysql_file_seek(FD, P, W, F)
385#endif
386
387/**
388 @def mysql_file_tell(FD, F)
389 Instrumented tell.
390 @c mysql_file_tell is a replacement for @c my_tell.
391*/
392#ifdef HAVE_PSI_FILE_INTERFACE
393#define mysql_file_tell(FD, F) inline_mysql_file_tell(__FILE__, __LINE__, FD, F)
394#else
395#define mysql_file_tell(FD, F) inline_mysql_file_tell(FD, F)
396#endif
397
398/**
399 @def mysql_file_delete(K, P1, P2)
400 Instrumented delete.
401 @c mysql_file_delete is a replacement for @c my_delete.
402*/
403#ifdef HAVE_PSI_FILE_INTERFACE
404#define mysql_file_delete(K, P1, P2) \
405 inline_mysql_file_delete(K, __FILE__, __LINE__, P1, P2)
406#else
407#define mysql_file_delete(K, P1, P2) inline_mysql_file_delete(P1, P2)
408#endif
409
410/**
411 @def mysql_file_rename(K, P1, P2, P3)
412 Instrumented rename.
413 @c mysql_file_rename is a replacement for @c my_rename.
414*/
415#ifdef HAVE_PSI_FILE_INTERFACE
416#define mysql_file_rename(K, P1, P2, P3) \
417 inline_mysql_file_rename(K, __FILE__, __LINE__, P1, P2, P3)
418#else
419#define mysql_file_rename(K, P1, P2, P3) inline_mysql_file_rename(P1, P2, P3)
420#endif
421
422/**
423 @def mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5)
424 Instrumented create with symbolic link.
425 @c mysql_file_create_with_symlink is a replacement
426 for @c my_create_with_symlink.
427*/
428#ifdef HAVE_PSI_FILE_INTERFACE
429#define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \
430 inline_mysql_file_create_with_symlink(K, __FILE__, __LINE__, P1, P2, P3, P4, \
431 P5)
432#else
433#define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \
434 inline_mysql_file_create_with_symlink(P1, P2, P3, P4, P5)
435#endif
436
437/**
438 @def mysql_file_delete_with_symlink(K, P1, P2)
439 Instrumented delete with symbolic link.
440 @c mysql_file_delete_with_symlink is a replacement
441 for @c my_delete_with_symlink.
442*/
443#ifdef HAVE_PSI_FILE_INTERFACE
444#define mysql_file_delete_with_symlink(K, P1, P2) \
445 inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2)
446#else
447#define mysql_file_delete_with_symlink(K, P1, P2) \
448 inline_mysql_file_delete_with_symlink(P1, P2)
449#endif
450
451/**
452 @def mysql_file_rename_with_symlink(K, P1, P2, P3)
453 Instrumented rename with symbolic link.
454 @c mysql_file_rename_with_symlink is a replacement
455 for @c my_rename_with_symlink.
456*/
457#ifdef HAVE_PSI_FILE_INTERFACE
458#define mysql_file_rename_with_symlink(K, P1, P2, P3) \
459 inline_mysql_file_rename_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
460#else
461#define mysql_file_rename_with_symlink(K, P1, P2, P3) \
462 inline_mysql_file_rename_with_symlink(P1, P2, P3)
463#endif
464
465/**
466 @def mysql_file_sync(P1, P2)
467 Instrumented file sync.
468 @c mysql_file_sync is a replacement for @c my_sync.
469*/
470#ifdef HAVE_PSI_FILE_INTERFACE
471#define mysql_file_sync(P1, P2) \
472 inline_mysql_file_sync(__FILE__, __LINE__, P1, P2)
473#else
474#define mysql_file_sync(P1, P2) inline_mysql_file_sync(P1, P2)
475#endif
476
477/**
478 An instrumented FILE structure.
479 @c MYSQL_FILE is a drop-in replacement for @c FILE.
480 @sa mysql_file_open
481*/
483 /** The real file. */
485 /**
486 The instrumentation hook.
487 Note that this hook is not conditionally defined,
488 for binary compatibility of the @c MYSQL_FILE interface.
489 */
491};
492
493static inline void inline_mysql_file_register(
495 const char *category, PSI_file_info *info, int count
496#else
497 const char *category [[maybe_unused]], void *info [[maybe_unused]],
498 int count [[maybe_unused]]
499#endif
500) {
501#ifdef HAVE_PSI_FILE_INTERFACE
502 PSI_FILE_CALL(register_file)(category, info, count);
503#endif
504}
505
506static inline char *inline_mysql_file_fgets(
508 const char *src_file, uint src_line,
509#endif
510 char *str, int size, MYSQL_FILE *file) {
511 char *result;
512#ifdef HAVE_PSI_FILE_INTERFACE
513 struct PSI_file_locker *locker;
515 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
517 if (likely(locker != nullptr)) {
518 PSI_FILE_CALL(start_file_wait)(locker, (size_t)size, src_file, src_line);
519 result = fgets(str, size, file->m_file);
520 PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
521 return result;
522 }
523#endif
524
525 result = fgets(str, size, file->m_file);
526 return result;
527}
528
529static inline int inline_mysql_file_fgetc(
531 const char *src_file, uint src_line,
532#endif
533 MYSQL_FILE *file) {
534 int result;
535#ifdef HAVE_PSI_FILE_INTERFACE
536 struct PSI_file_locker *locker;
538 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
540 if (likely(locker != nullptr)) {
541 PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
542 result = fgetc(file->m_file);
543 PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
544 return result;
545 }
546#endif
547
548 result = fgetc(file->m_file);
549 return result;
550}
551
552static inline int inline_mysql_file_fputs(
554 const char *src_file, uint src_line,
555#endif
556 const char *str, MYSQL_FILE *file) {
557 int result;
558#ifdef HAVE_PSI_FILE_INTERFACE
559 struct PSI_file_locker *locker;
561 size_t bytes;
562 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
564 if (likely(locker != nullptr)) {
565 bytes = str ? strlen(str) : 0;
566 PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line);
567 result = fputs(str, file->m_file);
568 PSI_FILE_CALL(end_file_wait)(locker, bytes);
569 return result;
570 }
571#endif
572
573 result = fputs(str, file->m_file);
574 return result;
575}
576
577static inline int inline_mysql_file_fputc(
579 const char *src_file, uint src_line,
580#endif
581 char c, MYSQL_FILE *file) {
582 int result;
583#ifdef HAVE_PSI_FILE_INTERFACE
584 struct PSI_file_locker *locker;
586 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
588 if (likely(locker != nullptr)) {
589 PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
590 result = fputc(c, file->m_file);
591 PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
592 return result;
593 }
594#endif
595
596 result = fputc(c, file->m_file);
597 return result;
598}
599
600static inline int inline_mysql_file_fprintf(MYSQL_FILE *file,
601 const char *format, ...)
602 MY_ATTRIBUTE((format(printf, 2, 3)));
603
605 const char *format, ...) {
606 /*
607 TODO: figure out how to pass src_file and src_line from the caller.
608 */
609 int result;
610 va_list args;
611#ifdef HAVE_PSI_FILE_INTERFACE
612 struct PSI_file_locker *locker;
614 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
616 if (likely(locker != nullptr)) {
617 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, __FILE__, __LINE__);
618 va_start(args, format);
619 result = vfprintf(file->m_file, format, args);
620 va_end(args);
621 PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
622 return result;
623 }
624#endif
625
626 va_start(args, format);
627 result = vfprintf(file->m_file, format, args);
628 va_end(args);
629 return result;
630}
631
632static inline int inline_mysql_file_vfprintf(
634 const char *src_file, uint src_line,
635#endif
636 MYSQL_FILE *file, const char *format, va_list args)
637#ifdef HAVE_PSI_FILE_INTERFACE
638 MY_ATTRIBUTE((format(printf, 4, 0)));
639#else
640 MY_ATTRIBUTE((format(printf, 2, 0)));
641#endif
642
645 const char *src_file, uint src_line,
646#endif
647 MYSQL_FILE *file, const char *format, va_list args) {
648 int result;
649#ifdef HAVE_PSI_FILE_INTERFACE
650 struct PSI_file_locker *locker;
652 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
654 if (likely(locker != nullptr)) {
655 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
656 result = vfprintf(file->m_file, format, args);
657 PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
658 return result;
659 }
660#endif
661
662 result = vfprintf(file->m_file, format, args);
663 return result;
664}
665
666static inline int inline_mysql_file_fflush(
668 const char *src_file, uint src_line,
669#endif
670 MYSQL_FILE *file) {
671 int result;
672#ifdef HAVE_PSI_FILE_INTERFACE
673 struct PSI_file_locker *locker;
675 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
677 if (likely(locker != nullptr)) {
678 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
679 result = fflush(file->m_file);
680 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
681 return result;
682 }
683#endif
684
685 result = fflush(file->m_file);
686 return result;
687}
688
690 /* Not instrumented, there is no wait involved */
691 return feof(file->m_file);
692}
693
694static inline int inline_mysql_file_fstat(
696 const char *src_file, uint src_line,
697#endif
698 int filenr, MY_STAT *stat_area) {
699 int result;
700#ifdef HAVE_PSI_FILE_INTERFACE
701 struct PSI_file_locker *locker;
703 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr,
705 if (likely(locker != nullptr)) {
706 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
707 result = my_fstat(filenr, stat_area);
708 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
709 return result;
710 }
711#endif
712
713 result = my_fstat(filenr, stat_area);
714 return result;
715}
716
719 PSI_file_key key, const char *src_file, uint src_line,
720#endif
721 const char *path, MY_STAT *stat_area, myf flags) {
723#ifdef HAVE_PSI_FILE_INTERFACE
724 struct PSI_file_locker *locker;
726 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
727 &state, key, PSI_FILE_STAT, path, &locker);
728 if (likely(locker != nullptr)) {
729 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
730 result = my_stat(path, stat_area, flags);
731 PSI_FILE_CALL(end_file_open_wait)(locker, result);
732 return result;
733 }
734#endif
735
736 result = my_stat(path, stat_area, flags);
737 return result;
738}
739
740static inline int inline_mysql_file_chsize(
742 const char *src_file, uint src_line,
743#endif
744 File file, my_off_t newlength, int filler, myf flags) {
745 int result;
746#ifdef HAVE_PSI_FILE_INTERFACE
747 struct PSI_file_locker *locker;
749 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
751 if (likely(locker != nullptr)) {
752 PSI_FILE_CALL(start_file_wait)
753 (locker, (size_t)newlength, src_file, src_line);
754 result = my_chsize(file, newlength, filler, flags);
755 PSI_FILE_CALL(end_file_wait)(locker, (size_t)newlength);
756 return result;
757 }
758#endif
759
760 result = my_chsize(file, newlength, filler, flags);
761 return result;
762}
763
766 PSI_file_key key, const char *src_file, uint src_line,
767#endif
768 const char *filename, int flags, myf myFlags) {
769 MYSQL_FILE *that;
771 MYF(MY_WME));
772 if (likely(that != nullptr)) {
773#ifdef HAVE_PSI_FILE_INTERFACE
774 struct PSI_file_locker *locker;
776 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
777 &state, key, PSI_FILE_STREAM_OPEN, filename, that);
778 if (likely(locker != nullptr)) {
779 PSI_FILE_CALL(start_file_open_wait)
780 (locker, src_file, src_line);
781 that->m_file = my_fopen(filename, flags, myFlags);
782 that->m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
783 if (unlikely(that->m_file == nullptr)) {
784 my_free(that);
785 return nullptr;
786 }
787 return that;
788 }
789#endif
790
791 that->m_psi = nullptr;
792 that->m_file = my_fopen(filename, flags, myFlags);
793 if (unlikely(that->m_file == nullptr)) {
794 my_free(that);
795 return nullptr;
796 }
797 }
798 return that;
799}
800
801static inline int inline_mysql_file_fclose(
803 const char *src_file, uint src_line,
804#endif
806 int result = 0;
807 if (likely(file != nullptr)) {
808#ifdef HAVE_PSI_FILE_INTERFACE
809 struct PSI_file_locker *locker;
811 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(
812 &state, file->m_psi, PSI_FILE_STREAM_CLOSE);
813 if (likely(locker != nullptr)) {
814 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
815 result = my_fclose(file->m_file, flags);
816 PSI_FILE_CALL(end_file_close_wait)(locker, result);
817 my_free(file);
818 return result;
819 }
820#endif
821
822 result = my_fclose(file->m_file, flags);
823 my_free(file);
824 }
825 return result;
826}
827
828static inline size_t inline_mysql_file_fread(
830 const char *src_file, uint src_line,
831#endif
832 MYSQL_FILE *file, uchar *buffer, size_t count, myf flags) {
833 size_t result;
834#ifdef HAVE_PSI_FILE_INTERFACE
835 struct PSI_file_locker *locker;
837 size_t bytes_read;
838 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
840 if (likely(locker != nullptr)) {
841 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
842 result = my_fread(file->m_file, buffer, count, flags);
843 if (flags & (MY_NABP | MY_FNABP)) {
844 bytes_read = (result == 0) ? count : 0;
845 } else {
846 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
847 }
848 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
849 return result;
850 }
851#endif
852
853 result = my_fread(file->m_file, buffer, count, flags);
854 return result;
855}
856
857static inline size_t inline_mysql_file_fwrite(
859 const char *src_file, uint src_line,
860#endif
861 MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags) {
862 size_t result;
863#ifdef HAVE_PSI_FILE_INTERFACE
864 struct PSI_file_locker *locker;
866 size_t bytes_written;
867 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
869 if (likely(locker != nullptr)) {
870 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
871 result = my_fwrite(file->m_file, buffer, count, flags);
872 if (flags & (MY_NABP | MY_FNABP)) {
873 bytes_written = (result == 0) ? count : 0;
874 } else {
875 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
876 }
877 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
878 return result;
879 }
880#endif
881
882 result = my_fwrite(file->m_file, buffer, count, flags);
883 return result;
884}
885
888 const char *src_file, uint src_line,
889#endif
890 MYSQL_FILE *file, my_off_t pos, int whence) {
892#ifdef HAVE_PSI_FILE_INTERFACE
893 struct PSI_file_locker *locker;
895 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
897 if (likely(locker != nullptr)) {
898 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
899 result = my_fseek(file->m_file, pos, whence);
900 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
901 return result;
902 }
903#endif
904
905 result = my_fseek(file->m_file, pos, whence);
906 return result;
907}
908
911 const char *src_file, uint src_line,
912#endif
913 MYSQL_FILE *file) {
915#ifdef HAVE_PSI_FILE_INTERFACE
916 struct PSI_file_locker *locker;
918 locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
920 if (likely(locker != nullptr)) {
921 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
922 result = my_ftell(file->m_file);
923 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
924 return result;
925 }
926#endif
927
928 result = my_ftell(file->m_file);
929 return result;
930}
931
934 PSI_file_key key, const char *src_file, uint src_line,
935#endif
936 const char *filename, int create_flags, int access_flags, myf myFlags) {
937 File file;
938#ifdef HAVE_PSI_FILE_INTERFACE
939 struct PSI_file_locker *locker;
941 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
942 &state, key, PSI_FILE_CREATE, filename, &locker);
943 if (likely(locker != nullptr)) {
944 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
945 file = my_create(filename, create_flags, access_flags, myFlags);
946 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
947 return file;
948 }
949#endif
950
951 file = my_create(filename, create_flags, access_flags, myFlags);
952 return file;
953}
954
957 PSI_file_key key, const char *src_file, uint src_line,
958#endif
959 char *to, const char *dir, const char *pfx, int mode,
960 UnlinkOrKeepFile unlink_or_keep, myf myFlags) {
961 File file;
962#ifdef HAVE_PSI_FILE_INTERFACE
963 struct PSI_file_locker *locker;
965 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
966 &state, key, PSI_FILE_CREATE, nullptr, &locker);
967 if (likely(locker != nullptr)) {
968 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
969 /* The file name is generated by create_temp_file(). */
970 file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
971 PSI_FILE_CALL(end_temp_file_open_wait_and_bind_to_descriptor)
972 (locker, file, (const char *)to);
973 return file;
974 }
975#endif
976
977 file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
978 return file;
979}
980
983 PSI_file_key key, const char *src_file, uint src_line,
984#endif
985 const char *filename, int flags, myf myFlags) {
986 File file;
987#ifdef HAVE_PSI_FILE_INTERFACE
988 struct PSI_file_locker *locker;
990 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
991 &state, key, PSI_FILE_OPEN, filename, &locker);
992 if (likely(locker != nullptr)) {
993 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
994 file = my_open(filename, flags, myFlags);
995 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
996 return file;
997 }
998#endif
999
1000 file = my_open(filename, flags, myFlags);
1001 return file;
1002}
1003
1004static inline int inline_mysql_file_close(
1006 const char *src_file, uint src_line,
1007#endif
1008 File file, myf flags) {
1009 int result;
1010#ifdef HAVE_PSI_FILE_INTERFACE
1011 struct PSI_file_locker *locker;
1013 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1015 if (likely(locker != nullptr)) {
1016 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1018 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1019 return result;
1020 }
1021#endif
1022
1024 return result;
1025}
1026
1027static inline size_t inline_mysql_file_read(
1029 const char *src_file, uint src_line,
1030#endif
1031 File file, uchar *buffer, size_t count, myf flags) {
1032 size_t result;
1033#ifdef HAVE_PSI_FILE_INTERFACE
1034 struct PSI_file_locker *locker;
1036 size_t bytes_read;
1037 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1039 if (likely(locker != nullptr)) {
1040 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1042 if (flags & (MY_NABP | MY_FNABP)) {
1043 bytes_read = (result == 0) ? count : 0;
1044 } else {
1045 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1046 }
1047 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1048 return result;
1049 }
1050#endif
1051
1053 return result;
1054}
1055
1056static inline size_t inline_mysql_file_write(
1058 const char *src_file, uint src_line,
1059#endif
1060 File file, const uchar *buffer, size_t count, myf flags) {
1061 size_t result;
1062#ifdef HAVE_PSI_FILE_INTERFACE
1063 struct PSI_file_locker *locker;
1065 size_t bytes_written;
1066 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1068 if (likely(locker != nullptr)) {
1069 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1071 if (flags & (MY_NABP | MY_FNABP)) {
1072 bytes_written = (result == 0) ? count : 0;
1073 } else {
1074 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1075 }
1076 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1077 return result;
1078 }
1079#endif
1080
1082 return result;
1083}
1084
1085static inline size_t inline_mysql_file_pread(
1087 const char *src_file, uint src_line,
1088#endif
1089 File file, uchar *buffer, size_t count, my_off_t offset, myf flags) {
1090 size_t result;
1091#ifdef HAVE_PSI_FILE_INTERFACE
1092 struct PSI_file_locker *locker;
1094 size_t bytes_read;
1095 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1097 if (likely(locker != nullptr)) {
1098 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1099 result = my_pread(file, buffer, count, offset, flags);
1100 if (flags & (MY_NABP | MY_FNABP)) {
1101 bytes_read = (result == 0) ? count : 0;
1102 } else {
1103 bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1104 }
1105 PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1106 return result;
1107 }
1108#endif
1109
1110 result = my_pread(file, buffer, count, offset, flags);
1111 return result;
1112}
1113
1114static inline size_t inline_mysql_file_pwrite(
1116 const char *src_file, uint src_line,
1117#endif
1118 File file, const uchar *buffer, size_t count, my_off_t offset, myf flags) {
1119 size_t result;
1120#ifdef HAVE_PSI_FILE_INTERFACE
1121 struct PSI_file_locker *locker;
1123 size_t bytes_written;
1124 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1126 if (likely(locker != nullptr)) {
1127 PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1128 result = my_pwrite(file, buffer, count, offset, flags);
1129 if (flags & (MY_NABP | MY_FNABP)) {
1130 bytes_written = (result == 0) ? count : 0;
1131 } else {
1132 bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1133 }
1134 PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1135 return result;
1136 }
1137#endif
1138
1139 result = my_pwrite(file, buffer, count, offset, flags);
1140 return result;
1141}
1142
1145 const char *src_file, uint src_line,
1146#endif
1147 File file, my_off_t pos, int whence, myf flags) {
1149#ifdef HAVE_PSI_FILE_INTERFACE
1150 struct PSI_file_locker *locker;
1152 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1154 if (likely(locker != nullptr)) {
1155 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1156 result = my_seek(file, pos, whence, flags);
1157 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1158 return result;
1159 }
1160#endif
1161
1162 result = my_seek(file, pos, whence, flags);
1163 return result;
1164}
1165
1168 const char *src_file, uint src_line,
1169#endif
1170 File file, myf flags) {
1172#ifdef HAVE_PSI_FILE_INTERFACE
1173 struct PSI_file_locker *locker;
1175 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1177 if (likely(locker != nullptr)) {
1178 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1180 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1181 return result;
1182 }
1183#endif
1184
1186 return result;
1187}
1188
1191 PSI_file_key key, const char *src_file, uint src_line,
1192#endif
1193 const char *name, myf flags) {
1194 int result;
1195#ifdef HAVE_PSI_FILE_INTERFACE
1196 struct PSI_file_locker *locker;
1198 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1199 &state, key, PSI_FILE_DELETE, name, &locker);
1200 if (likely(locker != nullptr)) {
1201 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1203 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1204 return result;
1205 }
1206#endif
1207
1209 return result;
1210}
1211
1214 PSI_file_key key, const char *src_file, uint src_line,
1215#endif
1216 const char *from, const char *to, myf flags) {
1217 int result;
1218#ifdef HAVE_PSI_FILE_INTERFACE
1219 struct PSI_file_locker *locker;
1221 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1222 &state, key, PSI_FILE_RENAME, from, &locker);
1223 if (likely(locker != nullptr)) {
1224 PSI_FILE_CALL(start_file_rename_wait)
1225 (locker, (size_t)0, from, to, src_file, src_line);
1226 result = my_rename(from, to, flags);
1227 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1228 return result;
1229 }
1230#endif
1231
1232 result = my_rename(from, to, flags);
1233 return result;
1234}
1235
1238 PSI_file_key key, const char *src_file, uint src_line,
1239#endif
1240 const char *linkname, const char *filename, int create_flags,
1241 int access_flags, myf flags) {
1242 File file;
1243#ifdef HAVE_PSI_FILE_INTERFACE
1244 struct PSI_file_locker *locker;
1246 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1247 &state, key, PSI_FILE_CREATE, filename, &locker);
1248 if (likely(locker != nullptr)) {
1249 PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
1250 file = my_create_with_symlink(linkname, filename, create_flags,
1251 access_flags, flags);
1252 PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
1253 return file;
1254 }
1255#endif
1256
1257 file = my_create_with_symlink(linkname, filename, create_flags, access_flags,
1258 flags);
1259 return file;
1260}
1261
1264 PSI_file_key key, const char *src_file, uint src_line,
1265#endif
1266 const char *name, myf flags) {
1267 int result;
1268#ifdef HAVE_PSI_FILE_INTERFACE
1269 struct PSI_file_locker *locker;
1271 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1272 &state, key, PSI_FILE_DELETE, name, &locker);
1273 if (likely(locker != nullptr)) {
1274 PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1276 PSI_FILE_CALL(end_file_close_wait)(locker, result);
1277 return result;
1278 }
1279#endif
1280
1282 return result;
1283}
1284
1287 PSI_file_key key, const char *src_file, uint src_line,
1288#endif
1289 const char *from, const char *to, myf flags) {
1290 int result;
1291#ifdef HAVE_PSI_FILE_INTERFACE
1292 struct PSI_file_locker *locker;
1294 locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1295 &state, key, PSI_FILE_RENAME, from, &locker);
1296 if (likely(locker != nullptr)) {
1297 PSI_FILE_CALL(start_file_rename_wait)
1298 (locker, (size_t)0, from, to, src_file, src_line);
1299 result = my_rename_with_symlink(from, to, flags);
1300 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1301 return result;
1302 }
1303#endif
1304
1305 result = my_rename_with_symlink(from, to, flags);
1306 return result;
1307}
1308
1309static inline int inline_mysql_file_sync(
1311 const char *src_file, uint src_line,
1312#endif
1313 File fd, myf flags) {
1314 int result = 0;
1315#ifdef HAVE_PSI_FILE_INTERFACE
1316 struct PSI_file_locker *locker;
1318 locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd,
1320 if (likely(locker != nullptr)) {
1321 PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1322 result = my_sync(fd, flags);
1323 PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1324 return result;
1325 }
1326#endif
1327
1328 result = my_sync(fd, flags);
1329 return result;
1330}
1331
1332/** @} (end of group psi_api_file) */
1333
1334#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:218
my_off_t my_ftell(FILE *stream)
Portable ftell() wrapper.
Definition: my_fstream.cc:165
#define MY_NABP
Definition: my_sys.h:120
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:122
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:119
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:773
#define MY_FILE_ERROR
Definition: my_sys.h:115
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:801
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:1262
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:981
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:740
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:1085
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:857
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:955
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:1143
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:932
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:1285
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:764
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:643
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:1056
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:1189
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:1236
static int inline_mysql_file_close(const char *src_file, uint src_line, File file, myf flags)
Definition: mysql_file.h:1004
static int inline_mysql_file_fputs(const char *src_file, uint src_line, const char *str, MYSQL_FILE *file)
Definition: mysql_file.h:552
static my_off_t inline_mysql_file_tell(const char *src_file, uint src_line, File file, myf flags)
Definition: mysql_file.h:1166
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:717
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:1027
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:1212
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:1114
static int inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format,...)
Definition: mysql_file.h:604
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:886
static void inline_mysql_file_register(const char *category, PSI_file_info *info, int count)
Definition: mysql_file.h:493
static int inline_mysql_file_fstat(const char *src_file, uint src_line, int filenr, MY_STAT *stat_area)
Definition: mysql_file.h:694
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:828
static my_off_t inline_mysql_file_ftell(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:909
static int inline_mysql_file_fgetc(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:529
static int inline_mysql_file_fputc(const char *src_file, uint src_line, char c, MYSQL_FILE *file)
Definition: mysql_file.h:577
static int inline_mysql_file_fflush(const char *src_file, uint src_line, MYSQL_FILE *file)
Definition: mysql_file.h:666
static int inline_mysql_file_sync(const char *src_file, uint src_line, File fd, myf flags)
Definition: mysql_file.h:1309
static char * inline_mysql_file_fgets(const char *src_file, uint src_line, char *str, int size, MYSQL_FILE *file)
Definition: mysql_file.h:506
static int inline_mysql_file_feof(MYSQL_FILE *file)
Definition: mysql_file.h:689
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:9838
constexpr bool likely(bool expr)
Definition: my_compiler.h:54
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:55
int my_fstat(int filenr, MY_STAT *stat_area)
Definition: my_lib.cc:292
#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:302
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:103
Common header for many mysys elements.
static int count
Definition: myisam_ftdump.cc:42
Log info(cout, "NOTE")
static char * path
Definition: mysqldump.cc:133
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1054
const std::string FILE("FILE")
std::string dir
Double write files location.
Definition: buf0dblwr.cc:76
Definition: os0file.h:85
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419
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:482
FILE * m_file
The real file.
Definition: mysql_file.h:484
struct PSI_file * m_psi
The instrumentation hook.
Definition: mysql_file.h:490
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
unsigned int uint
Definition: uca9-dump.cc:74
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:39