/src/mysql-server/mysys/errors.cc
Line | Count | Source |
1 | | /* Copyright (c) 2000, 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 | | Without limiting anything contained in the foregoing, this file, |
16 | | which is part of C Driver for MySQL (Connector/C), is also subject to the |
17 | | Universal FOSS Exception, version 1.0, a copy of which can be found at |
18 | | http://oss.oracle.com/licenses/universal-foss-exception. |
19 | | |
20 | | This program is distributed in the hope that it will be useful, |
21 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | | GNU General Public License, version 2.0, for more details. |
24 | | |
25 | | You should have received a copy of the GNU General Public License |
26 | | along with this program; if not, write to the Free Software |
27 | | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
28 | | |
29 | | /** |
30 | | @file mysys/errors.cc |
31 | | */ |
32 | | |
33 | | #include "my_config.h" |
34 | | #include "mysql/my_loglevel.h" |
35 | | |
36 | | #ifdef HAVE_UNISTD_H |
37 | | #include <unistd.h> |
38 | | #endif |
39 | | |
40 | | #include "my_dbug.h" |
41 | | #include "my_sys.h" |
42 | | #include "my_thread_local.h" |
43 | | #include "mysys_err.h" |
44 | | |
45 | | const char *globerrs[GLOBERRS] = { |
46 | | "Can't create/write to file '%s' (OS errno %d - %s)", |
47 | | "Error reading file '%s' (OS errno %d - %s)", |
48 | | "Error writing file '%s' (OS errno %d - %s)", |
49 | | "Error on close of '%s' (OS errno %d - %s)", |
50 | | "Out of memory (Needed %u bytes)", |
51 | | "Error on delete of '%s' (OS errno %d - %s)", |
52 | | "Error on rename of '%s' to '%s' (OS errno %d - %s)", |
53 | | "", |
54 | | "Unexpected EOF found when reading file '%s' (OS errno %d - %s)", |
55 | | "Can't lock file (OS errno %d - %s)", |
56 | | "Can't unlock file (OS errno %d - %s)", |
57 | | "Can't read dir of '%s' (OS errno %d - %s)", |
58 | | "Can't get stat of '%s' (OS errno %d - %s)", |
59 | | "Can't change size of file (OS errno %d - %s)", |
60 | | "Can't open stream from handle (OS errno %d - %s)", |
61 | | "Can't get working directory (OS errno %d - %s)", |
62 | | "Can't change dir to '%s' (OS errno %d - %s)", |
63 | | "Warning: '%s' had %d links", |
64 | | "Warning: %d files and %d streams are left open", |
65 | | "Disk is full writing '%s' (OS errno %d - %s). Waiting for someone to free " |
66 | | "space...", |
67 | | "Can't create directory '%s' (OS errno %d - %s)", |
68 | | "Character set '%s' is not a compiled character set and is not specified " |
69 | | "in the '%s' file", |
70 | | "Out of resources when opening file '%s' (OS errno %d - %s)", |
71 | | "Can't read value for symlink '%s' (Error %d - %s)", |
72 | | "Can't create symlink '%s' pointing at '%s' (Error %d - %s)", |
73 | | "Error on realpath() on '%s' (Error %d - %s)", |
74 | | "Can't sync file '%s' to disk (OS errno %d - %s)", |
75 | | "Collation '%s' is not a compiled collation and is not specified in the " |
76 | | "'%s' file", |
77 | | "File '%s' not found (OS errno %d - %s)", |
78 | | "File '%s' (fileno: %d) was not closed", |
79 | | "Cannot change ownership of the file '%s' (OS errno %d - %s)", |
80 | | "Cannot change permissions of the file '%s' (OS errno %d - %s)", |
81 | | "Cannot seek in file '%s' (OS errno %d - %s)", |
82 | | "Memory capacity exceeded (capacity %llu bytes)", |
83 | | "Disk is full writing '%s' (OS errno %d - %s). Waiting for someone to free " |
84 | | "space... Retry in %d secs. Message reprinted in %d secs.", |
85 | | "Failed to create timer (OS errno %d).", |
86 | | "Failed to delete timer (OS errno %d).", |
87 | | "Failed to create timer queue (OS errno %d).", |
88 | | "Failed to start timer notify thread.", |
89 | | "Failed to create event to interrupt timer notifier thread (OS errno %d).", |
90 | | "Failed to register timer event with queue (OS errno %d), exiting timer " |
91 | | "notifier thread.", |
92 | | "LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu.", |
93 | | "%s.", |
94 | | "Failed to determine large page size.", |
95 | | "Error in my_thread_global_end(): %d thread(s) did not exit.", |
96 | | "Failed to create IO completion port (OS errno %d).", |
97 | | "Failed to open required defaults file: %s", |
98 | | "Fatal error in defaults handling. Program aborted!", |
99 | | "Wrong '!%s' directive in config file %s at line %d.", |
100 | | "Skipping '%s' directive as maximum include recursion level was" |
101 | | " reached in file %s at line %d.", |
102 | | "Wrong group definition in config file %s at line %d.", |
103 | | "Found option without preceding group in config file %s at line %d.", |
104 | | "%s should be readable/writable only by current user.", |
105 | | "World-writable config file '%s' is ignored.", |
106 | | "%s: Option '%s' was used, but is disabled.", |
107 | | "%s: Option '-%c' was used, but is disabled.", |
108 | | "Using a password on the command line interface can be insecure.", |
109 | | "Unknown suffix '%c' used for variable '%s' (value '%s').", |
110 | | "SSL error: %s from '%s'.", |
111 | | "SSL error: %s.", |
112 | | "%d %s.", |
113 | | "Packets out of order (found %u, expected %u).", |
114 | | "Unknown option to protocol: %s.", |
115 | | "Failed to locate server public key '%s'.", |
116 | | "Public key is not in Privacy Enhanced Mail format: '%s'.", |
117 | | "%s.", |
118 | | "unknown variable '%s'.", |
119 | | "unknown option '--%s'.", |
120 | | "%s: unknown option '-%c'.", |
121 | | "%s: option '--%s' cannot take an argument.", |
122 | | "%s: option '--%s' requires an argument.", |
123 | | "%s: option '-%c' requires an argument.", |
124 | | "%s: ignoring option '--%s' due to invalid value '%s'.", |
125 | | "%s: Empty value for '%s' specified.", |
126 | | "%s: Maximum value of '%s' cannot be set.", |
127 | | "option '%s': boolean value '%s' was not recognized. Set to OFF.", |
128 | | "%s: Error while setting value '%s' to '%s'.", |
129 | | "Incorrect integer value: '%s'.", |
130 | | "Incorrect unsigned integer value: '%s'.", |
131 | | "option '%s': signed value %s adjusted to %s.", |
132 | | "option '%s': unsigned value %s adjusted to %s.", |
133 | | "option '%s': value %s adjusted to %s.", |
134 | | "option '%s': value %g adjusted to %g.", |
135 | | "Invalid decimal value for option '%s'.", |
136 | | "%s.", |
137 | | "Failed to reset before a primary ignorable character %s.", |
138 | | "Failed to reset before a tertiary ignorable character %s.", |
139 | | "Shift character out of range: %s.", |
140 | | "Reset character out of range: %s.", |
141 | | "Unknown LDML tag: '%.*s'.", |
142 | | "Failed to reset before a secondary ignorable character %s.", |
143 | | "Stopped processing the '%s' directive in file %s at line %d.", |
144 | | "pthread_kill(thread_id:%lu, signal:%s) returned '%s'."}; |
145 | | |
146 | | /* |
147 | | We cannot call my_error/my_printf_error here in this function. |
148 | | Those functions will set status variable in diagnostic area |
149 | | and there is no provision to reset them back. |
150 | | Here we are waiting for free space and will wait forever till |
151 | | space is created. So just giving warning in the error file |
152 | | should be enough. |
153 | | */ |
154 | 0 | void wait_for_free_space(const char *filename, int errors) { |
155 | 0 | size_t time_to_sleep = MY_WAIT_FOR_USER_TO_FIX_PANIC; |
156 | |
|
157 | 0 | if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE)) { |
158 | 0 | char errbuf[MYSYS_STRERROR_SIZE]; |
159 | 0 | my_message_local( |
160 | 0 | ERROR_LEVEL, EE_DISK_FULL_WITH_RETRY_MSG, filename, my_errno(), |
161 | 0 | my_strerror(errbuf, sizeof(errbuf), my_errno()), |
162 | 0 | MY_WAIT_FOR_USER_TO_FIX_PANIC, |
163 | 0 | MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC); |
164 | 0 | } |
165 | 0 | DBUG_EXECUTE_IF("simulate_no_free_space_error", { time_to_sleep = 1; }); |
166 | 0 | DBUG_EXECUTE_IF("force_wait_for_disk_space", { time_to_sleep = 1; }); |
167 | 0 | DBUG_EXECUTE_IF("simulate_io_thd_wait_for_disk_space", |
168 | 0 | { time_to_sleep = 1; }); |
169 | 0 | DBUG_EXECUTE_IF("simulate_random_io_thd_wait_for_disk_space", |
170 | 0 | { time_to_sleep = 1; }); |
171 | | // Answer more promptly to a KILL signal |
172 | 0 | do { |
173 | 0 | (void)sleep(1); |
174 | 0 | } while (--time_to_sleep > 0 && !is_killed_hook(nullptr)); |
175 | 0 | } |
176 | | |
177 | 0 | const char *get_global_errmsg(int nr) { return globerrs[nr - EE_ERROR_FIRST]; } |