1 | /* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
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 as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software |
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
15 | |
16 | /** |
17 | @file |
18 | File containing constants that can be used throughout the server. |
19 | |
20 | @note This file shall not contain or include any declarations of any kinds. |
21 | */ |
22 | |
23 | #ifndef SQL_CONST_INCLUDED |
24 | #define SQL_CONST_INCLUDED |
25 | |
26 | #include <mysql_version.h> |
27 | |
28 | #define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */ |
29 | /* extra 4+4 bytes for slave tmp tables */ |
30 | #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) |
31 | #define MAX_ALIAS_NAME 256 |
32 | #define MAX_FIELD_NAME 34 /* Max colum name length +2 */ |
33 | #define MAX_SYS_VAR_LENGTH 32 |
34 | #define MAX_KEY MAX_INDEXES /* Max used keys */ |
35 | #define MAX_REF_PARTS 32 /* Max parts used as ref */ |
36 | #define MAX_KEY_LENGTH 3072 /* max possible key */ |
37 | #if SIZEOF_OFF_T > 4 |
38 | #define MAX_REFLENGTH 8 /* Max length for record ref */ |
39 | #else |
40 | #define MAX_REFLENGTH 4 /* Max length for record ref */ |
41 | #endif |
42 | #define MAX_HOSTNAME 61 /* len+1 in mysql.user */ |
43 | #define MAX_CONNECTION_NAME NAME_LEN |
44 | |
45 | #define MAX_MBWIDTH 3 /* Max multibyte sequence */ |
46 | #define MAX_FILENAME_MBWIDTH 5 |
47 | #define MAX_FIELD_CHARLENGTH 255 |
48 | /* |
49 | In MAX_FIELD_VARCHARLENGTH we reserve extra bytes for the overhead: |
50 | - 2 bytes for the length |
51 | - 1 byte for NULL bits |
52 | to avoid the "Row size too large" error for these three corner definitions: |
53 | CREATE TABLE t1 (c VARBINARY(65533)); |
54 | CREATE TABLE t1 (c VARBINARY(65534)); |
55 | CREATE TABLE t1 (c VARBINARY(65535)); |
56 | Like VARCHAR(65536), they will be converted to BLOB automatically |
57 | in non-sctict mode. |
58 | */ |
59 | #define MAX_FIELD_VARCHARLENGTH (65535-2-1) |
60 | #define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */ |
61 | #define CONVERT_IF_BIGGER_TO_BLOB 512 /* Threshold *in characters* */ |
62 | |
63 | /* Max column width +1 */ |
64 | #define MAX_FIELD_WIDTH (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1) |
65 | |
66 | #define MAX_BIT_FIELD_LENGTH 64 /* Max length in bits for bit fields */ |
67 | |
68 | #define MAX_DATE_WIDTH 10 /* YYYY-MM-DD */ |
69 | #define MIN_TIME_WIDTH 10 /* -HHH:MM:SS */ |
70 | #define MAX_TIME_WIDTH 16 /* -DDDDDD HH:MM:SS */ |
71 | #define MAX_TIME_FULL_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */ |
72 | #define MAX_DATETIME_FULL_WIDTH 26 /* YYYY-MM-DD HH:MM:SS.###### */ |
73 | #define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */ |
74 | #define MAX_DATETIME_COMPRESSED_WIDTH 14 /* YYYYMMDDHHMMSS */ |
75 | #define MAX_DATETIME_PRECISION 6 |
76 | |
77 | #define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */ |
78 | #define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3)) |
79 | #define OUTER_REF_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-2)) |
80 | #define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1)) |
81 | #define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \ |
82 | RAND_TABLE_BIT) |
83 | #define CONNECT_STRING_MAXLEN 65535 /* stored in 2 bytes in .frm */ |
84 | #define MAX_FIELDS 4096 /* Limit in the .frm file */ |
85 | #define MAX_PARTITIONS 8192 |
86 | |
87 | #define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1) |
88 | |
89 | #define MAX_SORT_MEMORY 2048*1024 |
90 | #define MIN_SORT_MEMORY 1024 |
91 | |
92 | /* Some portable defines */ |
93 | |
94 | #define STRING_BUFFER_USUAL_SIZE 80 |
95 | |
96 | /* Memory allocated when parsing a statement / saving a statement */ |
97 | #define MEM_ROOT_BLOCK_SIZE 8192 |
98 | #define MEM_ROOT_PREALLOC 8192 |
99 | #define TRANS_MEM_ROOT_BLOCK_SIZE 4096 |
100 | #define TRANS_MEM_ROOT_PREALLOC 4096 |
101 | |
102 | #define DEFAULT_ERROR_COUNT 64 |
103 | #define 10 /* Extra records in sort */ |
104 | #define 5 /* Extra scroll-rows. */ |
105 | #define FIELD_NAME_USED ((uint) 32768) /* Bit set if fieldname used */ |
106 | #define FORM_NAME_USED ((uint) 16384) /* Bit set if formname used */ |
107 | #define FIELD_NR_MASK 16383 /* To get fieldnumber */ |
108 | #define FERR -1 /* Error from my_functions */ |
109 | #define CREATE_MODE 0 /* Default mode on new files */ |
110 | #define NAMES_SEP_CHAR 255 /* Char to sep. names */ |
111 | |
112 | #define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */ |
113 | #define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */ |
114 | |
115 | #define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */ |
116 | #define FRM_VER_EXPRESSSIONS (FRM_VER+5) /* 11 */ |
117 | #define FRM_VER_CURRENT FRM_VER_EXPRESSSIONS |
118 | |
119 | /*************************************************************************** |
120 | Configuration parameters |
121 | ****************************************************************************/ |
122 | |
123 | #define ACL_CACHE_SIZE 256 |
124 | #define MAX_PASSWORD_LENGTH 32 |
125 | #define HOST_CACHE_SIZE 128 |
126 | #define MAX_ACCEPT_RETRY 10 // Test accept this many times |
127 | #define MAX_FIELDS_BEFORE_HASH 32 |
128 | #define USER_VARS_HASH_SIZE 16 |
129 | #define SEQUENCES_HASH_SIZE 16 |
130 | #define TABLE_OPEN_CACHE_MIN 200 |
131 | #define TABLE_OPEN_CACHE_DEFAULT 2000 |
132 | #define TABLE_DEF_CACHE_DEFAULT 400 |
133 | /** |
134 | We must have room for at least 400 table definitions in the table |
135 | cache, since otherwise there is no chance prepared |
136 | statements that use these many tables can work. |
137 | Prepared statements use table definition cache ids (table_map_id) |
138 | as table version identifiers. If the table definition |
139 | cache size is less than the number of tables used in a statement, |
140 | the contents of the table definition cache is guaranteed to rotate |
141 | between a prepare and execute. This leads to stable validation |
142 | errors. In future we shall use more stable version identifiers, |
143 | for now the only solution is to ensure that the table definition |
144 | cache can contain at least all tables of a given statement. |
145 | */ |
146 | #define TABLE_DEF_CACHE_MIN 400 |
147 | |
148 | /** |
149 | Maximum number of connections default value. |
150 | 151 is larger than Apache's default max children, |
151 | to avoid "too many connections" error in a common setup. |
152 | */ |
153 | #define MAX_CONNECTIONS_DEFAULT 151 |
154 | |
155 | /* |
156 | Stack reservation. |
157 | Feel free to raise this by the smallest amount you can to get the |
158 | "execution_constants" test to pass. |
159 | */ |
160 | #define STACK_MIN_SIZE 16000 // Abort if less stack during eval. |
161 | |
162 | #define STACK_MIN_SIZE_FOR_OPEN (1024*80) |
163 | #define STACK_BUFF_ALLOC 352 ///< For stack overrun checks |
164 | #ifndef MYSQLD_NET_RETRY_COUNT |
165 | #define MYSQLD_NET_RETRY_COUNT 10 ///< Abort read after this many int. |
166 | #endif |
167 | |
168 | #define QUERY_ALLOC_BLOCK_SIZE 16384 |
169 | #define QUERY_ALLOC_PREALLOC_SIZE 24576 |
170 | #define TRANS_ALLOC_BLOCK_SIZE 8192 |
171 | #define TRANS_ALLOC_PREALLOC_SIZE 4096 |
172 | #define RANGE_ALLOC_BLOCK_SIZE 4096 |
173 | #define ACL_ALLOC_BLOCK_SIZE 1024 |
174 | #define UDF_ALLOC_BLOCK_SIZE 1024 |
175 | #define TABLE_ALLOC_BLOCK_SIZE 1024 |
176 | #define WARN_ALLOC_BLOCK_SIZE 2048 |
177 | #define WARN_ALLOC_PREALLOC_SIZE 1024 |
178 | /* |
179 | Note that if we are using 32K or less, then TCmalloc will use a local |
180 | heap without locks! |
181 | */ |
182 | #define SHOW_ALLOC_BLOCK_SIZE (32768-MALLOC_OVERHEAD) |
183 | |
184 | /* |
185 | The following parameters is to decide when to use an extra cache to |
186 | optimise seeks when reading a big table in sorted order |
187 | */ |
188 | #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024) |
189 | #define MIN_ROWS_TO_USE_TABLE_CACHE 100 |
190 | #define MIN_ROWS_TO_USE_BULK_INSERT 100 |
191 | |
192 | /** |
193 | The following is used to decide if MySQL should use table scanning |
194 | instead of reading with keys. The number says how many evaluation of the |
195 | WHERE clause is comparable to reading one extra row from a table. |
196 | */ |
197 | #define TIME_FOR_COMPARE 5 // 5 compares == one read |
198 | |
199 | /** |
200 | Number of comparisons of table rowids equivalent to reading one row from a |
201 | table. |
202 | */ |
203 | #define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*100) |
204 | |
205 | /* cost1 is better that cost2 only if cost1 + COST_EPS < cost2 */ |
206 | #define COST_EPS 0.001 |
207 | |
208 | /* |
209 | For sequential disk seeks the cost formula is: |
210 | DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip |
211 | |
212 | The cost of average seek |
213 | DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0. |
214 | */ |
215 | #define DISK_SEEK_BASE_COST ((double)0.9) |
216 | |
217 | #define BLOCKS_IN_AVG_SEEK 128 |
218 | |
219 | #define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK) |
220 | |
221 | |
222 | /** |
223 | Number of rows in a reference table when refereed through a not unique key. |
224 | This value is only used when we don't know anything about the key |
225 | distribution. |
226 | */ |
227 | #define MATCHING_ROWS_IN_OTHER_TABLE 10 |
228 | |
229 | /* |
230 | Subquery materialization-related constants |
231 | */ |
232 | #define HEAP_TEMPTABLE_LOOKUP_COST 0.05 |
233 | #define DISK_TEMPTABLE_LOOKUP_COST 1.0 |
234 | #define SORT_INDEX_CMP_COST 0.02 |
235 | |
236 | #define MY_CHARSET_BIN_MB_MAXLEN 1 |
237 | |
238 | /** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */ |
239 | #define KEY_DEFAULT_PACK_LENGTH 8 |
240 | |
241 | /** Characters shown for the command in 'show processlist'. */ |
242 | #define PROCESS_LIST_WIDTH 100 |
243 | /* Characters shown for the command in 'information_schema.processlist' */ |
244 | #define PROCESS_LIST_INFO_WIDTH 65535 |
245 | |
246 | #define PRECISION_FOR_DOUBLE 53 |
247 | #define PRECISION_FOR_FLOAT 24 |
248 | |
249 | /* -[digits].E+## */ |
250 | #define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6) |
251 | /* -[digits].E+### */ |
252 | #define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7) |
253 | |
254 | /* |
255 | Default time to wait before aborting a new client connection |
256 | that does not respond to "initial server greeting" timely |
257 | */ |
258 | #define CONNECT_TIMEOUT 10 |
259 | /* Wait 5 minutes before removing thread from thread cache */ |
260 | #define THREAD_CACHE_TIMEOUT 5*60 |
261 | |
262 | /* The following can also be changed from the command line */ |
263 | #define DEFAULT_CONCURRENCY 10 |
264 | #define DELAYED_LIMIT 100 /**< pause after xxx inserts */ |
265 | #define DELAYED_QUEUE_SIZE 1000 |
266 | #define DELAYED_WAIT_TIMEOUT (5*60) /**< Wait for delayed insert */ |
267 | #define MAX_CONNECT_ERRORS 100 ///< errors before disabling host |
268 | |
269 | #define LONG_TIMEOUT ((ulong) 3600L*24L*365L) |
270 | |
271 | /** |
272 | Maximum length of time zone name that we support (Time zone name is |
273 | char(64) in db). mysqlbinlog needs it. |
274 | */ |
275 | #define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1) |
276 | |
277 | #if defined(__WIN__) |
278 | |
279 | #define INTERRUPT_PRIOR -2 |
280 | #define CONNECT_PRIOR -1 |
281 | #define WAIT_PRIOR 0 |
282 | #define QUERY_PRIOR 2 |
283 | #else |
284 | #define INTERRUPT_PRIOR 10 |
285 | #define CONNECT_PRIOR 9 |
286 | #define WAIT_PRIOR 8 |
287 | #define QUERY_PRIOR 6 |
288 | #endif /* __WIN92__ */ |
289 | |
290 | #endif /* SQL_CONST_INCLUDED */ |
291 | |