MySQL 8.0.33
Source Code Documentation
mysys_priv.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 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 mysys/mysys_priv.h
25*/
26
27#ifndef MYSYS_PRIV_INCLUDED
28#define MYSYS_PRIV_INCLUDED
29
30#include <memory> // std::unique_ptr
31
32#include "my_inttypes.h" // myf
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
62
63#ifdef HAVE_LINUX_LARGE_PAGES
65#endif /* HAVE_LINUX_LARGE_PAGES */
67
68/* These keys are always defined. */
69
88
89#ifdef _WIN32
90extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
91extern PSI_memory_key key_memory_win_PACL;
92extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
93extern PSI_memory_key key_memory_win_handle_info;
94#endif
95
97
98/*
99 EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
100 system, we set it to some value which can never happen.
101*/
102#ifndef EDQUOT
103#define EDQUOT (-1)
104#endif
105
106namespace mysys_priv {
107template <class SYSC, class RET>
108inline RET RetryOnEintr(SYSC &&sysc, RET err) {
109 RET r;
110 do {
111 r = sysc();
112 } while (r == err && errno == EINTR);
113 return r;
114}
115} // namespace mysys_priv
116
118
119#ifdef _WIN32
120#include <stdint.h> // int64_t
121#include <sys/stat.h>
122// my_winfile.cc exports, should not be used outside mysys
123File my_win_open(const char *path, int oflag);
124int my_win_close(File fd);
125int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset);
126int64_t my_win_pwrite(File fd, const uchar *buffer, size_t count,
127 int64_t offset);
128int64_t my_win_lseek(File fd, int64_t pos, int whence);
129int64_t my_win_write(File fd, const uchar *buffer, size_t count);
130int my_win_chsize(File fd, int64_t newlength);
132FILE *my_win_fopen(const char *filename, const char *mode);
133FILE *my_win_fdopen(File Filedes, const char *mode);
134File my_win_fclose(FILE *stream);
135FILE *my_win_freopen(const char *path, const char *mode, FILE *stream);
136int my_win_fstat(File fd, struct _stati64 *buf);
137int my_win_stat(const char *path, struct _stati64 *buf);
138int my_win_fsync(File fd);
139
140void MyWinfileInit();
141void MyWinfileEnd();
142
143#endif /* _WIN32 */
144
145namespace file_info {
146
147/**
148 How was this file opened (for debugging purposes).
149 The important part is whether it is UNOPEN or not.
150*/
151enum class OpenType : char {
152 UNOPEN = 0,
153 FILE_BY_OPEN,
154 FILE_BY_CREATE,
155 STREAM_BY_FOPEN,
156 STREAM_BY_FDOPEN,
157 FILE_BY_MKSTEMP,
158 FILE_BY_O_TMPFILE
159};
160
163
164void RegisterFilename(File fd, const char *FileName, OpenType type_of_file);
166} // namespace file_info
167
168void MyFileInit();
169void MyFileEnd();
170
171#endif /* MYSYS_PRIV_INCLUDED */
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:43
unsigned int PSI_file_key
Instrumented file key.
Definition: psi_file_bits.h:47
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:51
unsigned int PSI_rwlock_key
Instrumented rwlock key.
Definition: psi_rwlock_bits.h:43
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:49
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
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
int File
Definition: my_io_bits.h:50
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:844
FILE * my_win_freopen(const char *path, const char *mode, FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:756
void MyWinfileEnd()
Destroys static objects.
Definition: my_winfile.cc:892
int my_win_fstat(File fd, struct _stati64 *buf)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:806
int my_win_close(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:438
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:507
int my_win_fsync(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:871
int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:468
File my_win_open(const char *path, int mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:424
int my_win_fclose(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:731
void MyWinfileInit()
Constructs static objects.
Definition: my_winfile.cc:885
File my_win_fileno(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:631
FILE * my_win_fdopen(File fd, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:703
int my_win_chsize(File fd, int64_t newlength)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:600
int64_t my_win_lseek(File fd, int64_t pos, int whence)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:537
FILE * my_win_fopen(const char *filename, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:658
int64_t my_win_write(File fd, const uchar *Buffer, size_t Count)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:566
static int count
Definition: myisam_ftdump.cc:42
ABI for instrumented mutexes.
static char * path
Definition: mysqldump.cc:133
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:284
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:77
mysql_mutex_t THR_LOCK_malloc
Definition: my_thr_init.cc:74
PSI_file_key key_file_charset
Definition: my_init.cc:513
PSI_cond_key key_IO_CACHE_SHARE_cond
Definition: my_init.cc:497
void my_error_unregister_all()
Unregister all formerly registered error messages.
Definition: my_error.cc:410
PSI_rwlock_key key_SAFE_HASH_lock
Definition: my_init.cc:490
PSI_mutex_key key_THR_LOCK_net
Definition: mysys_priv.h:49
PSI_mutex_key key_THR_LOCK_lock
Definition: mysys_priv.h:48
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:131
PSI_stage_info stage_waiting_for_table_level_lock
Definition: my_init.cc:450
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:50
PSI_mutex_key key_TMPDIR_mutex
Definition: mysys_priv.h:50
PSI_mutex_key key_THR_LOCK_mutex
Definition: mysys_priv.h:48
mysql_mutex_t THR_LOCK_charset
Definition: my_thr_init.cc:78
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:456
PSI_cond_key key_THR_COND_threads
Definition: mysys_priv.h:55
PSI_file_key key_file_proc_meminfo
Definition: my_init.cc:511
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:276
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_charset
Definition: mysys_priv.h:47
PSI_mutex_key key_THR_LOCK_myisam
Definition: mysys_priv.h:49
PSI_memory_key key_memory_charset_file
Definition: my_static.cc:53
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:29
const std::string FILE("FILE")
Definition: my_file.cc:180
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:85
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:909
Definition: mysys_priv.h:106
RET RetryOnEintr(SYSC &&sysc, RET err)
Definition: mysys_priv.h:108
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419
mode
Definition: file_handle.h:59
const char * filename
Definition: pfs_example_component_population.cc:66
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
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:73
OpenType
How was this file opened (for debugging purposes).
Definition: mysys_priv.h:151
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49