MySQL 8.4.2
Source Code Documentation
mysys_priv.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file mysys/mysys_priv.h
26*/
27
28#ifndef MYSYS_PRIV_INCLUDED
29#define MYSYS_PRIV_INCLUDED
30
31#include <memory> // std::unique_ptr
32
33#include "my_macros.h"
34
35#include "my_psi_config.h"
36#include "mysql/components/services/bits/mysql_mutex_bits.h" // for mysql_mutex_t
38#include "mysql/components/services/bits/psi_file_bits.h" // for PSI_file_key
39#include "mysql/components/services/bits/psi_memory_bits.h" // for PSI_memory_key
41#include "mysql/components/services/bits/psi_rwlock_bits.h" // for PSI_rwlock_key
42#include "mysql/components/services/bits/psi_stage_bits.h" // for PSI_stage_info
43#include "mysql/components/services/bits/psi_thread_bits.h" // for PSI_thread_key
44#include "mysql/psi/mysql_mutex.h" // for mysql_mutex_lock
45
51
53
56
58
61
62#ifdef HAVE_LINUX_LARGE_PAGES
64#endif /* HAVE_LINUX_LARGE_PAGES */
66
67/* These keys are always defined. */
68
86
87#ifdef _WIN32
88extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
89extern PSI_memory_key key_memory_win_PACL;
90extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
91extern PSI_memory_key key_memory_win_handle_info;
92#endif
93
95
96/*
97 EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
98 system, we set it to some value which can never happen.
99*/
100#ifndef EDQUOT
101#define EDQUOT (-1)
102#endif
103
104namespace mysys_priv {
105template <class SYSC, class RET>
106inline RET RetryOnEintr(SYSC &&sysc, RET err) {
107 RET r;
108 do {
109 r = sysc();
110 } while (r == err && errno == EINTR);
111 return r;
112}
113} // namespace mysys_priv
114
116
117#ifdef _WIN32
118#include <stdint.h> // int64_t
119#include <sys/stat.h>
120// my_winfile.cc exports, should not be used outside mysys
121File my_win_open(const char *path, int oflag);
122int my_win_close(File fd);
123int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset);
124int64_t my_win_pwrite(File fd, const uchar *buffer, size_t count,
125 int64_t offset);
126int64_t my_win_lseek(File fd, int64_t pos, int whence);
127int64_t my_win_write(File fd, const uchar *buffer, size_t count);
128int my_win_chsize(File fd, int64_t newlength);
130FILE *my_win_fopen(const char *filename, const char *mode);
131FILE *my_win_fdopen(File Filedes, const char *mode);
132File my_win_fclose(FILE *stream);
133FILE *my_win_freopen(const char *path, const char *mode, FILE *stream);
134int my_win_fstat(File fd, struct _stati64 *buf);
135int my_win_stat(const char *path, struct _stati64 *buf);
136int my_win_fsync(File fd);
137
138void MyWinfileInit();
139void MyWinfileEnd();
140
141#endif /* _WIN32 */
142
143namespace file_info {
144
145/**
146 How was this file opened (for debugging purposes).
147 The important part is whether it is UNOPEN or not.
148*/
149enum class OpenType : char {
150 UNOPEN = 0,
151 FILE_BY_OPEN,
152 FILE_BY_CREATE,
153 STREAM_BY_FOPEN,
154 STREAM_BY_FDOPEN,
155 FILE_BY_MKSTEMP,
156 FILE_BY_O_TMPFILE
157};
158
161
162void RegisterFilename(File fd, const char *FileName, OpenType type_of_file);
164} // namespace file_info
165
166void MyFileInit();
167void MyFileEnd();
168
169#endif /* MYSYS_PRIV_INCLUDED */
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:48
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:44
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:50
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:10162
unsigned char uchar
Definition: my_inttypes.h:52
int File
Definition: my_io_bits.h:51
Some common macros.
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
int my_win_stat(const char *path, struct _stati64 *buf)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:848
FILE * my_win_freopen(const char *path, const char *mode, FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:760
void MyWinfileEnd()
Destroys static objects.
Definition: my_winfile.cc:896
int my_win_fstat(File fd, struct _stati64 *buf)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:810
int my_win_close(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:442
int64_t my_win_pwrite(File fd, const uchar *buffer, size_t count, int64_t offset)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:511
int my_win_fsync(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:875
int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:472
File my_win_open(const char *path, int mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:428
int my_win_fclose(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:735
void MyWinfileInit()
Constructs static objects.
Definition: my_winfile.cc:889
File my_win_fileno(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:635
FILE * my_win_fdopen(File fd, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:707
int my_win_chsize(File fd, int64_t newlength)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:604
int64_t my_win_lseek(File fd, int64_t pos, int whence)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:541
FILE * my_win_fopen(const char *filename, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:662
int64_t my_win_write(File fd, const uchar *Buffer, size_t Count)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:570
static int count
Definition: myisam_ftdump.cc:45
ABI for instrumented mutexes.
static char * path
Definition: mysqldump.cc:149
PSI_memory_key key_memory_my_err_head
Definition: my_static.cc:64
PSI_mutex_key key_IO_CACHE_SHARE_mutex
Definition: mysys_priv.h:46
PSI_mutex_key key_THR_LOCK_malloc
Definition: mysys_priv.h:48
PSI_memory_key key_memory_SAFE_HASH_ENTRY
Definition: my_static.cc:61
PSI_memory_key key_memory_lf_node
Definition: my_static.cc:55
void MyFileEnd()
Destroys static objects.
Definition: my_file.cc:285
PSI_memory_key key_memory_MY_DIR
Definition: my_static.cc:67
PSI_mutex_key key_THR_LOCK_myisam_mmap
Definition: mysys_priv.h:50
mysql_mutex_t THR_LOCK_net
Definition: my_thr_init.cc:78
mysql_mutex_t THR_LOCK_malloc
Definition: my_thr_init.cc:75
PSI_file_key key_file_charset
Definition: my_init.cc:515
PSI_cond_key key_IO_CACHE_SHARE_cond
Definition: my_init.cc:499
void my_error_unregister_all()
Unregister all formerly registered error messages.
Definition: my_error.cc:411
PSI_rwlock_key key_SAFE_HASH_lock
Definition: my_init.cc:492
PSI_mutex_key key_THR_LOCK_net
Definition: mysys_priv.h:49
PSI_mutex_key key_THR_LOCK_lock
Definition: mysys_priv.h:47
PSI_memory_key key_memory_lf_slist
Definition: my_static.cc:57
PSI_memory_key key_memory_IO_CACHE
Definition: my_static.cc:59
PSI_memory_key key_memory_defaults
Definition: my_default.cc:136
PSI_stage_info stage_waiting_for_table_level_lock
Definition: my_init.cc:454
PSI_memory_key key_memory_LIST
Definition: my_static.cc:58
PSI_memory_key key_memory_TREE
Definition: my_static.cc:70
PSI_memory_key key_memory_KEY_CACHE
Definition: my_static.cc:60
PSI_mutex_key key_THR_LOCK_threads
Definition: mysys_priv.h:49
PSI_mutex_key key_TMPDIR_mutex
Definition: mysys_priv.h:49
PSI_mutex_key key_THR_LOCK_mutex
Definition: mysys_priv.h:48
PSI_memory_key key_memory_MY_TMPDIR_full_list
Definition: my_static.cc:68
PSI_mutex_key key_IO_CACHE_append_buffer_lock
Definition: my_init.cc:460
PSI_cond_key key_THR_COND_threads
Definition: mysys_priv.h:55
PSI_file_key key_file_proc_meminfo
Definition: my_init.cc:513
PSI_memory_key key_memory_DYNAMIC_STRING
Definition: my_static.cc:69
PSI_mutex_key key_THR_LOCK_open
Definition: mysys_priv.h:49
PSI_mutex_key key_THR_LOCK_heap
Definition: mysys_priv.h:47
PSI_memory_key key_memory_my_file_info
Definition: my_static.cc:65
mysql_mutex_t THR_LOCK_open
Definition: mysys_priv.h:59
void MyFileInit()
Constructs static objects.
Definition: my_file.cc:277
PSI_memory_key key_memory_charset_loader
Definition: my_static.cc:54
PSI_thread_key key_thread_timer_notifier
Definition: my_static.cc:72
PSI_mutex_key key_THR_LOCK_myisam
Definition: mysys_priv.h:48
PSI_memory_key key_memory_my_compress_alloc
Definition: my_static.cc:63
PSI_memory_key key_memory_lf_dynarray
Definition: my_static.cc:56
PSI_cond_key key_IO_CACHE_SHARE_cond_writer
Definition: mysys_priv.h:54
PSI_mutex_key key_KEY_CACHE_cache_lock
Definition: mysys_priv.h:47
PSI_memory_key key_memory_MY_BITMAP_bitmap
Definition: my_static.cc:62
Definition: buf0block_hint.cc:30
const std::string FILE("FILE")
Definition: my_file.cc:181
void RegisterFilename(File fd, const char *FileName, OpenType type_of_file)
void UnregisterFilename(File fd)
void CountFileOpen(OpenType pt, OpenType ct)
void CountFileClose(OpenType ft)
Definition: os0file.h:89
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:927
Definition: mysys_priv.h:104
RET RetryOnEintr(SYSC &&sysc, RET err)
Definition: mysys_priv.h:106
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
mode
Definition: file_handle.h:61
const char * filename
Definition: pfs_example_component_population.cc:67
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
Instrumentation helpers for mutexes.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Instrumentation helpers for mutexes.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Stage instrument information.
Definition: psi_stage_bits.h:74
OpenType
How was this file opened (for debugging purposes).
Definition: mysys_priv.h:149
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50