MySQL 8.2.0
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_macros.h"
33
34#include "my_psi_config.h"
35#include "mysql/components/services/bits/mysql_mutex_bits.h" // for mysql_mutex_t
37#include "mysql/components/services/bits/psi_file_bits.h" // for PSI_file_key
38#include "mysql/components/services/bits/psi_memory_bits.h" // for PSI_memory_key
40#include "mysql/components/services/bits/psi_rwlock_bits.h" // for PSI_rwlock_key
41#include "mysql/components/services/bits/psi_stage_bits.h" // for PSI_stage_info
42#include "mysql/components/services/bits/psi_thread_bits.h" // for PSI_thread_key
43#include "mysql/psi/mysql_mutex.h" // for mysql_mutex_lock
44
50
52
55
57
60
61#ifdef HAVE_LINUX_LARGE_PAGES
63#endif /* HAVE_LINUX_LARGE_PAGES */
65
66/* These keys are always defined. */
67
85
86#ifdef _WIN32
87extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
88extern PSI_memory_key key_memory_win_PACL;
89extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
90extern PSI_memory_key key_memory_win_handle_info;
91#endif
92
94
95/*
96 EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
97 system, we set it to some value which can never happen.
98*/
99#ifndef EDQUOT
100#define EDQUOT (-1)
101#endif
102
103namespace mysys_priv {
104template <class SYSC, class RET>
105inline RET RetryOnEintr(SYSC &&sysc, RET err) {
106 RET r;
107 do {
108 r = sysc();
109 } while (r == err && errno == EINTR);
110 return r;
111}
112} // namespace mysys_priv
113
115
116#ifdef _WIN32
117#include <stdint.h> // int64_t
118#include <sys/stat.h>
119// my_winfile.cc exports, should not be used outside mysys
120File my_win_open(const char *path, int oflag);
121int my_win_close(File fd);
122int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset);
123int64_t my_win_pwrite(File fd, const uchar *buffer, size_t count,
124 int64_t offset);
125int64_t my_win_lseek(File fd, int64_t pos, int whence);
126int64_t my_win_write(File fd, const uchar *buffer, size_t count);
127int my_win_chsize(File fd, int64_t newlength);
129FILE *my_win_fopen(const char *filename, const char *mode);
130FILE *my_win_fdopen(File Filedes, const char *mode);
131File my_win_fclose(FILE *stream);
132FILE *my_win_freopen(const char *path, const char *mode, FILE *stream);
133int my_win_fstat(File fd, struct _stati64 *buf);
134int my_win_stat(const char *path, struct _stati64 *buf);
135int my_win_fsync(File fd);
136
137void MyWinfileInit();
138void MyWinfileEnd();
139
140#endif /* _WIN32 */
141
142namespace file_info {
143
144/**
145 How was this file opened (for debugging purposes).
146 The important part is whether it is UNOPEN or not.
147*/
148enum class OpenType : char {
149 UNOPEN = 0,
150 FILE_BY_OPEN,
151 FILE_BY_CREATE,
152 STREAM_BY_FOPEN,
153 STREAM_BY_FDOPEN,
154 FILE_BY_MKSTEMP,
155 FILE_BY_O_TMPFILE
156};
157
160
161void RegisterFilename(File fd, const char *FileName, OpenType type_of_file);
163} // namespace file_info
164
165void MyFileInit();
166void MyFileEnd();
167
168#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:10044
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:847
FILE * my_win_freopen(const char *path, const char *mode, FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:759
void MyWinfileEnd()
Destroys static objects.
Definition: my_winfile.cc:895
int my_win_fstat(File fd, struct _stati64 *buf)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:809
int my_win_close(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:441
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:510
int my_win_fsync(File fd)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:874
int64_t my_win_pread(File fd, uchar *buffer, size_t count, int64_t offset)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:471
File my_win_open(const char *path, int mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:427
int my_win_fclose(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:734
void MyWinfileInit()
Constructs static objects.
Definition: my_winfile.cc:888
File my_win_fileno(FILE *stream)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:634
FILE * my_win_fdopen(File fd, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:706
int my_win_chsize(File fd, int64_t newlength)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:603
int64_t my_win_lseek(File fd, int64_t pos, int whence)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:540
FILE * my_win_fopen(const char *filename, const char *mode)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:661
int64_t my_win_write(File fd, const uchar *Buffer, size_t Count)
Homegrown posix emulation for Windows.
Definition: my_winfile.cc:569
static int count
Definition: myisam_ftdump.cc:44
ABI for instrumented mutexes.
static char * path
Definition: mysqldump.cc:148
PSI_memory_key key_memory_my_err_head
Definition: my_static.cc:63
PSI_mutex_key key_IO_CACHE_SHARE_mutex
Definition: mysys_priv.h:45
PSI_mutex_key key_THR_LOCK_malloc
Definition: mysys_priv.h:47
PSI_memory_key key_memory_SAFE_HASH_ENTRY
Definition: my_static.cc:60
PSI_memory_key key_memory_lf_node
Definition: my_static.cc:54
void MyFileEnd()
Destroys static objects.
Definition: my_file.cc:284
PSI_memory_key key_memory_MY_DIR
Definition: my_static.cc:66
PSI_mutex_key key_THR_LOCK_myisam_mmap
Definition: mysys_priv.h:49
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: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:410
PSI_rwlock_key key_SAFE_HASH_lock
Definition: my_init.cc:491
PSI_mutex_key key_THR_LOCK_net
Definition: mysys_priv.h:48
PSI_mutex_key key_THR_LOCK_lock
Definition: mysys_priv.h:46
PSI_memory_key key_memory_lf_slist
Definition: my_static.cc:56
PSI_memory_key key_memory_IO_CACHE
Definition: my_static.cc:58
PSI_memory_key key_memory_defaults
Definition: my_default.cc:135
PSI_stage_info stage_waiting_for_table_level_lock
Definition: my_init.cc:453
PSI_memory_key key_memory_LIST
Definition: my_static.cc:57
PSI_memory_key key_memory_TREE
Definition: my_static.cc:69
PSI_memory_key key_memory_KEY_CACHE
Definition: my_static.cc:59
PSI_mutex_key key_THR_LOCK_threads
Definition: mysys_priv.h:48
PSI_mutex_key key_TMPDIR_mutex
Definition: mysys_priv.h:48
PSI_mutex_key key_THR_LOCK_mutex
Definition: mysys_priv.h:47
PSI_memory_key key_memory_MY_TMPDIR_full_list
Definition: my_static.cc:67
PSI_mutex_key key_IO_CACHE_append_buffer_lock
Definition: my_init.cc:459
PSI_cond_key key_THR_COND_threads
Definition: mysys_priv.h:54
PSI_file_key key_file_proc_meminfo
Definition: my_init.cc:512
PSI_memory_key key_memory_DYNAMIC_STRING
Definition: my_static.cc:68
PSI_mutex_key key_THR_LOCK_open
Definition: mysys_priv.h:48
PSI_mutex_key key_THR_LOCK_heap
Definition: mysys_priv.h:46
PSI_memory_key key_memory_my_file_info
Definition: my_static.cc:64
mysql_mutex_t THR_LOCK_open
Definition: mysys_priv.h:58
void MyFileInit()
Constructs static objects.
Definition: my_file.cc:276
PSI_memory_key key_memory_charset_loader
Definition: my_static.cc:53
PSI_thread_key key_thread_timer_notifier
Definition: my_static.cc:71
PSI_mutex_key key_THR_LOCK_myisam
Definition: mysys_priv.h:47
PSI_memory_key key_memory_my_compress_alloc
Definition: my_static.cc:62
PSI_memory_key key_memory_lf_dynarray
Definition: my_static.cc:55
PSI_cond_key key_IO_CACHE_SHARE_cond_writer
Definition: mysys_priv.h:53
PSI_mutex_key key_KEY_CACHE_cache_lock
Definition: mysys_priv.h:46
PSI_memory_key key_memory_MY_BITMAP_bitmap
Definition: my_static.cc:61
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:88
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:921
Definition: mysys_priv.h:103
RET RetryOnEintr(SYSC &&sysc, RET err)
Definition: mysys_priv.h:105
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
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:148
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49