MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_const.h
Go to the documentation of this file.
1 /* Copyright (c) 2006, 2011, 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 
23 #ifndef SQL_CONST_INCLUDED
24 #define SQL_CONST_INCLUDED
25 
26 #define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */
27 /* extra 4+4 bytes for slave tmp tables */
28 #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
29 #define MAX_ALIAS_NAME 256
30 #define MAX_FIELD_NAME 34 /* Max colum name length +2 */
31 #define MAX_SYS_VAR_LENGTH 32
32 #define MAX_KEY MAX_INDEXES /* Max used keys */
33 #define MAX_REF_PARTS 16U /* Max parts used as ref */
34 #define MAX_KEY_LENGTH 3072U /* max possible key */
35 #if SIZEOF_OFF_T > 4
36 #define MAX_REFLENGTH 8 /* Max length for record ref */
37 #else
38 #define MAX_REFLENGTH 4 /* Max length for record ref */
39 #endif
40 #define MAX_HOSTNAME 61 /* len+1 in mysql.user */
41 
42 #define MAX_MBWIDTH 3 /* Max multibyte sequence */
43 #define MAX_FIELD_CHARLENGTH 255
44 #define MAX_FIELD_VARCHARLENGTH 65535
45 #define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */
46 #define CONVERT_IF_BIGGER_TO_BLOB 512 /* Used for CREATE ... SELECT */
47 
48 /* Max column width +1 */
49 #define MAX_FIELD_WIDTH (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
50 
51 #define MAX_BIT_FIELD_LENGTH 64 /* Max length in bits for bit fields */
52 
53 #define MAX_DATE_WIDTH 10 /* YYYY-MM-DD */
54 #define MAX_TIME_WIDTH 10 /* -838:59:59 */
55 #define MAX_TIME_FULL_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */
56 #define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */
57 #define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */
58 #define MAX_DATETIME_COMPRESSED_WIDTH 14 /* YYYYMMDDHHMMSS */
59 
60 #define DATE_INT_DIGITS 8 /* YYYYMMDD */
61 #define TIME_INT_DIGITS 7 /* hhhmmss */
62 #define DATETIME_INT_DIGITS 14 /* YYYYMMDDhhmmss */
63 
64 #define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */
65 #define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
66 #define OUTER_REF_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-2))
67 #define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
68 #define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
69  RAND_TABLE_BIT)
70 #define MAX_FIELDS 4096 /* Limit in the .frm file */
71 #define MAX_PARTITIONS 8192
72 
73 #define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
74 
75 #define DEFAULT_SORT_MEMORY (256U* 1024U)
76 #define MIN_SORT_MEMORY (32U * 1024U)
77 
78 /* Some portable defines */
79 
80 #define STRING_BUFFER_USUAL_SIZE 80
81 
82 /* Memory allocated when parsing a statement / saving a statement */
83 #define MEM_ROOT_BLOCK_SIZE 8192
84 #define MEM_ROOT_PREALLOC 8192
85 #define TRANS_MEM_ROOT_BLOCK_SIZE 4096
86 #define TRANS_MEM_ROOT_PREALLOC 4096
87 
88 #define DEFAULT_ERROR_COUNT 64
89 #define EXTRA_RECORDS 10 /* Extra records in sort */
90 #define SCROLL_EXTRA 5 /* Extra scroll-rows. */
91 #define FIELD_NAME_USED ((uint) 32768) /* Bit set if fieldname used */
92 #define FORM_NAME_USED ((uint) 16384) /* Bit set if formname used */
93 #define FIELD_NR_MASK 16383 /* To get fieldnumber */
94 #define FERR -1 /* Error from my_functions */
95 #define CREATE_MODE 0 /* Default mode on new files */
96 #define NAMES_SEP_CHAR '\377' /* Char to sep. names */
97 
98 #define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */
99 #define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */
100 
101 #define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
102 
103 /***************************************************************************
104  Configuration parameters
105 ****************************************************************************/
106 
107 #define ACL_CACHE_SIZE 256
108 #define MAX_PASSWORD_LENGTH 32
109 #define HOST_CACHE_SIZE 128
110 #define MAX_ACCEPT_RETRY 10 // Test accept this many times
111 #define MAX_FIELDS_BEFORE_HASH 32
112 #define USER_VARS_HASH_SIZE 16
113 #define TABLE_OPEN_CACHE_MIN 400
114 #define TABLE_OPEN_CACHE_DEFAULT 2000
115 #define TABLE_DEF_CACHE_DEFAULT 400
116 
121 #define MAX_CONNECTIONS_DEFAULT 151
122 
135 #define TABLE_DEF_CACHE_MIN 400
136 
137 /*
138  Stack reservation.
139  Feel free to raise this by the smallest amount you can to get the
140  "execution_constants" test to pass.
141 */
142 #define STACK_MIN_SIZE 16000 // Abort if less stack during eval.
143 
144 #define STACK_MIN_SIZE_FOR_OPEN 1024*80
145 #define STACK_BUFF_ALLOC 352
146 #ifndef MYSQLD_NET_RETRY_COUNT
147 #define MYSQLD_NET_RETRY_COUNT 10
148 #endif
149 
150 #define QUERY_ALLOC_BLOCK_SIZE 8192
151 #define QUERY_ALLOC_PREALLOC_SIZE 8192
152 #define TRANS_ALLOC_BLOCK_SIZE 4096
153 #define TRANS_ALLOC_PREALLOC_SIZE 4096
154 #define RANGE_ALLOC_BLOCK_SIZE 4096
155 #define ACL_ALLOC_BLOCK_SIZE 1024
156 #define UDF_ALLOC_BLOCK_SIZE 1024
157 #define TABLE_ALLOC_BLOCK_SIZE 1024
158 #define WARN_ALLOC_BLOCK_SIZE 2048
159 #define WARN_ALLOC_PREALLOC_SIZE 1024
160 
161 /*
162  The following parameters is to decide when to use an extra cache to
163  optimise seeks when reading a big table in sorted order
164 */
165 #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
166 #define MIN_ROWS_TO_USE_TABLE_CACHE 100
167 #define MIN_ROWS_TO_USE_BULK_INSERT 100
168 
174 #define ROW_EVALUATE_COST 0.20
175 
179 #define ROWID_COMPARE_COST 0.10 // Half the cost of a general row comparison
180 
181 /*
182  For sequential disk seeks the cost formula is:
183  DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
184 
185  The cost of average seek
186  DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
187 */
188 #define DISK_SEEK_BASE_COST ((double)0.9)
189 
190 #define BLOCKS_IN_AVG_SEEK 128
191 
192 #define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
193 
194 
200 #define MATCHING_ROWS_IN_OTHER_TABLE 10
201 
202 /*
203  Constants related to the use of temporary tables in query execution.
204  Lookup and write operations are currently assumed to be equally costly
205  (concerns HEAP_TEMPTABLE_ROW_COST and DISK_TEMPTABLE_ROW_COST).
206 */
207 /*
208  Creating a Heap temporary table is by benchmark found to be as costly as
209  writing 10 rows into the table.
210 */
211 #define HEAP_TEMPTABLE_CREATE_COST 2.0
212 /*
213  Writing a row to or reading a row from a Heap temporary table is equivalent
214  to evaluating a row in the join engine.
215 */
216 #define HEAP_TEMPTABLE_ROW_COST 0.2
217 /*
218  Creating a MyISAM table is 20 times slower than creating a Heap table.
219 */
220 #define DISK_TEMPTABLE_CREATE_COST 40.0
221 /*
222  Generating MyIsam rows sequentially is 2 times slower than generating
223  Heap rows, when number of rows is greater than 1000. However, we do not have
224  benchmarks for very large tables, so setting this factor conservatively to
225  be 5 times slower (ie the cost is 1.0).
226 */
227 #define DISK_TEMPTABLE_ROW_COST 1.0
228 
229 #define MY_CHARSET_BIN_MB_MAXLEN 1
230 
232 #define KEY_DEFAULT_PACK_LENGTH 8
233 
235 #define PROCESS_LIST_WIDTH 100
236 /* Characters shown for the command in 'information_schema.processlist' */
237 #define PROCESS_LIST_INFO_WIDTH 65535
238 
239 #define PRECISION_FOR_DOUBLE 53
240 #define PRECISION_FOR_FLOAT 24
241 
242 /* -[digits].E+## */
243 #define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6)
244 /* -[digits].E+### */
245 #define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7)
246 
247 /*
248  Default time to wait before aborting a new client connection
249  that does not respond to "initial server greeting" timely
250 */
251 #define CONNECT_TIMEOUT 10
252 
253 /* The following can also be changed from the command line */
254 #define DEFAULT_CONCURRENCY 10
255 #define DELAYED_LIMIT 100
256 #define DELAYED_QUEUE_SIZE 1000
257 #define DELAYED_WAIT_TIMEOUT 5*60
259 #define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
260 
265 #define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
266 
267 #if defined(__WIN__)
268 #define INTERRUPT_PRIOR -2
269 #define CONNECT_PRIOR -1
270 #define WAIT_PRIOR 0
271 #define QUERY_PRIOR 2
272 #else
273 #define INTERRUPT_PRIOR 10
274 #define CONNECT_PRIOR 9
275 #define WAIT_PRIOR 8
276 #define QUERY_PRIOR 6
277 #endif /* __WIN92__ */
278 
279 #endif /* SQL_CONST_INCLUDED */