MySQL 8.0.39
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_inttypes.h" // myf
34#include "my_macros.h"
35
36#include "my_psi_config.h"
37#include "mysql/components/services/bits/mysql_mutex_bits.h" // for mysql_mutex_t
39#include "mysql/components/services/bits/psi_file_bits.h" // for PSI_file_key
40#include "mysql/components/services/bits/psi_memory_bits.h" // for PSI_memory_key
42#include "mysql/components/services/bits/psi_rwlock_bits.h" // for PSI_rwlock_key
43#include "mysql/components/services/bits/psi_stage_bits.h" // for PSI_stage_info
44#include "mysql/components/services/bits/psi_thread_bits.h" // for PSI_thread_key
45#include "mysql/psi/mysql_mutex.h" // for mysql_mutex_lock
46
52
54
57
59
63
64#ifdef HAVE_LINUX_LARGE_PAGES
66#endif /* HAVE_LINUX_LARGE_PAGES */
68
69/* These keys are always defined. */
70
89
90#ifdef _WIN32
91extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
92extern PSI_memory_key key_memory_win_PACL;
93extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
94extern PSI_memory_key key_memory_win_handle_info;
95#endif
96
98
99/*
100 EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
101 system, we set it to some value which can never happen.
102*/
103#ifndef EDQUOT
104#define EDQUOT (-1)
105#endif
106
107namespace mysys_priv {
108template <class SYSC, class RET>
109inline RET RetryOnEintr(SYSC &&sysc, RET err) {
110 RET r;
111 do {
112 r = sysc();
113 } while (r == err && errno == EINTR);
114 return r;
115}
116} // namespace mysys_priv
117
119
120#ifdef _WIN32
121#include <stdint.h> // int64_t
122#include <sys/stat.h>
123// my_winfile.cc exports, should not be used outside mysys
124File my_win_open(const char *path, int oflag);
125int my_win_close(File fd);
126int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset);
127int64_t my_win_pwrite(File fd, const uchar *buffer, size_t count,
128 int64_t offset);
129int64_t my_win_lseek(File fd, int64_t pos, int whence);
130int64_t my_win_write(File fd, const uchar *buffer, size_t count);
131int my_win_chsize(File fd, int64_t newlength);
133FILE *my_win_fopen(const char *filename, const char *mode);
134FILE *my_win_fdopen(File Filedes, const char *mode);
135File my_win_fclose(FILE *stream);
136FILE *my_win_freopen(const char *path, const char *mode, FILE *stream);
137int my_win_fstat(File fd, struct _stati64 *buf);
138int my_win_stat(const char *path, struct _stati64 *buf);
139int my_win_fsync(File fd);
140
141void MyWinfileInit();
142void MyWinfileEnd();
143
144#endif /* _WIN32 */
145
146namespace file_info {
147
148/**
149 How was this file opened (for debugging purposes).
150 The important part is whether it is UNOPEN or not.
151*/
152enum class OpenType : char {
153 UNOPEN = 0,
154 FILE_BY_OPEN,
155 FILE_BY_CREATE,
156 STREAM_BY_FOPEN,
157 STREAM_BY_FDOPEN,
158 FILE_BY_MKSTEMP,
159 FILE_BY_O_TMPFILE
160};
161
164
165void RegisterFilename(File fd, const char *FileName, OpenType type_of_file);
167} // namespace file_info
168
169void MyFileInit();
170void MyFileEnd();
171
172#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:9912
Some integer typedefs for easier portability.
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:845
FILE * my_win_freopen(const char *path, const char *mode, FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:757
void MyWinfileEnd()
Destroys static objects.
Definition: my_winfile.cc:893
int my_win_fstat(File fd, struct _stati64 *buf)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:807
int my_win_close(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:439
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:508
int my_win_fsync(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:872
int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:469
File my_win_open(const char *path, int mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:425
int my_win_fclose(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:732
void MyWinfileInit()
Constructs static objects.
Definition: my_winfile.cc:886
File my_win_fileno(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:632
FILE * my_win_fdopen(File fd, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:704
int my_win_chsize(File fd, int64_t newlength)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:601
int64_t my_win_lseek(File fd, int64_t pos, int whence)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:538
FILE * my_win_fopen(const char *filename, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:659
int64_t my_win_write(File fd, const uchar *Buffer, size_t Count)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:567
static int count
Definition: myisam_ftdump.cc:43
ABI for instrumented mutexes.
static char * path
Definition: mysqldump.cc:137
PSI_memory_key key_memory_my_err_head
Definition: my_static.cc:65
PSI_mutex_key key_IO_CACHE_SHARE_mutex
Definition: mysys_priv.h:47
PSI_mutex_key key_THR_LOCK_malloc
Definition: mysys_priv.h:49
PSI_memory_key key_memory_SAFE_HASH_ENTRY
Definition: my_static.cc:62
PSI_memory_key key_memory_lf_node
Definition: my_static.cc:56
void MyFileEnd()
Destroys static objects.
Definition: my_file.cc:285
PSI_memory_key key_memory_MY_DIR
Definition: my_static.cc:68
PSI_mutex_key key_THR_LOCK_myisam_mmap
Definition: mysys_priv.h:51
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:514
PSI_cond_key key_IO_CACHE_SHARE_cond
Definition: my_init.cc:498
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:491
PSI_mutex_key key_THR_LOCK_net
Definition: mysys_priv.h:50
PSI_mutex_key key_THR_LOCK_lock
Definition: mysys_priv.h:49
PSI_memory_key key_memory_lf_slist
Definition: my_static.cc:58
PSI_memory_key key_memory_IO_CACHE
Definition: my_static.cc:60
PSI_memory_key key_memory_defaults
Definition: my_default.cc:132
PSI_stage_info stage_waiting_for_table_level_lock
Definition: my_init.cc:451
PSI_memory_key key_memory_LIST
Definition: my_static.cc:59
PSI_memory_key key_memory_TREE
Definition: my_static.cc:71
PSI_memory_key key_memory_KEY_CACHE
Definition: my_static.cc:61
PSI_mutex_key key_THR_LOCK_threads
Definition: mysys_priv.h:51
PSI_mutex_key key_TMPDIR_mutex
Definition: mysys_priv.h:51
PSI_mutex_key key_THR_LOCK_mutex
Definition: mysys_priv.h:49
mysql_mutex_t THR_LOCK_charset
Definition: my_thr_init.cc:79
PSI_memory_key key_memory_MY_TMPDIR_full_list
Definition: my_static.cc:69
PSI_mutex_key key_IO_CACHE_append_buffer_lock
Definition: my_init.cc:457
PSI_cond_key key_THR_COND_threads
Definition: mysys_priv.h:56
PSI_file_key key_file_proc_meminfo
Definition: my_init.cc:512
PSI_memory_key key_memory_DYNAMIC_STRING
Definition: my_static.cc:70
PSI_mutex_key key_THR_LOCK_open
Definition: mysys_priv.h:50
PSI_mutex_key key_THR_LOCK_heap
Definition: mysys_priv.h:48
PSI_memory_key key_memory_my_file_info
Definition: my_static.cc:66
mysql_mutex_t THR_LOCK_open
Definition: mysys_priv.h:60
void MyFileInit()
Constructs static objects.
Definition: my_file.cc:277
PSI_memory_key key_memory_charset_loader
Definition: my_static.cc:55
PSI_thread_key key_thread_timer_notifier
Definition: my_static.cc:73
PSI_mutex_key key_THR_LOCK_charset
Definition: mysys_priv.h:48
PSI_mutex_key key_THR_LOCK_myisam
Definition: mysys_priv.h:50
PSI_memory_key key_memory_charset_file
Definition: my_static.cc:54
PSI_memory_key key_memory_my_compress_alloc
Definition: my_static.cc:64
PSI_memory_key key_memory_lf_dynarray
Definition: my_static.cc:57
PSI_cond_key key_IO_CACHE_SHARE_cond_writer
Definition: mysys_priv.h:55
PSI_mutex_key key_KEY_CACHE_cache_lock
Definition: mysys_priv.h:48
PSI_memory_key key_memory_MY_BITMAP_bitmap
Definition: my_static.cc:63
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:86
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:910
Definition: mysys_priv.h:107
RET RetryOnEintr(SYSC &&sysc, RET err)
Definition: mysys_priv.h:109
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
mode
Definition: file_handle.h:60
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:152
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50