My Project
|
00001 /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; version 2 of the License. 00006 00007 This program is distributed in the hope that it will be useful, 00008 but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 GNU General Public License for more details. 00011 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software Foundation, 00014 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 00015 00026 #ifndef SQL_PRIV_INCLUDED 00027 #define SQL_PRIV_INCLUDED 00028 00029 #ifndef MYSQL_CLIENT 00030 00031 /* 00032 Generates a warning that a feature is deprecated. 00033 00034 Using it as 00035 00036 WARN_DEPRECATED(thd, "BAD", "'GOOD'"); 00037 00038 Will result in a warning 00039 00040 "The syntax 'BAD' is deprecated and will be removed in a 00041 future release. Please use 'GOOD' instead" 00042 00043 Note that in macro arguments BAD is not quoted, while 'GOOD' is. 00044 */ 00045 #define WARN_DEPRECATED(Thd,Old,New) \ 00046 do { \ 00047 if (((THD *) Thd) != NULL) \ 00048 push_warning_printf(((THD *) Thd), Sql_condition::WARN_LEVEL_WARN, \ 00049 ER_WARN_DEPRECATED_SYNTAX, \ 00050 ER(ER_WARN_DEPRECATED_SYNTAX), \ 00051 (Old), (New)); \ 00052 else \ 00053 sql_print_warning("The syntax '%s' is deprecated and will be removed " \ 00054 "in a future release. Please use %s instead.", \ 00055 (Old), (New)); \ 00056 } while(0) 00057 00058 00059 /* 00060 Generates a warning that a feature is deprecated and there is no replacement. 00061 00062 Using it as 00063 00064 WARN_DEPRECATED_NO_REPLACEMENT(thd, "BAD"); 00065 00066 Will result in a warning 00067 00068 "'BAD' is deprecated and will be removed in a future release." 00069 00070 Note that in macro arguments BAD is not quoted. 00071 */ 00072 00073 #define WARN_DEPRECATED_NO_REPLACEMENT(Thd,Old) \ 00074 do { \ 00075 if (((THD *) Thd) != NULL) \ 00076 push_warning_printf(((THD *) Thd), Sql_condition::WARN_LEVEL_WARN, \ 00077 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, \ 00078 ER(ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), \ 00079 (Old)); \ 00080 else \ 00081 sql_print_warning("'%s' is deprecated and will be removed " \ 00082 "in a future release.", (Old)); \ 00083 } while(0) 00084 00085 /*************************************************************************/ 00086 00087 #endif 00088 00089 /* 00090 This is included in the server and in the client. 00091 Options for select set by the yacc parser (stored in lex->options). 00092 00093 NOTE 00094 log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD 00095 options list are written into binlog. These options can NOT change their 00096 values, or it will break replication between version. 00097 00098 context is encoded as following: 00099 SELECT - SELECT_LEX_NODE::options 00100 THD - THD::options 00101 intern - neither. used only as 00102 func(..., select_node->options | thd->options | OPTION_XXX, ...) 00103 00104 TODO: separate three contexts above, move them to separate bitfields. 00105 */ 00106 00107 #define SELECT_DISTINCT (1ULL << 0) // SELECT, user 00108 #define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user 00109 #define SELECT_DESCRIBE (1ULL << 2) // SELECT, user 00110 #define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user 00111 #define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user 00112 #define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user 00113 #define OPTION_TO_QUERY_CACHE (1ULL << 6) // SELECT, user 00114 #define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern 00115 00116 #define OPTION_AUTOCOMMIT (1ULL << 8) // THD, user 00117 #define OPTION_BIG_SELECTS (1ULL << 9) // THD, user 00118 #define OPTION_LOG_OFF (1ULL << 10) // THD, user 00119 #define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused 00120 #define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern 00121 #define OPTION_WARNINGS (1ULL << 13) // THD, user 00122 #define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog 00123 #define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser 00124 #define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user 00125 #define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user 00126 #define OPTION_BIN_LOG (1ULL << 18) // THD, user 00127 #define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user 00128 #define OPTION_BEGIN (1ULL << 20) // THD, intern 00129 #define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern 00130 #define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE) 00131 /* 23rd bit is unused. It was occupied by OPTION_KEEP_LOG. */ 00132 00133 /* The following is used to detect a conflict with DISTINCT */ 00134 #define SELECT_ALL (1ULL << 24) // SELECT, user, parser 00135 00137 #define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog 00138 00140 #define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog 00141 #define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern 00142 #define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern 00143 00144 #define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern 00145 00146 #define OPTION_SQL_NOTES (1ULL << 31) // THD, user 00147 00151 #define TMP_TABLE_FORCE_MYISAM (1ULL << 32) 00152 #define OPTION_PROFILING (1ULL << 33) 00153 00158 #define SELECT_HIGH_PRIORITY (1ULL << 34) // SELECT, user 00159 00168 #define OPTION_MASTER_SQL_ERROR (1ULL << 35) 00169 00170 /* 00171 Dont report errors for individual rows, 00172 But just report error on commit (or read ofcourse) 00173 Note! Reserved for use in MySQL Cluster 00174 */ 00175 #define OPTION_ALLOW_BATCH (ULL(1) << 36) // THD, intern (slave) 00176 00177 /* 00178 Check how many bytes are available on buffer. 00179 00180 @param buf_start Pointer to buffer start. 00181 @param buf_current Pointer to the current position on buffer. 00182 @param buf_len Buffer length. 00183 00184 @return Number of bytes available on event buffer. 00185 */ 00186 template <class T> T available_buffer(const char* buf_start, 00187 const char* buf_current, 00188 T buf_len) 00189 { 00190 return buf_len - (buf_current - buf_start); 00191 } 00192 00193 /* 00194 Check if jump value is within buffer limits. 00195 00196 @param jump Number of positions we want to advance. 00197 @param buf_start Pointer to buffer start 00198 @param buf_current Pointer to the current position on buffer. 00199 @param buf_len Buffer length. 00200 00201 @return True If jump value is within buffer limits. 00202 False Otherwise. 00203 */ 00204 template <class T> bool valid_buffer_range(T jump, 00205 const char* buf_start, 00206 const char* buf_current, 00207 T buf_len) 00208 { 00209 return (jump <= available_buffer(buf_start, buf_current, buf_len)); 00210 } 00211 00212 /* The rest of the file is included in the server only */ 00213 #ifndef MYSQL_CLIENT 00214 00215 /* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */ 00216 #define OPTIMIZER_SWITCH_INDEX_MERGE (1ULL << 0) 00217 #define OPTIMIZER_SWITCH_INDEX_MERGE_UNION (1ULL << 1) 00218 #define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION (1ULL << 2) 00219 #define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT (1ULL << 3) 00220 #define OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN (1ULL << 4) 00221 #define OPTIMIZER_SWITCH_INDEX_CONDITION_PUSHDOWN (1ULL << 5) 00222 00223 #define OPTIMIZER_SWITCH_MRR (1ULL << 6) 00224 00230 #define OPTIMIZER_SWITCH_MRR_COST_BASED (1ULL << 7) 00231 #define OPTIMIZER_SWITCH_BNL (1ULL << 8) 00232 #define OPTIMIZER_SWITCH_BKA (1ULL << 9) 00233 #define OPTIMIZER_SWITCH_MATERIALIZATION (1ULL << 10) 00234 #define OPTIMIZER_SWITCH_SEMIJOIN (1ULL << 11) 00235 #define OPTIMIZER_SWITCH_LOOSE_SCAN (1ULL << 12) 00236 #define OPTIMIZER_SWITCH_FIRSTMATCH (1ULL << 13) 00237 #define OPTIMIZER_SWITCH_SUBQ_MAT_COST_BASED (1ULL << 14) 00238 #define OPTIMIZER_SWITCH_USE_INDEX_EXTENSIONS (1ULL << 15) 00239 #define OPTIMIZER_SWITCH_LAST (1ULL << 16) 00240 00245 #define OPTIMIZER_SWITCH_ALL 1 00246 00247 /* 00248 The following must be kept in sync with optimizer_switch string in 00249 sys_vars.cc. 00250 */ 00251 #ifdef OPTIMIZER_SWITCH_ALL 00252 #define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ 00253 OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ 00254 OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ 00255 OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \ 00256 OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN |\ 00257 OPTIMIZER_SWITCH_INDEX_CONDITION_PUSHDOWN | \ 00258 OPTIMIZER_SWITCH_MRR | \ 00259 OPTIMIZER_SWITCH_MRR_COST_BASED | \ 00260 OPTIMIZER_SWITCH_BNL | \ 00261 OPTIMIZER_SWITCH_MATERIALIZATION | \ 00262 OPTIMIZER_SWITCH_SEMIJOIN | \ 00263 OPTIMIZER_SWITCH_LOOSE_SCAN | \ 00264 OPTIMIZER_SWITCH_FIRSTMATCH | \ 00265 OPTIMIZER_SWITCH_SUBQ_MAT_COST_BASED | \ 00266 OPTIMIZER_SWITCH_USE_INDEX_EXTENSIONS) 00267 #else 00268 #define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ 00269 OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ 00270 OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ 00271 OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \ 00272 OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN |\ 00273 OPTIMIZER_SWITCH_INDEX_CONDITION_PUSHDOWN | \ 00274 OPTIMIZER_SWITCH_MRR | \ 00275 OPTIMIZER_SWITCH_MRR_COST_BASED | \ 00276 OPTIMIZER_SWITCH_BNL | \ 00277 OPTIMIZER_SWITCH_USE_INDEX_EXTENSIONS) 00278 #endif 00279 /* 00280 Replication uses 8 bytes to store SQL_MODE in the binary log. The day you 00281 use strictly more than 64 bits by adding one more define above, you should 00282 contact the replication team because the replication code should then be 00283 updated (to store more bytes on disk). 00284 00285 NOTE: When adding new SQL_MODE types, make sure to also add them to 00286 the scripts used for creating the MySQL system tables 00287 in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql 00288 00289 */ 00290 00291 /* 00292 Flags below are set when we perform 00293 context analysis of the statement and make 00294 subqueries non-const. It prevents subquery 00295 evaluation at context analysis stage. 00296 */ 00297 00298 /* 00299 Don't evaluate this subquery during statement prepare even if 00300 it's a constant one. The flag is switched off in the end of 00301 mysqld_stmt_prepare. 00302 */ 00303 #define CONTEXT_ANALYSIS_ONLY_PREPARE 1 00304 /* 00305 Special JOIN::prepare mode: changing of query is prohibited. 00306 When creating a view, we need to just check its syntax omitting 00307 any optimizations: afterwards definition of the view will be 00308 reconstructed by means of ::print() methods and written to 00309 to an .frm file. We need this definition to stay untouched. 00310 */ 00311 #define CONTEXT_ANALYSIS_ONLY_VIEW 2 00312 /* 00313 Don't evaluate this subquery during derived table prepare even if 00314 it's a constant one. 00315 */ 00316 #define CONTEXT_ANALYSIS_ONLY_DERIVED 4 00317 00318 // uncachable cause 00319 #define UNCACHEABLE_DEPENDENT 1 00320 #define UNCACHEABLE_RAND 2 00321 #define UNCACHEABLE_SIDEEFFECT 4 00322 00323 #define UNCACHEABLE_EXPLAIN 8 00324 /* For uncorrelated SELECT in an UNION with some correlated SELECTs */ 00325 #define UNCACHEABLE_UNITED 16 00326 #define UNCACHEABLE_CHECKOPTION 32 00327 00328 /* 00329 Some defines for exit codes for ::is_equal class functions. 00330 */ 00331 #define IS_EQUAL_NO 0 00332 #define IS_EQUAL_YES 1 00333 #define IS_EQUAL_PACK_LENGTH 2 00334 00335 enum enum_parsing_place 00336 { 00337 NO_MATTER, 00338 IN_HAVING, 00339 SELECT_LIST, 00340 IN_WHERE, 00341 IN_ON 00342 }; 00343 00344 00345 enum enum_var_type 00346 { 00347 OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL 00348 }; 00349 00350 class sys_var; 00351 00352 enum enum_yes_no_unknown 00353 { 00354 TVL_YES, TVL_NO, TVL_UNKNOWN 00355 }; 00356 00357 #ifdef MYSQL_SERVER 00358 00359 #endif /* MYSQL_SERVER */ 00360 00361 #ifdef MYSQL_SERVER 00362 /* 00363 External variables 00364 */ 00365 00366 /* sql_yacc.cc */ 00367 #ifndef DBUG_OFF 00368 extern void turn_parser_debug_on(); 00369 00370 #endif 00371 00376 inline int hexchar_to_int(char c) 00377 { 00378 if (c <= '9' && c >= '0') 00379 return c-'0'; 00380 c|=32; 00381 if (c <= 'f' && c >= 'a') 00382 return c-'a'+10; 00383 return -1; 00384 } 00385 00386 /* This must match the path length limit in the ER_NOT_RW_DIR error msg. */ 00387 #define ER_NOT_RW_DIR_PATHSIZE 200 00388 00389 #define IS_TABLESPACES_TABLESPACE_NAME 0 00390 #define IS_TABLESPACES_ENGINE 1 00391 #define IS_TABLESPACES_TABLESPACE_TYPE 2 00392 #define IS_TABLESPACES_LOGFILE_GROUP_NAME 3 00393 #define IS_TABLESPACES_EXTENT_SIZE 4 00394 #define IS_TABLESPACES_AUTOEXTEND_SIZE 5 00395 #define IS_TABLESPACES_MAXIMUM_SIZE 6 00396 #define IS_TABLESPACES_NODEGROUP_ID 7 00397 #define IS_TABLESPACES_TABLESPACE_COMMENT 8 00398 00399 #endif /* MYSQL_SERVER */ 00400 00401 #endif /* MYSQL_CLIENT */ 00402 00403 #endif /* SQL_PRIV_INCLUDED */