1 #ifndef UNIREG_INCLUDED
2 #define UNIREG_INCLUDED
3 
4 /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License, version 2.0,
8    as published by the Free Software Foundation.
9 
10    This program is also distributed with certain software (including
11    but not limited to OpenSSL) that is licensed under separate terms,
12    as designated in a particular file or component or in included license
13    documentation.  The authors of MySQL hereby grant you an additional
14    permission to link the program and your derivative works with the
15    separately licensed software that they have included with MySQL.
16 
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License, version 2.0, for more details.
21 
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software Foundation,
24    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
25 
26 
27 #include "my_global.h"                          /* ulonglong */
28 #include "mysql_version.h"                      /* FRM_VER */
29 
30 /*  Extra functions used by unireg library */
31 
32 typedef struct st_ha_create_information HA_CREATE_INFO;
33 
34 #ifndef NO_ALARM_LOOP
35 #define NO_ALARM_LOOP		/* lib5 and popen can't use alarm */
36 #endif
37 
38 /* These paths are converted to other systems (WIN95) before use */
39 
40 #define LANGUAGE	"english/"
41 #define ERRMSG_FILE	"errmsg.sys"
42 #define TEMP_PREFIX	"MY"
43 #define LOG_PREFIX	"ML"
44 #define PROGDIR		"bin/"
45 #ifndef MYSQL_DATADIR
46 #define MYSQL_DATADIR		"data/"
47 #endif
48 #ifndef SHAREDIR
49 #define SHAREDIR	"share/"
50 #endif
51 #ifndef PLUGINDIR
52 #define PLUGINDIR	"lib/plugin"
53 #endif
54 
55 #define CURRENT_THD_ERRMSGS current_thd->variables.lc_messages->errmsgs->errmsgs
56 #define DEFAULT_ERRMSGS     my_default_lc_messages->errmsgs->errmsgs
57 
58 #define ER(X)         CURRENT_THD_ERRMSGS[(X) - ER_ERROR_FIRST]
59 #define ER_DEFAULT(X) DEFAULT_ERRMSGS[(X) - ER_ERROR_FIRST]
60 #define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : "Invalid error code")
61 #define ER_THD(thd,X) ((thd)->variables.lc_messages->errmsgs->errmsgs[(X) - \
62                        ER_ERROR_FIRST])
63 #define ER_THD_OR_DEFAULT(thd,X) ((thd) ? ER_THD(thd, X) : ER_DEFAULT(X))
64 
65 
66 #define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
67 #define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
68 #define MYF_RW MYF(MY_WME+MY_NABP)		/* Vid my_read & my_write */
69 
70 #define SPECIAL_USE_LOCKS	1		/* Lock used databases */
71 #define SPECIAL_NO_NEW_FUNC	2		/* Skip new functions */
72 #define SPECIAL_SKIP_SHOW_DB    4               /* Don't allow 'show db' */
73 #define SPECIAL_WAIT_IF_LOCKED	8		/* Wait if locked database */
74 #define SPECIAL_SAME_DB_NAME   16		/* form name = file name */
75 #define SPECIAL_ENGLISH        32		/* English error messages */
76 #define SPECIAL_NO_RESOLVE     64		/* Don't use gethostname */
77 #define SPECIAL_NO_PRIOR	128		/* Obsolete */
78 #define SPECIAL_BIG_SELECTS	256		/* Don't use heap tables */
79 #define SPECIAL_NO_HOST_CACHE	512		/* Don't cache hosts */
80 #define SPECIAL_SHORT_LOG_FORMAT 1024
81 /* 2048 is no longer used */
82 #define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Obsolete */
83 
84 	/* Extern defines */
85 #define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
86 #define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
87 #define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
88 #define empty_record(A) { \
89                           restore_record((A),s->default_values); \
90                           memset((A)->null_flags, 255, (A)->s->null_bytes);\
91                         }
92 
93 	/* Defines for use with openfrm, openprt and openfrd */
94 
95 #define READ_ALL		1	/* openfrm: Read all parameters */
96 #define CHANGE_FRM		2	/* openfrm: open .frm as O_RDWR */
97 #define READ_KEYINFO		4	/* L{s nyckeldata fr}n filen */
98 #define EXTRA_RECORD		8	/* Reservera plats f|r extra record */
99 #define DONT_OPEN_TABLES	8	/* Don't open database-files (frd) */
100 #define DONT_OPEN_MASTER_REG	16	/* Don't open first reg-file (prt) */
101 #define EXTRA_LONG_RECORD	16	/* Plats f|r dubbel s|k-record */
102 #define COMPUTE_TYPES		32	/* Kontrollera type f|r f{ltena */
103 #define SEARCH_PRG		64	/* S|k efter registret i 'prg_dev' */
104 #define READ_USED_NAMES		128	/* L{s anv{nda formul{rnamn */
105 #define DONT_GIVE_ERROR		256	/* Don't do frm_error on openfrm  */
106 #define READ_SCREENS		1024	/* Read screens, info and helpfile */
107 #define DELAYED_OPEN		4096	/* Open table later */
108 #define OPEN_VIEW		8192	/* Allow open on view */
109 #define OPEN_VIEW_NO_PARSE     16384    /* Open frm only if it's a view,
110                                            but do not parse view itself */
111 /**
112   This flag is used in function get_all_tables() which fills
113   I_S tables with data which are retrieved from frm files and storage engine
114   The flag means that we need to open FRM file only to get necessary data.
115 */
116 #define OPEN_FRM_FILE_ONLY     32768
117 /**
118   This flag is used in function get_all_tables() which fills
119   I_S tables with data which are retrieved from frm files and storage engine
120   The flag means that we need to process tables only to get necessary data.
121   Views are not processed.
122 */
123 #define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
124 /**
125   This flag is used in function get_all_tables() which fills
126   I_S tables with data which are retrieved from frm files and storage engine
127   The flag means that we need to process views only to get necessary data.
128   Tables are not processed.
129 */
130 #define OPEN_VIEW_ONLY         OPEN_TABLE_ONLY*2
131 /**
132   This flag is used in function get_all_tables() which fills
133   I_S tables with data which are retrieved from frm files and storage engine.
134   The flag means that we need to open a view using
135   open_normal_and_derived_tables() function.
136 */
137 #define OPEN_VIEW_FULL         OPEN_VIEW_ONLY*2
138 /**
139   This flag is used in function get_all_tables() which fills
140   I_S tables with data which are retrieved from frm files and storage engine.
141   The flag means that I_S table uses optimization algorithm.
142 */
143 #define OPTIMIZE_I_S_TABLE     OPEN_VIEW_FULL*2
144 /**
145   The flag means that we need to process trigger files only.
146 */
147 #define OPEN_TRIGGER_ONLY      OPTIMIZE_I_S_TABLE*2
148 /**
149   This flag is used to instruct tdc_open_view() to check metadata version.
150 */
151 #define CHECK_METADATA_VERSION OPEN_TRIGGER_ONLY*2
152 
153 #define SC_INFO_LENGTH 4		/* Form format constant */
154 #define TE_INFO_LENGTH 3
155 #define MTYP_NOEMPTY_BIT 128
156 
157 /*
158   Minimum length pattern before Turbo Boyer-Moore is used
159   for SELECT "text" LIKE "%pattern%", excluding the two
160   wildcards in class Item_func_like.
161 */
162 #define MIN_TURBOBM_PATTERN_LEN 3
163 
164 /*
165    Defines for binary logging.
166    Do not decrease the value of BIN_LOG_HEADER_SIZE.
167    Do not even increase it before checking code.
168 */
169 
170 #define BIN_LOG_HEADER_SIZE    4
171 
172 #define DEFAULT_KEY_CACHE_NAME "default"
173 
174 /* Include prototypes for unireg */
175 
176 #include "mysqld_error.h"
177 #include "structs.h"				/* All structs we need */
178 #include "sql_list.h"                           /* List<> */
179 #include "field.h"                              /* Create_field */
180 
181 bool mysql_create_frm(THD *thd, const char *file_name,
182                       const char *db, const char *table,
183 		      HA_CREATE_INFO *create_info,
184 		      List<Create_field> &create_field,
185 		      uint key_count,KEY *key_info,handler *db_type);
186 int rea_create_table(THD *thd, const char *path,
187                      const char *db, const char *table_name,
188                      HA_CREATE_INFO *create_info,
189   		     List<Create_field> &create_field,
190                      uint key_count,KEY *key_info,
191                      handler *file,
192                      bool no_ha_table);
193 #endif
194