Coverage Report

Created: 2025-12-31 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mysql-server/include/mysql/psi/mysql_file.h
Line
Count
Source
1
/* Copyright (c) 2008, 2025, 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"
56
#include "mysql/service_mysql_alloc.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
0
#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
0
#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
0
  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
0
  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
0
  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
*/
484
struct MYSQL_FILE {
485
  /** The real file. */
486
  FILE *m_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
  */
492
  struct PSI_file *m_psi;
493
};
494
495
static inline void inline_mysql_file_register(
496
#ifdef HAVE_PSI_FILE_INTERFACE
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
0
) {
503
0
#ifdef HAVE_PSI_FILE_INTERFACE
504
0
  PSI_FILE_CALL(register_file)(category, info, count);
505
0
#endif
506
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_register(char const*, PSI_file_info_v1*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_register(char const*, PSI_file_info_v1*, int)
507
508
static inline char *inline_mysql_file_fgets(
509
#ifdef HAVE_PSI_FILE_INTERFACE
510
    const char *src_file, uint src_line,
511
#endif
512
0
    char *str, int size, MYSQL_FILE *file) {
513
0
  char *result;
514
0
#ifdef HAVE_PSI_FILE_INTERFACE
515
0
  struct PSI_file_locker *locker;
516
0
  PSI_file_locker_state state;
517
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
518
0
                                                        PSI_FILE_READ);
519
0
  if (likely(locker != nullptr)) {
520
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)size, src_file, src_line);
521
0
    result = fgets(str, size, file->m_file);
522
0
    PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
523
0
    return result;
524
0
  }
525
0
#endif
526
0
527
0
  result = fgets(str, size, file->m_file);
528
0
  return result;
529
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fgets(char const*, unsigned int, char*, int, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fgets(char const*, unsigned int, char*, int, MYSQL_FILE*)
530
531
static inline int inline_mysql_file_fgetc(
532
#ifdef HAVE_PSI_FILE_INTERFACE
533
    const char *src_file, uint src_line,
534
#endif
535
0
    MYSQL_FILE *file) {
536
0
  int result;
537
0
#ifdef HAVE_PSI_FILE_INTERFACE
538
0
  struct PSI_file_locker *locker;
539
0
  PSI_file_locker_state state;
540
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
541
0
                                                        PSI_FILE_READ);
542
0
  if (likely(locker != nullptr)) {
543
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
544
0
    result = fgetc(file->m_file);
545
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
546
0
    return result;
547
0
  }
548
0
#endif
549
0
550
0
  result = fgetc(file->m_file);
551
0
  return result;
552
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fgetc(char const*, unsigned int, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fgetc(char const*, unsigned int, MYSQL_FILE*)
553
554
static inline int inline_mysql_file_fputs(
555
#ifdef HAVE_PSI_FILE_INTERFACE
556
    const char *src_file, uint src_line,
557
#endif
558
0
    const char *str, MYSQL_FILE *file) {
559
0
  int result;
560
0
#ifdef HAVE_PSI_FILE_INTERFACE
561
0
  struct PSI_file_locker *locker;
562
0
  PSI_file_locker_state state;
563
0
  size_t bytes;
564
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
565
0
                                                        PSI_FILE_WRITE);
566
0
  if (likely(locker != nullptr)) {
567
0
    bytes = str ? strlen(str) : 0;
568
0
    PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line);
569
0
    result = fputs(str, file->m_file);
570
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes);
571
0
    return result;
572
0
  }
573
0
#endif
574
0
575
0
  result = fputs(str, file->m_file);
576
0
  return result;
577
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fputs(char const*, unsigned int, char const*, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fputs(char const*, unsigned int, char const*, MYSQL_FILE*)
578
579
static inline int inline_mysql_file_fputc(
580
#ifdef HAVE_PSI_FILE_INTERFACE
581
    const char *src_file, uint src_line,
582
#endif
583
0
    char c, MYSQL_FILE *file) {
584
0
  int result;
585
0
#ifdef HAVE_PSI_FILE_INTERFACE
586
0
  struct PSI_file_locker *locker;
587
0
  PSI_file_locker_state state;
588
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
589
0
                                                        PSI_FILE_WRITE);
590
0
  if (likely(locker != nullptr)) {
591
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)1, src_file, src_line);
592
0
    result = fputc(c, file->m_file);
593
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)1);
594
0
    return result;
595
0
  }
596
0
#endif
597
0
598
0
  result = fputc(c, file->m_file);
599
0
  return result;
600
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fputc(char const*, unsigned int, char, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fputc(char const*, unsigned int, char, MYSQL_FILE*)
601
602
static inline int inline_mysql_file_fprintf(MYSQL_FILE *file,
603
                                            const char *format, ...)
604
    MY_ATTRIBUTE((format(printf, 2, 3)));
605
606
static inline int inline_mysql_file_fprintf(MYSQL_FILE *file,
607
0
                                            const char *format, ...) {
608
0
  /*
609
0
    TODO: figure out how to pass src_file and src_line from the caller.
610
0
  */
611
0
  int result;
612
0
  va_list args;
613
0
#ifdef HAVE_PSI_FILE_INTERFACE
614
0
  struct PSI_file_locker *locker;
615
0
  PSI_file_locker_state state;
616
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
617
0
                                                        PSI_FILE_WRITE);
618
0
  if (likely(locker != nullptr)) {
619
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, __FILE__, __LINE__);
620
0
    va_start(args, format);
621
0
    result = vfprintf(file->m_file, format, args);
622
0
    va_end(args);
623
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
624
0
    return result;
625
0
  }
626
0
#endif
627
0
628
0
  va_start(args, format);
629
0
  result = vfprintf(file->m_file, format, args);
630
0
  va_end(args);
631
0
  return result;
632
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fprintf(MYSQL_FILE*, char const*, ...)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fprintf(MYSQL_FILE*, char const*, ...)
633
634
static inline int inline_mysql_file_vfprintf(
635
#ifdef HAVE_PSI_FILE_INTERFACE
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
645
static inline int inline_mysql_file_vfprintf(
646
#ifdef HAVE_PSI_FILE_INTERFACE
647
    const char *src_file, uint src_line,
648
#endif
649
0
    MYSQL_FILE *file, const char *format, va_list args) {
650
0
  int result;
651
0
#ifdef HAVE_PSI_FILE_INTERFACE
652
0
  struct PSI_file_locker *locker;
653
0
  PSI_file_locker_state state;
654
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
655
0
                                                        PSI_FILE_WRITE);
656
0
  if (likely(locker != nullptr)) {
657
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
658
0
    result = vfprintf(file->m_file, format, args);
659
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)result);
660
0
    return result;
661
0
  }
662
0
#endif
663
0
664
0
  result = vfprintf(file->m_file, format, args);
665
0
  return result;
666
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_vfprintf(char const*, unsigned int, MYSQL_FILE*, char const*, __va_list_tag*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_vfprintf(char const*, unsigned int, MYSQL_FILE*, char const*, __va_list_tag*)
667
668
static inline int inline_mysql_file_fflush(
669
#ifdef HAVE_PSI_FILE_INTERFACE
670
    const char *src_file, uint src_line,
671
#endif
672
0
    MYSQL_FILE *file) {
673
0
  int result;
674
0
#ifdef HAVE_PSI_FILE_INTERFACE
675
0
  struct PSI_file_locker *locker;
676
0
  PSI_file_locker_state state;
677
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
678
0
                                                        PSI_FILE_FLUSH);
679
0
  if (likely(locker != nullptr)) {
680
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
681
0
    result = fflush(file->m_file);
682
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
683
0
    return result;
684
0
  }
685
0
#endif
686
0
687
0
  result = fflush(file->m_file);
688
0
  return result;
689
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fflush(char const*, unsigned int, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fflush(char const*, unsigned int, MYSQL_FILE*)
690
691
0
static inline int inline_mysql_file_feof(MYSQL_FILE *file) {
692
0
  /* Not instrumented, there is no wait involved */
693
0
  return feof(file->m_file);
694
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_feof(MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_feof(MYSQL_FILE*)
695
696
static inline int inline_mysql_file_fstat(
697
#ifdef HAVE_PSI_FILE_INTERFACE
698
    const char *src_file, uint src_line,
699
#endif
700
0
    int filenr, MY_STAT *stat_area) {
701
0
  int result;
702
0
#ifdef HAVE_PSI_FILE_INTERFACE
703
0
  struct PSI_file_locker *locker;
704
0
  PSI_file_locker_state state;
705
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr,
706
0
                                                            PSI_FILE_FSTAT);
707
0
  if (likely(locker != nullptr)) {
708
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
709
0
    result = my_fstat(filenr, stat_area);
710
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
711
0
    return result;
712
0
  }
713
0
#endif
714
0
715
0
  result = my_fstat(filenr, stat_area);
716
0
  return result;
717
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fstat(char const*, unsigned int, int, stat*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fstat(char const*, unsigned int, int, stat*)
718
719
static inline MY_STAT *inline_mysql_file_stat(
720
#ifdef HAVE_PSI_FILE_INTERFACE
721
    PSI_file_key key, const char *src_file, uint src_line,
722
#endif
723
0
    const char *path, MY_STAT *stat_area, myf flags) {
724
0
  MY_STAT *result;
725
0
#ifdef HAVE_PSI_FILE_INTERFACE
726
0
  struct PSI_file_locker *locker = nullptr;
727
0
  PSI_file_locker_state state;
728
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
729
0
      &state, key, PSI_FILE_STAT, path, &locker);
730
0
  if (likely(locker != nullptr)) {
731
0
    PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
732
0
    result = my_stat(path, stat_area, flags);
733
0
    PSI_FILE_CALL(end_file_open_wait)(locker, result);
734
0
    return result;
735
0
  }
736
0
#endif
737
0
738
0
  result = my_stat(path, stat_area, flags);
739
0
  return result;
740
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_stat(unsigned int, char const*, unsigned int, char const*, stat*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_stat(unsigned int, char const*, unsigned int, char const*, stat*, int)
741
742
static inline int inline_mysql_file_chsize(
743
#ifdef HAVE_PSI_FILE_INTERFACE
744
    const char *src_file, uint src_line,
745
#endif
746
0
    File file, my_off_t newlength, int filler, myf flags) {
747
0
  int result;
748
0
#ifdef HAVE_PSI_FILE_INTERFACE
749
0
  struct PSI_file_locker *locker;
750
0
  PSI_file_locker_state state;
751
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
752
0
                                                            PSI_FILE_CHSIZE);
753
0
  if (likely(locker != nullptr)) {
754
0
    PSI_FILE_CALL(start_file_wait)
755
0
    (locker, (size_t)newlength, src_file, src_line);
756
0
    result = my_chsize(file, newlength, filler, flags);
757
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)newlength);
758
0
    return result;
759
0
  }
760
0
#endif
761
0
762
0
  result = my_chsize(file, newlength, filler, flags);
763
0
  return result;
764
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_chsize(char const*, unsigned int, int, unsigned long long, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_chsize(char const*, unsigned int, int, unsigned long long, int, int)
765
766
static inline MYSQL_FILE *inline_mysql_file_fopen(
767
#ifdef HAVE_PSI_FILE_INTERFACE
768
    PSI_file_key key, const char *src_file, uint src_line,
769
#endif
770
0
    const char *filename, int flags, myf myFlags) {
771
0
  MYSQL_FILE *that;
772
0
  that = (MYSQL_FILE *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MYSQL_FILE),
773
0
                                 MYF(MY_WME));
774
0
  if (likely(that != nullptr)) {
775
0
#ifdef HAVE_PSI_FILE_INTERFACE
776
0
    struct PSI_file_locker *locker;
777
0
    PSI_file_locker_state state;
778
0
    locker = PSI_FILE_CALL(get_thread_file_name_locker)(
779
0
        &state, key, PSI_FILE_STREAM_OPEN, filename, that);
780
0
    if (likely(locker != nullptr)) {
781
0
      PSI_FILE_CALL(start_file_open_wait)
782
0
      (locker, src_file, src_line);
783
0
      that->m_file = my_fopen(filename, flags, myFlags);
784
0
      that->m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
785
0
      if (unlikely(that->m_file == nullptr)) {
786
0
        my_free(that);
787
0
        return nullptr;
788
0
      }
789
0
      return that;
790
0
    }
791
0
#endif
792
0
793
0
    that->m_psi = nullptr;
794
0
    that->m_file = my_fopen(filename, flags, myFlags);
795
0
    if (unlikely(that->m_file == nullptr)) {
796
0
      my_free(that);
797
0
      return nullptr;
798
0
    }
799
0
  }
800
0
  return that;
801
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fopen(unsigned int, char const*, unsigned int, char const*, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fopen(unsigned int, char const*, unsigned int, char const*, int, int)
802
803
static inline int inline_mysql_file_fclose(
804
#ifdef HAVE_PSI_FILE_INTERFACE
805
    const char *src_file, uint src_line,
806
#endif
807
0
    MYSQL_FILE *file, myf flags) {
808
0
  int result = 0;
809
0
  if (likely(file != nullptr)) {
810
0
#ifdef HAVE_PSI_FILE_INTERFACE
811
0
    struct PSI_file_locker *locker;
812
0
    PSI_file_locker_state state;
813
0
    locker = PSI_FILE_CALL(get_thread_file_stream_locker)(
814
0
        &state, file->m_psi, PSI_FILE_STREAM_CLOSE);
815
0
    if (likely(locker != nullptr)) {
816
0
      PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
817
0
      result = my_fclose(file->m_file, flags);
818
0
      PSI_FILE_CALL(end_file_close_wait)(locker, result);
819
0
      my_free(file);
820
0
      return result;
821
0
    }
822
0
#endif
823
0
824
0
    result = my_fclose(file->m_file, flags);
825
0
    my_free(file);
826
0
  }
827
0
  return result;
828
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fclose(char const*, unsigned int, MYSQL_FILE*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fclose(char const*, unsigned int, MYSQL_FILE*, int)
829
830
static inline size_t inline_mysql_file_fread(
831
#ifdef HAVE_PSI_FILE_INTERFACE
832
    const char *src_file, uint src_line,
833
#endif
834
0
    MYSQL_FILE *file, uchar *buffer, size_t count, myf flags) {
835
0
  size_t result;
836
0
#ifdef HAVE_PSI_FILE_INTERFACE
837
0
  struct PSI_file_locker *locker;
838
0
  PSI_file_locker_state state;
839
0
  size_t bytes_read;
840
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
841
0
                                                        PSI_FILE_READ);
842
0
  if (likely(locker != nullptr)) {
843
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
844
0
    result = my_fread(file->m_file, buffer, count, flags);
845
0
    if (flags & (MY_NABP | MY_FNABP)) {
846
0
      bytes_read = (result == 0) ? count : 0;
847
0
    } else {
848
0
      bytes_read = (result != MY_FILE_ERROR) ? result : 0;
849
0
    }
850
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
851
0
    return result;
852
0
  }
853
0
#endif
854
0
855
0
  result = my_fread(file->m_file, buffer, count, flags);
856
0
  return result;
857
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fread(char const*, unsigned int, MYSQL_FILE*, unsigned char*, unsigned long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fread(char const*, unsigned int, MYSQL_FILE*, unsigned char*, unsigned long, int)
858
859
static inline size_t inline_mysql_file_fwrite(
860
#ifdef HAVE_PSI_FILE_INTERFACE
861
    const char *src_file, uint src_line,
862
#endif
863
0
    MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags) {
864
0
  size_t result;
865
0
#ifdef HAVE_PSI_FILE_INTERFACE
866
0
  struct PSI_file_locker *locker;
867
0
  PSI_file_locker_state state;
868
0
  size_t bytes_written;
869
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
870
0
                                                        PSI_FILE_WRITE);
871
0
  if (likely(locker != nullptr)) {
872
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
873
0
    result = my_fwrite(file->m_file, buffer, count, flags);
874
0
    if (flags & (MY_NABP | MY_FNABP)) {
875
0
      bytes_written = (result == 0) ? count : 0;
876
0
    } else {
877
0
      bytes_written = (result != MY_FILE_ERROR) ? result : 0;
878
0
    }
879
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
880
0
    return result;
881
0
  }
882
0
#endif
883
0
884
0
  result = my_fwrite(file->m_file, buffer, count, flags);
885
0
  return result;
886
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fwrite(char const*, unsigned int, MYSQL_FILE*, unsigned char const*, unsigned long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fwrite(char const*, unsigned int, MYSQL_FILE*, unsigned char const*, unsigned long, int)
887
888
static inline my_off_t inline_mysql_file_fseek(
889
#ifdef HAVE_PSI_FILE_INTERFACE
890
    const char *src_file, uint src_line,
891
#endif
892
0
    MYSQL_FILE *file, my_off_t pos, int whence) {
893
0
  my_off_t result;
894
0
#ifdef HAVE_PSI_FILE_INTERFACE
895
0
  struct PSI_file_locker *locker;
896
0
  PSI_file_locker_state state;
897
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
898
0
                                                        PSI_FILE_SEEK);
899
0
  if (likely(locker != nullptr)) {
900
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
901
0
    result = my_fseek(file->m_file, pos, whence);
902
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
903
0
    return result;
904
0
  }
905
0
#endif
906
0
907
0
  result = my_fseek(file->m_file, pos, whence);
908
0
  return result;
909
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_fseek(char const*, unsigned int, MYSQL_FILE*, unsigned long long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_fseek(char const*, unsigned int, MYSQL_FILE*, unsigned long long, int)
910
911
static inline my_off_t inline_mysql_file_ftell(
912
#ifdef HAVE_PSI_FILE_INTERFACE
913
    const char *src_file, uint src_line,
914
#endif
915
0
    MYSQL_FILE *file) {
916
0
  my_off_t result;
917
0
#ifdef HAVE_PSI_FILE_INTERFACE
918
0
  struct PSI_file_locker *locker;
919
0
  PSI_file_locker_state state;
920
0
  locker = PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
921
0
                                                        PSI_FILE_TELL);
922
0
  if (likely(locker != nullptr)) {
923
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
924
0
    result = my_ftell(file->m_file);
925
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
926
0
    return result;
927
0
  }
928
0
#endif
929
0
930
0
  result = my_ftell(file->m_file);
931
0
  return result;
932
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_ftell(char const*, unsigned int, MYSQL_FILE*)
Unexecuted instantiation: my_init.cc:inline_mysql_file_ftell(char const*, unsigned int, MYSQL_FILE*)
933
934
static inline File inline_mysql_file_create(
935
#ifdef HAVE_PSI_FILE_INTERFACE
936
    PSI_file_key key, const char *src_file, uint src_line,
937
#endif
938
0
    const char *filename, int create_flags, int access_flags, myf myFlags) {
939
0
  File file;
940
0
#ifdef HAVE_PSI_FILE_INTERFACE
941
0
  struct PSI_file_locker *locker = nullptr;
942
0
  PSI_file_locker_state state;
943
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
944
0
      &state, key, PSI_FILE_CREATE, filename, &locker);
945
0
  if (likely(locker != nullptr)) {
946
0
    PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
947
0
    file = my_create(filename, create_flags, access_flags, myFlags);
948
0
    PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
949
0
    return file;
950
0
  }
951
0
#endif
952
0
953
0
  file = my_create(filename, create_flags, access_flags, myFlags);
954
0
  return file;
955
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_create(unsigned int, char const*, unsigned int, char const*, int, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_create(unsigned int, char const*, unsigned int, char const*, int, int, int)
956
957
static inline File inline_mysql_file_create_temp(
958
#ifdef HAVE_PSI_FILE_INTERFACE
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
0
    UnlinkOrKeepFile unlink_or_keep, myf myFlags) {
963
0
  File file;
964
0
#ifdef HAVE_PSI_FILE_INTERFACE
965
0
  struct PSI_file_locker *locker = nullptr;
966
0
  PSI_file_locker_state state;
967
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
968
0
      &state, key, PSI_FILE_CREATE, nullptr, &locker);
969
0
  if (likely(locker != nullptr)) {
970
0
    PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
971
0
    /* The file name is generated by create_temp_file(). */
972
0
    file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
973
0
    PSI_FILE_CALL(end_temp_file_open_wait_and_bind_to_descriptor)
974
0
    (locker, file, (const char *)to);
975
0
    return file;
976
0
  }
977
0
#endif
978
0
979
0
  file = create_temp_file(to, dir, pfx, mode, unlink_or_keep, myFlags);
980
0
  return file;
981
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_create_temp(unsigned int, char const*, unsigned int, char*, char const*, char const*, int, UnlinkOrKeepFile, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_create_temp(unsigned int, char const*, unsigned int, char*, char const*, char const*, int, UnlinkOrKeepFile, int)
982
983
static inline File inline_mysql_file_open(
984
#ifdef HAVE_PSI_FILE_INTERFACE
985
    PSI_file_key key, const char *src_file, uint src_line,
986
#endif
987
0
    const char *filename, int flags, myf myFlags) {
988
0
  File file;
989
0
#ifdef HAVE_PSI_FILE_INTERFACE
990
0
  struct PSI_file_locker *locker = nullptr;
991
0
  PSI_file_locker_state state;
992
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
993
0
      &state, key, PSI_FILE_OPEN, filename, &locker);
994
0
  if (likely(locker != nullptr)) {
995
0
    PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
996
0
    file = my_open(filename, flags, myFlags);
997
0
    PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
998
0
    return file;
999
0
  }
1000
0
#endif
1001
1002
0
  file = my_open(filename, flags, myFlags);
1003
0
  return file;
1004
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_open(unsigned int, char const*, unsigned int, char const*, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_open(unsigned int, char const*, unsigned int, char const*, int, int)
1005
1006
static inline int inline_mysql_file_close(
1007
#ifdef HAVE_PSI_FILE_INTERFACE
1008
    const char *src_file, uint src_line,
1009
#endif
1010
0
    File file, myf flags) {
1011
0
  int result;
1012
0
#ifdef HAVE_PSI_FILE_INTERFACE
1013
0
  struct PSI_file_locker *locker;
1014
0
  PSI_file_locker_state state;
1015
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1016
0
                                                            PSI_FILE_CLOSE);
1017
0
  if (likely(locker != nullptr)) {
1018
0
    PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1019
0
    result = my_close(file, flags);
1020
0
    PSI_FILE_CALL(end_file_close_wait)(locker, result);
1021
0
    return result;
1022
0
  }
1023
0
#endif
1024
1025
0
  result = my_close(file, flags);
1026
0
  return result;
1027
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_close(char const*, unsigned int, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_close(char const*, unsigned int, int, int)
1028
1029
static inline size_t inline_mysql_file_read(
1030
#ifdef HAVE_PSI_FILE_INTERFACE
1031
    const char *src_file, uint src_line,
1032
#endif
1033
0
    File file, uchar *buffer, size_t count, myf flags) {
1034
0
  size_t result;
1035
0
#ifdef HAVE_PSI_FILE_INTERFACE
1036
0
  struct PSI_file_locker *locker;
1037
0
  PSI_file_locker_state state;
1038
0
  size_t bytes_read;
1039
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1040
0
                                                            PSI_FILE_READ);
1041
0
  if (likely(locker != nullptr)) {
1042
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1043
0
    result = my_read(file, buffer, count, flags);
1044
0
    if (flags & (MY_NABP | MY_FNABP)) {
1045
0
      bytes_read = (result == 0) ? count : 0;
1046
0
    } else {
1047
0
      bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1048
0
    }
1049
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1050
0
    return result;
1051
0
  }
1052
0
#endif
1053
1054
0
  result = my_read(file, buffer, count, flags);
1055
0
  return result;
1056
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_read(char const*, unsigned int, int, unsigned char*, unsigned long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_read(char const*, unsigned int, int, unsigned char*, unsigned long, int)
1057
1058
static inline size_t inline_mysql_file_write(
1059
#ifdef HAVE_PSI_FILE_INTERFACE
1060
    const char *src_file, uint src_line,
1061
#endif
1062
0
    File file, const uchar *buffer, size_t count, myf flags) {
1063
0
  size_t result;
1064
0
#ifdef HAVE_PSI_FILE_INTERFACE
1065
0
  struct PSI_file_locker *locker;
1066
0
  PSI_file_locker_state state;
1067
0
  size_t bytes_written;
1068
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1069
0
                                                            PSI_FILE_WRITE);
1070
0
  if (likely(locker != nullptr)) {
1071
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1072
0
    result = my_write(file, buffer, count, flags);
1073
0
    if (flags & (MY_NABP | MY_FNABP)) {
1074
0
      bytes_written = (result == 0) ? count : 0;
1075
0
    } else {
1076
0
      bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1077
0
    }
1078
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1079
0
    return result;
1080
0
  }
1081
0
#endif
1082
0
1083
0
  result = my_write(file, buffer, count, flags);
1084
0
  return result;
1085
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_write(char const*, unsigned int, int, unsigned char const*, unsigned long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_write(char const*, unsigned int, int, unsigned char const*, unsigned long, int)
1086
1087
static inline size_t inline_mysql_file_pread(
1088
#ifdef HAVE_PSI_FILE_INTERFACE
1089
    const char *src_file, uint src_line,
1090
#endif
1091
0
    File file, uchar *buffer, size_t count, my_off_t offset, myf flags) {
1092
0
  size_t result;
1093
0
#ifdef HAVE_PSI_FILE_INTERFACE
1094
0
  struct PSI_file_locker *locker;
1095
0
  PSI_file_locker_state state;
1096
0
  size_t bytes_read;
1097
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1098
0
                                                            PSI_FILE_READ);
1099
0
  if (likely(locker != nullptr)) {
1100
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1101
0
    result = my_pread(file, buffer, count, offset, flags);
1102
0
    if (flags & (MY_NABP | MY_FNABP)) {
1103
0
      bytes_read = (result == 0) ? count : 0;
1104
0
    } else {
1105
0
      bytes_read = (result != MY_FILE_ERROR) ? result : 0;
1106
0
    }
1107
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
1108
0
    return result;
1109
0
  }
1110
0
#endif
1111
0
1112
0
  result = my_pread(file, buffer, count, offset, flags);
1113
0
  return result;
1114
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_pread(char const*, unsigned int, int, unsigned char*, unsigned long, unsigned long long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_pread(char const*, unsigned int, int, unsigned char*, unsigned long, unsigned long long, int)
1115
1116
static inline size_t inline_mysql_file_pwrite(
1117
#ifdef HAVE_PSI_FILE_INTERFACE
1118
    const char *src_file, uint src_line,
1119
#endif
1120
0
    File file, const uchar *buffer, size_t count, my_off_t offset, myf flags) {
1121
0
  size_t result;
1122
0
#ifdef HAVE_PSI_FILE_INTERFACE
1123
0
  struct PSI_file_locker *locker;
1124
0
  PSI_file_locker_state state;
1125
0
  size_t bytes_written;
1126
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1127
0
                                                            PSI_FILE_WRITE);
1128
0
  if (likely(locker != nullptr)) {
1129
0
    PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
1130
0
    result = my_pwrite(file, buffer, count, offset, flags);
1131
0
    if (flags & (MY_NABP | MY_FNABP)) {
1132
0
      bytes_written = (result == 0) ? count : 0;
1133
0
    } else {
1134
0
      bytes_written = (result != MY_FILE_ERROR) ? result : 0;
1135
0
    }
1136
0
    PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
1137
0
    return result;
1138
0
  }
1139
0
#endif
1140
0
1141
0
  result = my_pwrite(file, buffer, count, offset, flags);
1142
0
  return result;
1143
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_pwrite(char const*, unsigned int, int, unsigned char const*, unsigned long, unsigned long long, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_pwrite(char const*, unsigned int, int, unsigned char const*, unsigned long, unsigned long long, int)
1144
1145
static inline my_off_t inline_mysql_file_seek(
1146
#ifdef HAVE_PSI_FILE_INTERFACE
1147
    const char *src_file, uint src_line,
1148
#endif
1149
0
    File file, my_off_t pos, int whence, myf flags) {
1150
0
  my_off_t result;
1151
0
#ifdef HAVE_PSI_FILE_INTERFACE
1152
0
  struct PSI_file_locker *locker;
1153
0
  PSI_file_locker_state state;
1154
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1155
0
                                                            PSI_FILE_SEEK);
1156
0
  if (likely(locker != nullptr)) {
1157
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1158
0
    result = my_seek(file, pos, whence, flags);
1159
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1160
0
    return result;
1161
0
  }
1162
0
#endif
1163
0
1164
0
  result = my_seek(file, pos, whence, flags);
1165
0
  return result;
1166
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_seek(char const*, unsigned int, int, unsigned long long, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_seek(char const*, unsigned int, int, unsigned long long, int, int)
1167
1168
static inline my_off_t inline_mysql_file_tell(
1169
#ifdef HAVE_PSI_FILE_INTERFACE
1170
    const char *src_file, uint src_line,
1171
#endif
1172
0
    File file, myf flags) {
1173
0
  my_off_t result;
1174
0
#ifdef HAVE_PSI_FILE_INTERFACE
1175
0
  struct PSI_file_locker *locker;
1176
0
  PSI_file_locker_state state;
1177
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file,
1178
0
                                                            PSI_FILE_TELL);
1179
0
  if (likely(locker != nullptr)) {
1180
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1181
0
    result = my_tell(file, flags);
1182
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1183
0
    return result;
1184
0
  }
1185
0
#endif
1186
0
1187
0
  result = my_tell(file, flags);
1188
0
  return result;
1189
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_tell(char const*, unsigned int, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_tell(char const*, unsigned int, int, int)
1190
1191
static inline int inline_mysql_file_delete(
1192
#ifdef HAVE_PSI_FILE_INTERFACE
1193
    PSI_file_key key, const char *src_file, uint src_line,
1194
#endif
1195
0
    const char *name, myf flags) {
1196
0
  int result;
1197
0
#ifdef HAVE_PSI_FILE_INTERFACE
1198
0
  struct PSI_file_locker *locker = nullptr;
1199
0
  PSI_file_locker_state state;
1200
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1201
0
      &state, key, PSI_FILE_DELETE, name, &locker);
1202
0
  if (likely(locker != nullptr)) {
1203
0
    PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1204
0
    result = my_delete(name, flags);
1205
0
    PSI_FILE_CALL(end_file_close_wait)(locker, result);
1206
0
    return result;
1207
0
  }
1208
0
#endif
1209
0
1210
0
  result = my_delete(name, flags);
1211
0
  return result;
1212
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_delete(unsigned int, char const*, unsigned int, char const*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_delete(unsigned int, char const*, unsigned int, char const*, int)
1213
1214
static inline int inline_mysql_file_rename(
1215
#ifdef HAVE_PSI_FILE_INTERFACE
1216
    PSI_file_key key, const char *src_file, uint src_line,
1217
#endif
1218
0
    const char *from, const char *to, myf flags) {
1219
0
  int result;
1220
0
#ifdef HAVE_PSI_FILE_INTERFACE
1221
0
  struct PSI_file_locker *locker = nullptr;
1222
0
  PSI_file_locker_state state;
1223
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1224
0
      &state, key, PSI_FILE_RENAME, from, &locker);
1225
0
  if (likely(locker != nullptr)) {
1226
0
    PSI_FILE_CALL(start_file_rename_wait)
1227
0
    (locker, (size_t)0, from, to, src_file, src_line);
1228
0
    result = my_rename(from, to, flags);
1229
0
    PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1230
0
    return result;
1231
0
  }
1232
0
#endif
1233
0
1234
0
  result = my_rename(from, to, flags);
1235
0
  return result;
1236
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_rename(unsigned int, char const*, unsigned int, char const*, char const*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_rename(unsigned int, char const*, unsigned int, char const*, char const*, int)
1237
1238
static inline File inline_mysql_file_create_with_symlink(
1239
#ifdef HAVE_PSI_FILE_INTERFACE
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
0
    int access_flags, myf flags) {
1244
0
  File file;
1245
0
#ifdef HAVE_PSI_FILE_INTERFACE
1246
0
  struct PSI_file_locker *locker = nullptr;
1247
0
  PSI_file_locker_state state;
1248
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1249
0
      &state, key, PSI_FILE_CREATE, filename, &locker);
1250
0
  if (likely(locker != nullptr)) {
1251
0
    PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
1252
0
    file = my_create_with_symlink(linkname, filename, create_flags,
1253
0
                                  access_flags, flags);
1254
0
    PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
1255
0
    return file;
1256
0
  }
1257
0
#endif
1258
0
1259
0
  file = my_create_with_symlink(linkname, filename, create_flags, access_flags,
1260
0
                                flags);
1261
0
  return file;
1262
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_create_with_symlink(unsigned int, char const*, unsigned int, char const*, char const*, int, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_create_with_symlink(unsigned int, char const*, unsigned int, char const*, char const*, int, int, int)
1263
1264
static inline int inline_mysql_file_delete_with_symlink(
1265
#ifdef HAVE_PSI_FILE_INTERFACE
1266
    PSI_file_key key, const char *src_file, uint src_line,
1267
#endif
1268
0
    const char *name, myf flags) {
1269
0
  int result;
1270
0
#ifdef HAVE_PSI_FILE_INTERFACE
1271
0
  struct PSI_file_locker *locker = nullptr;
1272
0
  PSI_file_locker_state state;
1273
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1274
0
      &state, key, PSI_FILE_DELETE, name, &locker);
1275
0
  if (likely(locker != nullptr)) {
1276
0
    PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
1277
0
    result = my_delete_with_symlink(name, flags);
1278
0
    PSI_FILE_CALL(end_file_close_wait)(locker, result);
1279
0
    return result;
1280
0
  }
1281
0
#endif
1282
0
1283
0
  result = my_delete_with_symlink(name, flags);
1284
0
  return result;
1285
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_delete_with_symlink(unsigned int, char const*, unsigned int, char const*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_delete_with_symlink(unsigned int, char const*, unsigned int, char const*, int)
1286
1287
static inline int inline_mysql_file_rename_with_symlink(
1288
#ifdef HAVE_PSI_FILE_INTERFACE
1289
    PSI_file_key key, const char *src_file, uint src_line,
1290
#endif
1291
0
    const char *from, const char *to, myf flags) {
1292
0
  int result;
1293
0
#ifdef HAVE_PSI_FILE_INTERFACE
1294
0
  struct PSI_file_locker *locker = nullptr;
1295
0
  PSI_file_locker_state state;
1296
0
  locker = PSI_FILE_CALL(get_thread_file_name_locker)(
1297
0
      &state, key, PSI_FILE_RENAME, from, &locker);
1298
0
  if (likely(locker != nullptr)) {
1299
0
    PSI_FILE_CALL(start_file_rename_wait)
1300
0
    (locker, (size_t)0, from, to, src_file, src_line);
1301
0
    result = my_rename_with_symlink(from, to, flags);
1302
0
    PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
1303
0
    return result;
1304
0
  }
1305
0
#endif
1306
0
1307
0
  result = my_rename_with_symlink(from, to, flags);
1308
0
  return result;
1309
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_rename_with_symlink(unsigned int, char const*, unsigned int, char const*, char const*, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_rename_with_symlink(unsigned int, char const*, unsigned int, char const*, char const*, int)
1310
1311
static inline int inline_mysql_file_sync(
1312
#ifdef HAVE_PSI_FILE_INTERFACE
1313
    const char *src_file, uint src_line,
1314
#endif
1315
0
    File fd, myf flags) {
1316
0
  int result = 0;
1317
0
#ifdef HAVE_PSI_FILE_INTERFACE
1318
0
  struct PSI_file_locker *locker;
1319
0
  PSI_file_locker_state state;
1320
0
  locker = PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd,
1321
0
                                                            PSI_FILE_SYNC);
1322
0
  if (likely(locker != nullptr)) {
1323
0
    PSI_FILE_CALL(start_file_wait)(locker, (size_t)0, src_file, src_line);
1324
0
    result = my_sync(fd, flags);
1325
0
    PSI_FILE_CALL(end_file_wait)(locker, (size_t)0);
1326
0
    return result;
1327
0
  }
1328
0
#endif
1329
0
1330
0
  result = my_sync(fd, flags);
1331
0
  return result;
1332
0
}
Unexecuted instantiation: charset.cc:inline_mysql_file_sync(char const*, unsigned int, int, int)
Unexecuted instantiation: my_init.cc:inline_mysql_file_sync(char const*, unsigned int, int, int)
1333
1334
/** @} (end of group psi_api_file) */
1335
1336
#endif