1 | #ifndef UNIREG_INCLUDED |
2 | #define UNIREG_INCLUDED |
3 | |
4 | /* |
5 | Copyright (c) 2000, 2011, Oracle and/or its affiliates. |
6 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; version 2 of the License. |
10 | |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
19 | |
20 | |
21 | #include <mysql_version.h> /* FRM_VER */ |
22 | |
23 | /* Extra functions used by unireg library */ |
24 | |
25 | #ifndef NO_ALARM_LOOP |
26 | #define NO_ALARM_LOOP /* lib5 and popen can't use alarm */ |
27 | #endif |
28 | |
29 | /* These paths are converted to other systems (WIN95) before use */ |
30 | |
31 | #define LANGUAGE "english/" |
32 | #define ERRMSG_FILE "errmsg.sys" |
33 | #define TEMP_PREFIX "MY" |
34 | #define LOG_PREFIX "ML" |
35 | #define PROGDIR "bin/" |
36 | #ifndef MYSQL_DATADIR |
37 | #define MYSQL_DATADIR "data/" |
38 | #endif |
39 | #ifndef SHAREDIR |
40 | #define SHAREDIR "share/" |
41 | #endif |
42 | #ifndef PLUGINDIR |
43 | #define PLUGINDIR "lib/plugin" |
44 | #endif |
45 | |
46 | #define MAX_ERROR_RANGES 4 /* 1000-2000, 2000-3000, 3000-4000, 4000-5000 */ |
47 | #define ERRORS_PER_RANGE 1000 |
48 | |
49 | #define DEFAULT_ERRMSGS my_default_lc_messages->errmsgs->errmsgs |
50 | #define CURRENT_THD_ERRMSGS (current_thd)->variables.errmsgs |
51 | |
52 | #ifndef mysqld_error_find_printf_error_used |
53 | #define ER_DEFAULT(X) DEFAULT_ERRMSGS[((X)-ER_ERROR_FIRST) / ERRORS_PER_RANGE][(X)% ERRORS_PER_RANGE] |
54 | #define ER_THD(thd,X) ((thd)->variables.errmsgs[((X)-ER_ERROR_FIRST) / ERRORS_PER_RANGE][(X) % ERRORS_PER_RANGE]) |
55 | #define ER(X) ER_THD(current_thd, (X)) |
56 | #endif |
57 | #define ER_THD_OR_DEFAULT(thd,X) ((thd) ? ER_THD(thd, (X)) : ER_DEFAULT(X)) |
58 | |
59 | |
60 | #define ME_INFO (ME_HOLDTANG | ME_NOREFRESH) |
61 | #define ME_ERROR (ME_BELL | ME_NOREFRESH) |
62 | #define MYF_RW MYF(MY_WME+MY_NABP) /* Vid my_read & my_write */ |
63 | |
64 | #define SPECIAL_USE_LOCKS 1 /* Lock used databases */ |
65 | #define SPECIAL_NO_NEW_FUNC 2 /* Skip new functions */ |
66 | #define SPECIAL_SKIP_SHOW_DB 4 /* Don't allow 'show db' */ |
67 | #define SPECIAL_WAIT_IF_LOCKED 8 /* Wait if locked database */ |
68 | #define SPECIAL_SAME_DB_NAME 16 /* form name = file name */ |
69 | #define SPECIAL_ENGLISH 32 /* English error messages */ |
70 | #define SPECIAL_NO_RESOLVE 64 /* Don't use gethostname */ |
71 | #define SPECIAL_NO_PRIOR 128 /* Obsolete */ |
72 | #define SPECIAL_BIG_SELECTS 256 /* Don't use heap tables */ |
73 | #define SPECIAL_NO_HOST_CACHE 512 /* Don't cache hosts */ |
74 | #define SPECIAL_SHORT_LOG_FORMAT 1024 |
75 | #define SPECIAL_SAFE_MODE 2048 |
76 | #define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Obsolete */ |
77 | |
78 | /* Extern defines */ |
79 | #define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength) |
80 | #define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength) |
81 | #define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength) |
82 | #define empty_record(A) { \ |
83 | restore_record((A),s->default_values); \ |
84 | bfill((A)->null_flags,(A)->s->null_bytes,255);\ |
85 | } |
86 | |
87 | /* Defines for use with openfrm, openprt and openfrd */ |
88 | |
89 | #define READ_ALL (1 << 0) /* openfrm: Read all parameters */ |
90 | #define (1 << 3) /* Reserve space for an extra record */ |
91 | #define DELAYED_OPEN (1 << 12) /* Open table later */ |
92 | #define OPEN_VIEW_NO_PARSE (1 << 14) /* Open frm only if it's a view, |
93 | but do not parse view itself */ |
94 | /** |
95 | This flag is used in function get_all_tables() which fills |
96 | I_S tables with data which are retrieved from frm files and storage engine |
97 | The flag means that we need to open FRM file only to get necessary data. |
98 | */ |
99 | #define OPEN_FRM_FILE_ONLY (1 << 15) |
100 | /** |
101 | This flag is used in function get_all_tables() which fills |
102 | I_S tables with data which are retrieved from frm files and storage engine |
103 | The flag means that we need to process tables only to get necessary data. |
104 | Views are not processed. |
105 | */ |
106 | #define OPEN_TABLE_ONLY (1 << 16) |
107 | /** |
108 | This flag is used in function get_all_tables() which fills |
109 | I_S tables with data which are retrieved from frm files and storage engine |
110 | The flag means that we need to process views only to get necessary data. |
111 | Tables are not processed. |
112 | */ |
113 | #define OPEN_VIEW_ONLY (1 << 17) |
114 | /** |
115 | This flag is used in function get_all_tables() which fills |
116 | I_S tables with data which are retrieved from frm files and storage engine. |
117 | The flag means that we need to open a view using |
118 | open_normal_and_derived_tables() function. |
119 | */ |
120 | #define OPEN_VIEW_FULL (1 << 18) |
121 | /** |
122 | This flag is used in function get_all_tables() which fills |
123 | I_S tables with data which are retrieved from frm files and storage engine. |
124 | The flag means that I_S table uses optimization algorithm. |
125 | */ |
126 | #define OPTIMIZE_I_S_TABLE (1 << 19) |
127 | /** |
128 | This flag is used to instruct tdc_open_view() to check metadata version. |
129 | */ |
130 | #define CHECK_METADATA_VERSION (1 << 20) |
131 | |
132 | /* |
133 | The flag means that we need to process trigger files only. |
134 | */ |
135 | #define OPEN_TRIGGER_ONLY (1 << 21) |
136 | |
137 | /* |
138 | Minimum length pattern before Turbo Boyer-Moore is used |
139 | for SELECT "text" LIKE "%pattern%", excluding the two |
140 | wildcards in class Item_func_like. |
141 | */ |
142 | #define MIN_TURBOBM_PATTERN_LEN 3 |
143 | |
144 | /* |
145 | Defines for binary logging. |
146 | Do not decrease the value of BIN_LOG_HEADER_SIZE. |
147 | Do not even increase it before checking code. |
148 | */ |
149 | |
150 | #define 4 |
151 | |
152 | #define DEFAULT_KEY_CACHE_NAME "default" |
153 | |
154 | |
155 | /* Include prototypes for unireg */ |
156 | |
157 | #include "mysqld_error.h" |
158 | #include "structs.h" /* All structs we need */ |
159 | #include "sql_list.h" /* List<> */ |
160 | #include "field.h" /* Create_field */ |
161 | |
162 | /* |
163 | Types of values in the MariaDB extra2 frm segment. |
164 | Each value is written as |
165 | type: 1 byte |
166 | length: 1 byte (1..255) or \0 and 2 bytes. |
167 | binary value of the 'length' bytes. |
168 | |
169 | Older MariaDB servers can ignore values of unknown types if |
170 | the type code is less than 128 (EXTRA2_ENGINE_IMPORTANT). |
171 | Otherwise older (but newer than 10.0.1) servers are required |
172 | to report an error. |
173 | */ |
174 | enum { |
175 | =0, |
176 | =1, |
177 | =2, |
178 | =4, |
179 | |
180 | #define 128 |
181 | |
182 | =128, |
183 | =129 |
184 | }; |
185 | |
186 | enum { |
187 | VERS_OPTIMIZED_UPDATE= 1 << INVISIBLE_MAX_BITS |
188 | }; |
189 | |
190 | int rea_create_table(THD *thd, LEX_CUSTRING *frm, |
191 | const char *path, const char *db, const char *table_name, |
192 | HA_CREATE_INFO *create_info, handler *file, |
193 | bool no_ha_create_table); |
194 | LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table, |
195 | HA_CREATE_INFO *create_info, |
196 | List<Create_field> &create_fields, |
197 | uint keys, KEY *key_info, handler *db_file); |
198 | |
199 | #define 64 |
200 | #define FRM_FORMINFO_SIZE 288 |
201 | #define FRM_MAX_SIZE (512*1024) |
202 | |
203 | static inline bool (uchar *head) |
204 | { |
205 | return head[0] == 254 |
206 | && head[1] == 1 |
207 | && head[2] >= FRM_VER |
208 | && head[2] <= FRM_VER_CURRENT; |
209 | } |
210 | |
211 | #endif |
212 | |