PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/mysql-5.5.25a/sql/sql_priv.h

#
C Header | 304 lines | 124 code | 39 blank | 141 comment | 7 complexity | 1ca3283f38a29f508e2ee78de9583e7d MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. /**
  13. @file
  14. @details
  15. Mostly this file is used in the server. But a little part of it is used in
  16. mysqlbinlog too (definition of SELECT_DISTINCT and others).
  17. The consequence is that 90% of the file is wrapped in \#ifndef MYSQL_CLIENT,
  18. except the part which must be in the server and in the client.
  19. */
  20. #ifndef SQL_PRIV_INCLUDED
  21. #define SQL_PRIV_INCLUDED
  22. #ifndef MYSQL_CLIENT
  23. /*
  24. Generates a warning that a feature is deprecated. After a specified
  25. version asserts that the feature is removed.
  26. Using it as
  27. WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
  28. Will result in a warning
  29. "The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
  30. use 'GOOD' instead"
  31. Note that in macro arguments BAD is not quoted, while 'GOOD' is.
  32. Note that the version is TWO numbers, separated with a comma
  33. (two macro arguments, that is)
  34. */
  35. #define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New) \
  36. do { \
  37. compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100); \
  38. if (((THD *) Thd) != NULL) \
  39. push_warning_printf(((THD *) Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
  40. ER_WARN_DEPRECATED_SYNTAX, \
  41. ER(ER_WARN_DEPRECATED_SYNTAX), \
  42. (Old), (New)); \
  43. else \
  44. sql_print_warning("The syntax '%s' is deprecated and will be removed " \
  45. "in a future release. Please use %s instead.", \
  46. (Old), (New)); \
  47. } while(0)
  48. /*************************************************************************/
  49. #endif
  50. /*
  51. This is included in the server and in the client.
  52. Options for select set by the yacc parser (stored in lex->options).
  53. NOTE
  54. log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
  55. options list are written into binlog. These options can NOT change their
  56. values, or it will break replication between version.
  57. context is encoded as following:
  58. SELECT - SELECT_LEX_NODE::options
  59. THD - THD::options
  60. intern - neither. used only as
  61. func(..., select_node->options | thd->options | OPTION_XXX, ...)
  62. TODO: separate three contexts above, move them to separate bitfields.
  63. */
  64. #define SELECT_DISTINCT (1ULL << 0) // SELECT, user
  65. #define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user
  66. #define SELECT_DESCRIBE (1ULL << 2) // SELECT, user
  67. #define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user
  68. #define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user
  69. #define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user
  70. #define OPTION_TO_QUERY_CACHE (1ULL << 6) // SELECT, user
  71. #define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern
  72. /** always the opposite of OPTION_NOT_AUTOCOMMIT except when in fix_autocommit() */
  73. #define OPTION_AUTOCOMMIT (1ULL << 8) // THD, user
  74. #define OPTION_BIG_SELECTS (1ULL << 9) // THD, user
  75. #define OPTION_LOG_OFF (1ULL << 10) // THD, user
  76. #define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused
  77. #define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
  78. #define OPTION_WARNINGS (1ULL << 13) // THD, user
  79. #define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
  80. #define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser
  81. #define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
  82. #define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
  83. #define OPTION_BIN_LOG (1ULL << 18) // THD, user
  84. #define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user
  85. #define OPTION_BEGIN (1ULL << 20) // THD, intern
  86. #define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern
  87. #define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE)
  88. #define OPTION_KEEP_LOG (1ULL << 23) // THD, user
  89. /* The following is used to detect a conflict with DISTINCT */
  90. #define SELECT_ALL (1ULL << 24) // SELECT, user, parser
  91. /** The following can be set when importing tables in a 'wrong order'
  92. to suppress foreign key checks */
  93. #define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog
  94. /** The following speeds up inserts to InnoDB tables by suppressing unique
  95. key checks in some cases */
  96. #define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
  97. #define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
  98. #define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
  99. /** Flag set if setup_tables already done */
  100. #define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
  101. /** If not set then the thread will ignore all warnings with level notes. */
  102. #define OPTION_SQL_NOTES (1ULL << 31) // THD, user
  103. /**
  104. Force the used temporary table to be a MyISAM table (because we will use
  105. fulltext functions when reading from it.
  106. */
  107. #define TMP_TABLE_FORCE_MYISAM (1ULL << 32)
  108. #define OPTION_PROFILING (1ULL << 33)
  109. /**
  110. Indicates that this is a HIGH_PRIORITY SELECT.
  111. Currently used only for printing of such selects.
  112. Type of locks to be acquired is specified directly.
  113. */
  114. #define SELECT_HIGH_PRIORITY (1ULL << 34) // SELECT, user
  115. /**
  116. Is set in slave SQL thread when there was an
  117. error on master, which, when is not reproducible
  118. on slave (i.e. the query succeeds on slave),
  119. is not terminal to the state of repliation,
  120. and should be ignored. The slave SQL thread,
  121. however, needs to rollback the effects of the
  122. succeeded statement to keep replication consistent.
  123. */
  124. #define OPTION_MASTER_SQL_ERROR (1ULL << 35)
  125. /*
  126. Dont report errors for individual rows,
  127. But just report error on commit (or read ofcourse)
  128. Note! Reserved for use in MySQL Cluster
  129. */
  130. #define OPTION_ALLOW_BATCH (ULL(1) << 36) // THD, intern (slave)
  131. /* The rest of the file is included in the server only */
  132. #ifndef MYSQL_CLIENT
  133. /* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */
  134. #define OPTIMIZER_SWITCH_INDEX_MERGE (1ULL << 0)
  135. #define OPTIMIZER_SWITCH_INDEX_MERGE_UNION (1ULL << 1)
  136. #define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION (1ULL << 2)
  137. #define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT (1ULL << 3)
  138. #define OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN (1ULL << 4)
  139. #define OPTIMIZER_SWITCH_LAST (1ULL << 5)
  140. /* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
  141. #define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
  142. OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
  143. OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
  144. OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
  145. OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN)
  146. /*
  147. Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
  148. use strictly more than 64 bits by adding one more define above, you should
  149. contact the replication team because the replication code should then be
  150. updated (to store more bytes on disk).
  151. NOTE: When adding new SQL_MODE types, make sure to also add them to
  152. the scripts used for creating the MySQL system tables
  153. in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
  154. */
  155. /*
  156. Flags below are set when we perform
  157. context analysis of the statement and make
  158. subqueries non-const. It prevents subquery
  159. evaluation at context analysis stage.
  160. */
  161. /*
  162. Don't evaluate this subquery during statement prepare even if
  163. it's a constant one. The flag is switched off in the end of
  164. mysqld_stmt_prepare.
  165. */
  166. #define CONTEXT_ANALYSIS_ONLY_PREPARE 1
  167. /*
  168. Special JOIN::prepare mode: changing of query is prohibited.
  169. When creating a view, we need to just check its syntax omitting
  170. any optimizations: afterwards definition of the view will be
  171. reconstructed by means of ::print() methods and written to
  172. to an .frm file. We need this definition to stay untouched.
  173. */
  174. #define CONTEXT_ANALYSIS_ONLY_VIEW 2
  175. /*
  176. Don't evaluate this subquery during derived table prepare even if
  177. it's a constant one.
  178. */
  179. #define CONTEXT_ANALYSIS_ONLY_DERIVED 4
  180. // uncachable cause
  181. #define UNCACHEABLE_DEPENDENT 1
  182. #define UNCACHEABLE_RAND 2
  183. #define UNCACHEABLE_SIDEEFFECT 4
  184. /// forcing to save JOIN for explain
  185. #define UNCACHEABLE_EXPLAIN 8
  186. /* For uncorrelated SELECT in an UNION with some correlated SELECTs */
  187. #define UNCACHEABLE_UNITED 16
  188. #define UNCACHEABLE_CHECKOPTION 32
  189. /* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
  190. #define UNDEF_POS (-1)
  191. /* BINLOG_DUMP options */
  192. #define BINLOG_DUMP_NON_BLOCK 1
  193. /*
  194. Some defines for exit codes for ::is_equal class functions.
  195. */
  196. #define IS_EQUAL_NO 0
  197. #define IS_EQUAL_YES 1
  198. #define IS_EQUAL_PACK_LENGTH 2
  199. enum enum_parsing_place
  200. {
  201. NO_MATTER,
  202. IN_HAVING,
  203. SELECT_LIST,
  204. IN_WHERE,
  205. IN_ON
  206. };
  207. enum enum_var_type
  208. {
  209. OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
  210. };
  211. class sys_var;
  212. enum enum_yes_no_unknown
  213. {
  214. TVL_YES, TVL_NO, TVL_UNKNOWN
  215. };
  216. #ifdef MYSQL_SERVER
  217. #endif /* MYSQL_SERVER */
  218. #ifdef MYSQL_SERVER
  219. /*
  220. External variables
  221. */
  222. /* sql_yacc.cc */
  223. #ifndef DBUG_OFF
  224. extern void turn_parser_debug_on();
  225. #endif
  226. /**
  227. convert a hex digit into number.
  228. */
  229. inline int hexchar_to_int(char c)
  230. {
  231. if (c <= '9' && c >= '0')
  232. return c-'0';
  233. c|=32;
  234. if (c <= 'f' && c >= 'a')
  235. return c-'a'+10;
  236. return -1;
  237. }
  238. /* This must match the path length limit in the ER_NOT_RW_DIR error msg. */
  239. #define ER_NOT_RW_DIR_PATHSIZE 200
  240. #define IS_TABLESPACES_TABLESPACE_NAME 0
  241. #define IS_TABLESPACES_ENGINE 1
  242. #define IS_TABLESPACES_TABLESPACE_TYPE 2
  243. #define IS_TABLESPACES_LOGFILE_GROUP_NAME 3
  244. #define IS_TABLESPACES_EXTENT_SIZE 4
  245. #define IS_TABLESPACES_AUTOEXTEND_SIZE 5
  246. #define IS_TABLESPACES_MAXIMUM_SIZE 6
  247. #define IS_TABLESPACES_NODEGROUP_ID 7
  248. #define IS_TABLESPACES_TABLESPACE_COMMENT 8
  249. #endif /* MYSQL_SERVER */
  250. #endif /* MYSQL_CLIENT */
  251. #endif /* SQL_PRIV_INCLUDED */