You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3290 lines
119 KiB

  1. --- a/sql/sql_lex.cc
  2. +++ b/sql/sql_lex.cc
  3. @@ -775,14 +775,13 @@ bool consume_comment(Lex_input_stream *l
  4. (which can't be followed by a signed number)
  5. */
  6. -int MYSQLlex(void *arg, void *yythd)
  7. +int MYSQLlex(void *arg, THD *thd)
  8. {
  9. reg1 uchar c= 0;
  10. bool comment_closed;
  11. int tokval, result_state;
  12. uint length;
  13. enum my_lex_states state;
  14. - THD *thd= (THD *)yythd;
  15. Lex_input_stream *lip= & thd->m_parser_state->m_lip;
  16. LEX *lex= thd->lex;
  17. YYSTYPE *yylval=(YYSTYPE*) arg;
  18. --- a/sql/sql_lex.h
  19. +++ b/sql/sql_lex.h
  20. @@ -2072,7 +2072,7 @@ extern void lex_init(void);
  21. extern void lex_free(void);
  22. extern void lex_start(THD *thd);
  23. extern void lex_end(LEX *lex);
  24. -extern int MYSQLlex(void *arg, void *yythd);
  25. +extern int MYSQLlex(void *arg, THD *thd);
  26. extern void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str);
  27. --- a/sql/sql_parse.cc
  28. +++ b/sql/sql_parse.cc
  29. @@ -8012,7 +8012,7 @@ bool check_host_name(LEX_STRING *str)
  30. }
  31. -extern int MYSQLparse(void *thd); // from sql_yacc.cc
  32. +extern int MYSQLparse(THD *thd); // from sql_yacc.cc
  33. /**
  34. --- a/sql/sql_yacc.yy
  35. +++ b/sql/sql_yacc.yy
  36. @@ -25,17 +25,15 @@
  37. %{
  38. /* thd is passed as an argument to yyparse(), and subsequently to yylex().
  39. ** The type will be void*, so it must be cast to (THD*) when used.
  40. -** Use the YYTHD macro for this.
  41. +** Use the thd macro for this.
  42. */
  43. -#define YYPARSE_PARAM yythd
  44. -#define YYLEX_PARAM yythd
  45. -#define YYTHD ((THD *)yythd)
  46. -#define YYLIP (& YYTHD->m_parser_state->m_lip)
  47. +#define YYLIP (& thd->m_parser_state->m_lip)
  48. +#define YYPS (& thd->m_parser_state->m_yacc)
  49. #define MYSQL_YACC
  50. #define YYINITDEPTH 100
  51. #define YYMAXDEPTH 3200 /* Because of 64K stack */
  52. -#define Lex (YYTHD->lex)
  53. +#define Lex (thd->lex)
  54. #define Select Lex->current_select
  55. #include "mysql_priv.h"
  56. #include "slave.h"
  57. @@ -64,7 +62,7 @@ const LEX_STRING null_lex_str= {0,0};
  58. ulong val= *(F); \
  59. if (my_yyoverflow((B), (D), &val)) \
  60. { \
  61. - yyerror((char*) (A)); \
  62. + yyerror(current_thd, (char*) (A)); \
  63. return 2; \
  64. } \
  65. else \
  66. @@ -76,7 +74,7 @@ const LEX_STRING null_lex_str= {0,0};
  67. #define MYSQL_YYABORT \
  68. do \
  69. { \
  70. - LEX::cleanup_lex_after_parse_error(YYTHD);\
  71. + LEX::cleanup_lex_after_parse_error(thd); \
  72. YYABORT; \
  73. } while (0)
  74. @@ -159,10 +157,8 @@ void my_parse_error(const char *s)
  75. to abort from the parser.
  76. */
  77. -void MYSQLerror(const char *s)
  78. +void MYSQLerror(THD *thd, const char *s)
  79. {
  80. - THD *thd= current_thd;
  81. -
  82. /*
  83. Restore the original LEX if it was replaced when parsing
  84. a stored procedure. We must ensure that a parsing error
  85. @@ -675,7 +671,10 @@ static bool add_create_index (LEX *lex,
  86. bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
  87. %}
  88. -%pure_parser /* We have threads */
  89. +/* We have threads */
  90. +%define api.pure
  91. +%parse-param { THD *thd }
  92. +%lex-param { THD *thd }
  93. /*
  94. Currently there are 169 shift/reduce conflicts.
  95. We should not introduce new conflicts any more.
  96. @@ -1516,7 +1515,6 @@ rule: <-- starts at col 1
  97. query:
  98. END_OF_INPUT
  99. {
  100. - THD *thd= YYTHD;
  101. if (!thd->bootstrap &&
  102. (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
  103. {
  104. @@ -1530,7 +1528,7 @@ query:
  105. {
  106. Lex_input_stream *lip = YYLIP;
  107. - if ((YYTHD->client_capabilities & CLIENT_MULTI_QUERIES) &&
  108. + if ((thd->client_capabilities & CLIENT_MULTI_QUERIES) &&
  109. ! lip->stmt_prepare_mode &&
  110. ! lip->eof())
  111. {
  112. @@ -1626,7 +1624,6 @@ statement:
  113. deallocate:
  114. deallocate_or_drop PREPARE_SYM ident
  115. {
  116. - THD *thd= YYTHD;
  117. LEX *lex= thd->lex;
  118. lex->sql_command= SQLCOM_DEALLOCATE_PREPARE;
  119. lex->prepared_stmt_name= $3;
  120. @@ -1641,7 +1638,6 @@ deallocate_or_drop:
  121. prepare:
  122. PREPARE_SYM ident FROM prepare_src
  123. {
  124. - THD *thd= YYTHD;
  125. LEX *lex= thd->lex;
  126. lex->sql_command= SQLCOM_PREPARE;
  127. lex->prepared_stmt_name= $2;
  128. @@ -1651,14 +1647,12 @@ prepare:
  129. prepare_src:
  130. TEXT_STRING_sys
  131. {
  132. - THD *thd= YYTHD;
  133. LEX *lex= thd->lex;
  134. lex->prepared_stmt_code= $1;
  135. lex->prepared_stmt_code_is_varref= FALSE;
  136. }
  137. | '@' ident_or_text
  138. {
  139. - THD *thd= YYTHD;
  140. LEX *lex= thd->lex;
  141. lex->prepared_stmt_code= $2;
  142. lex->prepared_stmt_code_is_varref= TRUE;
  143. @@ -1668,7 +1662,6 @@ prepare_src:
  144. execute:
  145. EXECUTE_SYM ident
  146. {
  147. - THD *thd= YYTHD;
  148. LEX *lex= thd->lex;
  149. lex->sql_command= SQLCOM_EXECUTE;
  150. lex->prepared_stmt_name= $2;
  151. @@ -1826,7 +1819,6 @@ master_file_def:
  152. create:
  153. CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
  154. {
  155. - THD *thd= YYTHD;
  156. LEX *lex= thd->lex;
  157. lex->sql_command= SQLCOM_CREATE_TABLE;
  158. if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
  159. @@ -1844,13 +1836,13 @@ create:
  160. }
  161. create2
  162. {
  163. - LEX *lex= YYTHD->lex;
  164. + LEX *lex= thd->lex;
  165. lex->current_select= &lex->select_lex;
  166. if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) &&
  167. !lex->create_info.db_type)
  168. {
  169. - lex->create_info.db_type= ha_default_handlerton(YYTHD);
  170. - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
  171. + lex->create_info.db_type= ha_default_handlerton(thd);
  172. + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
  173. ER_WARN_USING_OTHER_HANDLER,
  174. ER(ER_WARN_USING_OTHER_HANDLER),
  175. ha_resolve_storage_engine_name(lex->create_info.db_type),
  176. @@ -1979,7 +1971,6 @@ server_option:
  177. event_tail:
  178. remember_name EVENT_SYM opt_if_not_exists sp_name
  179. {
  180. - THD *thd= YYTHD;
  181. LEX *lex=Lex;
  182. lex->stmt_definition_begin= $1;
  183. @@ -2046,7 +2037,7 @@ opt_ev_status:
  184. ev_starts:
  185. /* empty */
  186. {
  187. - Item *item= new (YYTHD->mem_root) Item_func_now_local();
  188. + Item *item= new (thd->mem_root) Item_func_now_local();
  189. if (item == NULL)
  190. MYSQL_YYABORT;
  191. Lex->event_parse_data->item_starts= item;
  192. @@ -2096,7 +2087,6 @@ opt_ev_comment:
  193. ev_sql_stmt:
  194. {
  195. - THD *thd= YYTHD;
  196. LEX *lex= thd->lex;
  197. Lex_input_stream *lip= YYLIP;
  198. @@ -2139,7 +2129,6 @@ ev_sql_stmt:
  199. }
  200. ev_sql_stmt_inner
  201. {
  202. - THD *thd= YYTHD;
  203. LEX *lex= thd->lex;
  204. /* return back to the original memory root ASAP */
  205. @@ -2198,11 +2187,10 @@ sp_name:
  206. $$= new sp_name($1, $3, true);
  207. if ($$ == NULL)
  208. MYSQL_YYABORT;
  209. - $$->init_qname(YYTHD);
  210. + $$->init_qname(thd);
  211. }
  212. | ident
  213. {
  214. - THD *thd= YYTHD;
  215. LEX *lex= thd->lex;
  216. LEX_STRING db;
  217. if (check_routine_name(&$1))
  218. @@ -2272,7 +2260,7 @@ call:
  219. lex->sql_command= SQLCOM_CALL;
  220. lex->spname= $2;
  221. lex->value_list.empty();
  222. - sp_add_used_routine(lex, YYTHD, $2, TYPE_ENUM_PROCEDURE);
  223. + sp_add_used_routine(lex, thd, $2, TYPE_ENUM_PROCEDURE);
  224. }
  225. opt_sp_cparam_list {}
  226. ;
  227. @@ -2345,7 +2333,7 @@ sp_fdparam:
  228. (enum enum_field_types)$3,
  229. sp_param_in);
  230. - if (lex->sphead->fill_field_definition(YYTHD, lex,
  231. + if (lex->sphead->fill_field_definition(thd, lex,
  232. (enum enum_field_types) $3,
  233. &spvar->field_def))
  234. {
  235. @@ -2382,7 +2370,7 @@ sp_pdparam:
  236. (enum enum_field_types)$4,
  237. (sp_param_mode_t)$1);
  238. - if (lex->sphead->fill_field_definition(YYTHD, lex,
  239. + if (lex->sphead->fill_field_definition(thd, lex,
  240. (enum enum_field_types) $4,
  241. &spvar->field_def))
  242. {
  243. @@ -2445,13 +2433,12 @@ sp_decl:
  244. {
  245. LEX *lex= Lex;
  246. - lex->sphead->reset_lex(YYTHD);
  247. + lex->sphead->reset_lex(thd);
  248. lex->spcont->declare_var_boundary($2);
  249. }
  250. type
  251. sp_opt_default
  252. {
  253. - THD *thd= YYTHD;
  254. LEX *lex= Lex;
  255. sp_pcontext *pctx= lex->spcont;
  256. uint num_vars= pctx->context_var_count();
  257. @@ -2477,7 +2464,7 @@ sp_decl:
  258. spvar->type= var_type;
  259. spvar->dflt= dflt_value_item;
  260. - if (lex->sphead->fill_field_definition(YYTHD, lex, var_type,
  261. + if (lex->sphead->fill_field_definition(thd, lex, var_type,
  262. &spvar->field_def))
  263. {
  264. MYSQL_YYABORT;
  265. @@ -2501,7 +2488,7 @@ sp_decl:
  266. }
  267. pctx->declare_var_boundary(0);
  268. - if (lex->sphead->restore_lex(YYTHD))
  269. + if (lex->sphead->restore_lex(thd))
  270. MYSQL_YYABORT;
  271. $$.vars= $2;
  272. $$.conds= $$.hndlrs= $$.curs= 0;
  273. @@ -2516,7 +2503,7 @@ sp_decl:
  274. my_error(ER_SP_DUP_COND, MYF(0), $2.str);
  275. MYSQL_YYABORT;
  276. }
  277. - if(YYTHD->lex->spcont->push_cond(&$2, $5))
  278. + if(thd->lex->spcont->push_cond(&$2, $5))
  279. MYSQL_YYABORT;
  280. $$.vars= $$.hndlrs= $$.curs= 0;
  281. $$.conds= 1;
  282. @@ -2602,7 +2589,7 @@ sp_decl:
  283. sp_cursor_stmt:
  284. {
  285. - Lex->sphead->reset_lex(YYTHD);
  286. + Lex->sphead->reset_lex(thd);
  287. }
  288. select
  289. {
  290. @@ -2618,7 +2605,7 @@ sp_cursor_stmt:
  291. }
  292. lex->sp_lex_in_use= TRUE;
  293. $$= lex;
  294. - if (lex->sphead->restore_lex(YYTHD))
  295. + if (lex->sphead->restore_lex(thd))
  296. MYSQL_YYABORT;
  297. }
  298. ;
  299. @@ -2662,7 +2649,7 @@ sp_hcond_element:
  300. sp_cond:
  301. ulong_num
  302. { /* mysql errno */
  303. - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
  304. + $$= (sp_cond_type_t *)thd->alloc(sizeof(sp_cond_type_t));
  305. if ($$ == NULL)
  306. MYSQL_YYABORT;
  307. $$->type= sp_cond_type_t::number;
  308. @@ -2675,7 +2662,7 @@ sp_cond:
  309. my_error(ER_SP_BAD_SQLSTATE, MYF(0), $3.str);
  310. MYSQL_YYABORT;
  311. }
  312. - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
  313. + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t));
  314. if ($$ == NULL)
  315. MYSQL_YYABORT;
  316. $$->type= sp_cond_type_t::state;
  317. @@ -2705,21 +2692,21 @@ sp_hcond:
  318. }
  319. | SQLWARNING_SYM /* SQLSTATEs 01??? */
  320. {
  321. - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
  322. + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t));
  323. if ($$ == NULL)
  324. MYSQL_YYABORT;
  325. $$->type= sp_cond_type_t::warning;
  326. }
  327. | not FOUND_SYM /* SQLSTATEs 02??? */
  328. {
  329. - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
  330. + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t));
  331. if ($$ == NULL)
  332. MYSQL_YYABORT;
  333. $$->type= sp_cond_type_t::notfound;
  334. }
  335. | SQLEXCEPTION_SYM /* All other SQLSTATEs */
  336. {
  337. - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
  338. + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t));
  339. if ($$ == NULL)
  340. MYSQL_YYABORT;
  341. $$->type= sp_cond_type_t::exception;
  342. @@ -2789,7 +2776,6 @@ sp_proc_stmt_if:
  343. sp_proc_stmt_statement:
  344. {
  345. - THD *thd= YYTHD;
  346. LEX *lex= thd->lex;
  347. Lex_input_stream *lip= YYLIP;
  348. @@ -2798,7 +2784,6 @@ sp_proc_stmt_statement:
  349. }
  350. statement
  351. {
  352. - THD *thd= YYTHD;
  353. LEX *lex= thd->lex;
  354. Lex_input_stream *lip= YYLIP;
  355. sp_head *sp= lex->sphead;
  356. @@ -2845,7 +2830,7 @@ sp_proc_stmt_statement:
  357. sp_proc_stmt_return:
  358. RETURN_SYM
  359. - { Lex->sphead->reset_lex(YYTHD); }
  360. + { Lex->sphead->reset_lex(thd); }
  361. expr
  362. {
  363. LEX *lex= Lex;
  364. @@ -2867,7 +2852,7 @@ sp_proc_stmt_return:
  365. MYSQL_YYABORT;
  366. sp->m_flags|= sp_head::HAS_RETURN;
  367. }
  368. - if (sp->restore_lex(YYTHD))
  369. + if (sp->restore_lex(thd))
  370. MYSQL_YYABORT;
  371. }
  372. ;
  373. @@ -3094,7 +3079,7 @@ sp_fetch_list:
  374. ;
  375. sp_if:
  376. - { Lex->sphead->reset_lex(YYTHD); }
  377. + { Lex->sphead->reset_lex(thd); }
  378. expr THEN_SYM
  379. {
  380. LEX *lex= Lex;
  381. @@ -3108,7 +3093,7 @@ sp_if:
  382. sp->add_cont_backpatch(i) ||
  383. sp->add_instr(i))
  384. MYSQL_YYABORT;
  385. - if (sp->restore_lex(YYTHD))
  386. + if (sp->restore_lex(thd))
  387. MYSQL_YYABORT;
  388. }
  389. sp_proc_stmts1
  390. @@ -3147,7 +3132,7 @@ simple_case_stmt:
  391. {
  392. LEX *lex= Lex;
  393. case_stmt_action_case(lex);
  394. - lex->sphead->reset_lex(YYTHD); /* For expr $3 */
  395. + lex->sphead->reset_lex(thd); /* For expr $3 */
  396. }
  397. expr
  398. {
  399. @@ -3156,7 +3141,7 @@ simple_case_stmt:
  400. MYSQL_YYABORT;
  401. /* For expr $3 */
  402. - if (lex->sphead->restore_lex(YYTHD))
  403. + if (lex->sphead->restore_lex(thd))
  404. MYSQL_YYABORT;
  405. }
  406. simple_when_clause_list
  407. @@ -3198,7 +3183,7 @@ searched_when_clause_list:
  408. simple_when_clause:
  409. WHEN_SYM
  410. {
  411. - Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
  412. + Lex->sphead->reset_lex(thd); /* For expr $3 */
  413. }
  414. expr
  415. {
  416. @@ -3208,7 +3193,7 @@ simple_when_clause:
  417. if (case_stmt_action_when(lex, $3, true))
  418. MYSQL_YYABORT;
  419. /* For expr $3 */
  420. - if (lex->sphead->restore_lex(YYTHD))
  421. + if (lex->sphead->restore_lex(thd))
  422. MYSQL_YYABORT;
  423. }
  424. THEN_SYM
  425. @@ -3223,7 +3208,7 @@ simple_when_clause:
  426. searched_when_clause:
  427. WHEN_SYM
  428. {
  429. - Lex->sphead->reset_lex(YYTHD); /* For expr $3 */
  430. + Lex->sphead->reset_lex(thd); /* For expr $3 */
  431. }
  432. expr
  433. {
  434. @@ -3231,7 +3216,7 @@ searched_when_clause:
  435. if (case_stmt_action_when(lex, $3, false))
  436. MYSQL_YYABORT;
  437. /* For expr $3 */
  438. - if (lex->sphead->restore_lex(YYTHD))
  439. + if (lex->sphead->restore_lex(thd))
  440. MYSQL_YYABORT;
  441. }
  442. THEN_SYM
  443. @@ -3395,7 +3380,7 @@ sp_unlabeled_control:
  444. MYSQL_YYABORT;
  445. }
  446. | WHILE_SYM
  447. - { Lex->sphead->reset_lex(YYTHD); }
  448. + { Lex->sphead->reset_lex(thd); }
  449. expr DO_SYM
  450. {
  451. LEX *lex= Lex;
  452. @@ -3409,7 +3394,7 @@ sp_unlabeled_control:
  453. sp->new_cont_backpatch(i) ||
  454. sp->add_instr(i))
  455. MYSQL_YYABORT;
  456. - if (sp->restore_lex(YYTHD))
  457. + if (sp->restore_lex(thd))
  458. MYSQL_YYABORT;
  459. }
  460. sp_proc_stmts1 END WHILE_SYM
  461. @@ -3424,7 +3409,7 @@ sp_unlabeled_control:
  462. lex->sphead->do_cont_backpatch();
  463. }
  464. | REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
  465. - { Lex->sphead->reset_lex(YYTHD); }
  466. + { Lex->sphead->reset_lex(thd); }
  467. expr END REPEAT_SYM
  468. {
  469. LEX *lex= Lex;
  470. @@ -3436,7 +3421,7 @@ sp_unlabeled_control:
  471. if (i == NULL ||
  472. lex->sphead->add_instr(i))
  473. MYSQL_YYABORT;
  474. - if (lex->sphead->restore_lex(YYTHD))
  475. + if (lex->sphead->restore_lex(thd))
  476. MYSQL_YYABORT;
  477. /* We can shortcut the cont_backpatch here */
  478. i->m_cont_dest= ip+1;
  479. @@ -3859,7 +3844,6 @@ create2:
  480. create3 {}
  481. | LIKE table_ident
  482. {
  483. - THD *thd= YYTHD;
  484. TABLE_LIST *src_table;
  485. LEX *lex= thd->lex;
  486. @@ -3873,7 +3857,6 @@ create2:
  487. }
  488. | '(' LIKE table_ident ')'
  489. {
  490. - THD *thd= YYTHD;
  491. TABLE_LIST *src_table;
  492. LEX *lex= thd->lex;
  493. @@ -4342,7 +4325,6 @@ part_bit_expr:
  494. bit_expr
  495. {
  496. Item *part_expr= $1;
  497. - THD *thd= YYTHD;
  498. LEX *lex= thd->lex;
  499. Name_resolution_context *context= &lex->current_select->context;
  500. TABLE_LIST *save_list= context->table_list;
  501. @@ -4364,7 +4346,7 @@ part_bit_expr:
  502. my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
  503. MYSQL_YYABORT;
  504. }
  505. - if (part_expr->fix_fields(YYTHD, (Item**)0) ||
  506. + if (part_expr->fix_fields(thd, (Item**)0) ||
  507. ((context->table_list= save_list), FALSE) ||
  508. (!part_expr->const_item()) ||
  509. (!lex->safe_to_cache_query))
  510. @@ -4629,7 +4611,7 @@ create_table_option:
  511. | TYPE_SYM opt_equal storage_engines
  512. {
  513. Lex->create_info.db_type= $3;
  514. - WARN_DEPRECATED(yythd, "6.0", "TYPE=storage_engine",
  515. + WARN_DEPRECATED(thd, "6.0", "TYPE=storage_engine",
  516. "'ENGINE=storage_engine'");
  517. Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
  518. }
  519. @@ -4791,19 +4773,19 @@ default_collation:
  520. storage_engines:
  521. ident_or_text
  522. {
  523. - plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1);
  524. + plugin_ref plugin= ha_resolve_by_name(thd, &$1);
  525. if (plugin)
  526. $$= plugin_data(plugin, handlerton*);
  527. else
  528. {
  529. - if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
  530. + if (thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
  531. {
  532. my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
  533. MYSQL_YYABORT;
  534. }
  535. $$= 0;
  536. - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
  537. + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
  538. ER_UNKNOWN_STORAGE_ENGINE,
  539. ER(ER_UNKNOWN_STORAGE_ENGINE),
  540. $1.str);
  541. @@ -4815,7 +4797,7 @@ known_storage_engines:
  542. ident_or_text
  543. {
  544. plugin_ref plugin;
  545. - if ((plugin= ha_resolve_by_name(YYTHD, &$1)))
  546. + if ((plugin= ha_resolve_by_name(thd, &$1)))
  547. $$= plugin_data(plugin, handlerton*);
  548. else
  549. {
  550. @@ -5043,7 +5025,7 @@ type:
  551. {
  552. char buff[sizeof("YEAR()") + MY_INT64_NUM_DECIMAL_DIGITS + 1];
  553. my_snprintf(buff, sizeof(buff), "YEAR(%lu)", length);
  554. - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_NOTE,
  555. + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
  556. ER_WARN_DEPRECATED_SYNTAX,
  557. ER(ER_WARN_DEPRECATED_SYNTAX),
  558. buff, "YEAR(4)");
  559. @@ -5057,7 +5039,7 @@ type:
  560. { $$=MYSQL_TYPE_TIME; }
  561. | TIMESTAMP opt_field_length
  562. {
  563. - if (YYTHD->variables.sql_mode & MODE_MAXDB)
  564. + if (thd->variables.sql_mode & MODE_MAXDB)
  565. $$=MYSQL_TYPE_DATETIME;
  566. else
  567. {
  568. @@ -5189,7 +5171,7 @@ int_type:
  569. real_type:
  570. REAL
  571. {
  572. - $$= YYTHD->variables.sql_mode & MODE_REAL_AS_FLOAT ?
  573. + $$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ?
  574. MYSQL_TYPE_FLOAT : MYSQL_TYPE_DOUBLE;
  575. }
  576. | DOUBLE_SYM
  577. @@ -5263,7 +5245,7 @@ attribute:
  578. | DEFAULT now_or_signed_literal { Lex->default_value=$2; }
  579. | ON UPDATE_SYM NOW_SYM optional_braces
  580. {
  581. - Item *item= new (YYTHD->mem_root) Item_func_now_local();
  582. + Item *item= new (thd->mem_root) Item_func_now_local();
  583. if (item == NULL)
  584. MYSQL_YYABORT;
  585. Lex->on_update_value= item;
  586. @@ -5312,7 +5294,7 @@ attribute:
  587. now_or_signed_literal:
  588. NOW_SYM optional_braces
  589. {
  590. - $$= new (YYTHD->mem_root) Item_func_now_local();
  591. + $$= new (thd->mem_root) Item_func_now_local();
  592. if ($$ == NULL)
  593. MYSQL_YYABORT;
  594. }
  595. @@ -5673,7 +5655,6 @@ string_list:
  596. alter:
  597. ALTER opt_ignore TABLE_SYM table_ident
  598. {
  599. - THD *thd= YYTHD;
  600. LEX *lex= thd->lex;
  601. lex->name.str= 0;
  602. lex->name.length= 0;
  603. @@ -5799,7 +5780,7 @@ alter:
  604. Event_parse_data.
  605. */
  606. - if (!(Lex->event_parse_data= Event_parse_data::new_instance(YYTHD)))
  607. + if (!(Lex->event_parse_data= Event_parse_data::new_instance(thd)))
  608. MYSQL_YYABORT;
  609. Lex->event_parse_data->identifier= $4;
  610. @@ -6192,7 +6173,6 @@ alter_list_item:
  611. {
  612. if (!$4)
  613. {
  614. - THD *thd= YYTHD;
  615. $4= thd->variables.collation_database;
  616. }
  617. $5= $5 ? $5 : $4;
  618. @@ -6556,7 +6536,7 @@ keycache_list:
  619. assign_to_keycache:
  620. table_ident cache_keys_spec
  621. {
  622. - if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ,
  623. + if (!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ,
  624. Select->pop_index_hints()))
  625. MYSQL_YYABORT;
  626. }
  627. @@ -6585,7 +6565,7 @@ preload_list:
  628. preload_keys:
  629. table_ident cache_keys_spec opt_ignore_leaves
  630. {
  631. - if (!Select->add_table_to_list(YYTHD, $1, NULL, $3, TL_READ,
  632. + if (!Select->add_table_to_list(thd, $1, NULL, $3, TL_READ,
  633. Select->pop_index_hints()))
  634. MYSQL_YYABORT;
  635. }
  636. @@ -6593,7 +6573,7 @@ preload_keys:
  637. cache_keys_spec:
  638. {
  639. - Lex->select_lex.alloc_index_hints(YYTHD);
  640. + Lex->select_lex.alloc_index_hints(thd);
  641. Select->set_index_hint_type(INDEX_HINT_USE,
  642. global_system_variables.old_mode ?
  643. INDEX_HINT_MASK_JOIN :
  644. @@ -6813,7 +6793,6 @@ select_item_list:
  645. | select_item
  646. | '*'
  647. {
  648. - THD *thd= YYTHD;
  649. Item *item= new (thd->mem_root)
  650. Item_field(&thd->lex->current_select->context,
  651. NULL, NULL, "*");
  652. @@ -6828,7 +6807,6 @@ select_item_list:
  653. select_item:
  654. remember_name select_item2 remember_end select_alias
  655. {
  656. - THD *thd= YYTHD;
  657. DBUG_ASSERT($1 < $3);
  658. if (add_item_to_list(thd, $2))
  659. @@ -6929,7 +6907,7 @@ expr:
  660. else
  661. {
  662. /* X OR Y */
  663. - $$ = new (YYTHD->mem_root) Item_cond_or($1, $3);
  664. + $$ = new (thd->mem_root) Item_cond_or($1, $3);
  665. if ($$ == NULL)
  666. MYSQL_YYABORT;
  667. }
  668. @@ -6937,7 +6915,7 @@ expr:
  669. | expr XOR expr %prec XOR
  670. {
  671. /* XOR is a proprietary extension */
  672. - $$ = new (YYTHD->mem_root) Item_cond_xor($1, $3);
  673. + $$ = new (thd->mem_root) Item_cond_xor($1, $3);
  674. if ($$ == NULL)
  675. MYSQL_YYABORT;
  676. }
  677. @@ -6979,50 +6957,50 @@ expr:
  678. else
  679. {
  680. /* X AND Y */
  681. - $$ = new (YYTHD->mem_root) Item_cond_and($1, $3);
  682. + $$ = new (thd->mem_root) Item_cond_and($1, $3);
  683. if ($$ == NULL)
  684. MYSQL_YYABORT;
  685. }
  686. }
  687. | NOT_SYM expr %prec NOT_SYM
  688. {
  689. - $$= negate_expression(YYTHD, $2);
  690. + $$= negate_expression(thd, $2);
  691. if ($$ == NULL)
  692. MYSQL_YYABORT;
  693. }
  694. | bool_pri IS TRUE_SYM %prec IS
  695. {
  696. - $$= new (YYTHD->mem_root) Item_func_istrue($1);
  697. + $$= new (thd->mem_root) Item_func_istrue($1);
  698. if ($$ == NULL)
  699. MYSQL_YYABORT;
  700. }
  701. | bool_pri IS not TRUE_SYM %prec IS
  702. {
  703. - $$= new (YYTHD->mem_root) Item_func_isnottrue($1);
  704. + $$= new (thd->mem_root) Item_func_isnottrue($1);
  705. if ($$ == NULL)
  706. MYSQL_YYABORT;
  707. }
  708. | bool_pri IS FALSE_SYM %prec IS
  709. {
  710. - $$= new (YYTHD->mem_root) Item_func_isfalse($1);
  711. + $$= new (thd->mem_root) Item_func_isfalse($1);
  712. if ($$ == NULL)
  713. MYSQL_YYABORT;
  714. }
  715. | bool_pri IS not FALSE_SYM %prec IS
  716. {
  717. - $$= new (YYTHD->mem_root) Item_func_isnotfalse($1);
  718. + $$= new (thd->mem_root) Item_func_isnotfalse($1);
  719. if ($$ == NULL)
  720. MYSQL_YYABORT;
  721. }
  722. | bool_pri IS UNKNOWN_SYM %prec IS
  723. {
  724. - $$= new (YYTHD->mem_root) Item_func_isnull($1);
  725. + $$= new (thd->mem_root) Item_func_isnull($1);
  726. if ($$ == NULL)
  727. MYSQL_YYABORT;
  728. }
  729. | bool_pri IS not UNKNOWN_SYM %prec IS
  730. {
  731. - $$= new (YYTHD->mem_root) Item_func_isnotnull($1);
  732. + $$= new (thd->mem_root) Item_func_isnotnull($1);
  733. if ($$ == NULL)
  734. MYSQL_YYABORT;
  735. }
  736. @@ -7032,19 +7010,19 @@ expr:
  737. bool_pri:
  738. bool_pri IS NULL_SYM %prec IS
  739. {
  740. - $$= new (YYTHD->mem_root) Item_func_isnull($1);
  741. + $$= new (thd->mem_root) Item_func_isnull($1);
  742. if ($$ == NULL)
  743. MYSQL_YYABORT;
  744. }
  745. | bool_pri IS not NULL_SYM %prec IS
  746. {
  747. - $$= new (YYTHD->mem_root) Item_func_isnotnull($1);
  748. + $$= new (thd->mem_root) Item_func_isnotnull($1);
  749. if ($$ == NULL)
  750. MYSQL_YYABORT;
  751. }
  752. | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
  753. {
  754. - $$= new (YYTHD->mem_root) Item_func_equal($1,$3);
  755. + $$= new (thd->mem_root) Item_func_equal($1,$3);
  756. if ($$ == NULL)
  757. MYSQL_YYABORT;
  758. }
  759. @@ -7066,13 +7044,12 @@ bool_pri:
  760. predicate:
  761. bit_expr IN_SYM '(' subselect ')'
  762. {
  763. - $$= new (YYTHD->mem_root) Item_in_subselect($1, $4);
  764. + $$= new (thd->mem_root) Item_in_subselect($1, $4);
  765. if ($$ == NULL)
  766. MYSQL_YYABORT;
  767. }
  768. | bit_expr not IN_SYM '(' subselect ')'
  769. {
  770. - THD *thd= YYTHD;
  771. Item *item= new (thd->mem_root) Item_in_subselect($1, $5);
  772. if (item == NULL)
  773. MYSQL_YYABORT;
  774. @@ -7082,7 +7059,7 @@ predicate:
  775. }
  776. | bit_expr IN_SYM '(' expr ')'
  777. {
  778. - $$= handle_sql2003_note184_exception(YYTHD, $1, true, $4);
  779. + $$= handle_sql2003_note184_exception(thd, $1, true, $4);
  780. if ($$ == NULL)
  781. MYSQL_YYABORT;
  782. }
  783. @@ -7090,13 +7067,13 @@ predicate:
  784. {
  785. $6->push_front($4);
  786. $6->push_front($1);
  787. - $$= new (YYTHD->mem_root) Item_func_in(*$6);
  788. + $$= new (thd->mem_root) Item_func_in(*$6);
  789. if ($$ == NULL)
  790. MYSQL_YYABORT;
  791. }
  792. | bit_expr not IN_SYM '(' expr ')'
  793. {
  794. - $$= handle_sql2003_note184_exception(YYTHD, $1, false, $5);
  795. + $$= handle_sql2003_note184_exception(thd, $1, false, $5);
  796. if ($$ == NULL)
  797. MYSQL_YYABORT;
  798. }
  799. @@ -7104,7 +7081,7 @@ predicate:
  800. {
  801. $7->push_front($5);
  802. $7->push_front($1);
  803. - Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7);
  804. + Item_func_in *item = new (thd->mem_root) Item_func_in(*$7);
  805. if (item == NULL)
  806. MYSQL_YYABORT;
  807. item->negate();
  808. @@ -7112,14 +7089,14 @@ predicate:
  809. }
  810. | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate
  811. {
  812. - $$= new (YYTHD->mem_root) Item_func_between($1,$3,$5);
  813. + $$= new (thd->mem_root) Item_func_between($1,$3,$5);
  814. if ($$ == NULL)
  815. MYSQL_YYABORT;
  816. }
  817. | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
  818. {
  819. Item_func_between *item;
  820. - item= new (YYTHD->mem_root) Item_func_between($1,$4,$6);
  821. + item= new (thd->mem_root) Item_func_between($1,$4,$6);
  822. if (item == NULL)
  823. MYSQL_YYABORT;
  824. item->negate();
  825. @@ -7127,42 +7104,42 @@ predicate:
  826. }
  827. | bit_expr SOUNDS_SYM LIKE bit_expr
  828. {
  829. - Item *item1= new (YYTHD->mem_root) Item_func_soundex($1);
  830. - Item *item4= new (YYTHD->mem_root) Item_func_soundex($4);
  831. + Item *item1= new (thd->mem_root) Item_func_soundex($1);
  832. + Item *item4= new (thd->mem_root) Item_func_soundex($4);
  833. if ((item1 == NULL) || (item4 == NULL))
  834. MYSQL_YYABORT;
  835. - $$= new (YYTHD->mem_root) Item_func_eq(item1, item4);
  836. + $$= new (thd->mem_root) Item_func_eq(item1, item4);
  837. if ($$ == NULL)
  838. MYSQL_YYABORT;
  839. }
  840. | bit_expr LIKE simple_expr opt_escape
  841. {
  842. - $$= new (YYTHD->mem_root) Item_func_like($1,$3,$4,Lex->escape_used);
  843. + $$= new (thd->mem_root) Item_func_like($1,$3,$4,Lex->escape_used);
  844. if ($$ == NULL)
  845. MYSQL_YYABORT;
  846. }
  847. | bit_expr not LIKE simple_expr opt_escape
  848. {
  849. - Item *item= new (YYTHD->mem_root) Item_func_like($1,$4,$5,
  850. + Item *item= new (thd->mem_root) Item_func_like($1,$4,$5,
  851. Lex->escape_used);
  852. if (item == NULL)
  853. MYSQL_YYABORT;
  854. - $$= new (YYTHD->mem_root) Item_func_not(item);
  855. + $$= new (thd->mem_root) Item_func_not(item);
  856. if ($$ == NULL)
  857. MYSQL_YYABORT;
  858. }
  859. | bit_expr REGEXP bit_expr
  860. {
  861. - $$= new (YYTHD->mem_root) Item_func_regex($1,$3);
  862. + $$= new (thd->mem_root) Item_func_regex($1,$3);
  863. if ($$ == NULL)
  864. MYSQL_YYABORT;
  865. }
  866. | bit_expr not REGEXP bit_expr
  867. {
  868. - Item *item= new (YYTHD->mem_root) Item_func_regex($1,$4);
  869. + Item *item= new (thd->mem_root) Item_func_regex($1,$4);
  870. if (item == NULL)
  871. MYSQL_YYABORT;
  872. - $$= negate_expression(YYTHD, item);
  873. + $$= negate_expression(thd, item);
  874. if ($$ == NULL)
  875. MYSQL_YYABORT;
  876. }
  877. @@ -7172,85 +7149,85 @@ predicate:
  878. bit_expr:
  879. bit_expr '|' bit_expr %prec '|'
  880. {
  881. - $$= new (YYTHD->mem_root) Item_func_bit_or($1,$3);
  882. + $$= new (thd->mem_root) Item_func_bit_or($1,$3);
  883. if ($$ == NULL)
  884. MYSQL_YYABORT;
  885. }
  886. | bit_expr '&' bit_expr %prec '&'
  887. {
  888. - $$= new (YYTHD->mem_root) Item_func_bit_and($1,$3);
  889. + $$= new (thd->mem_root) Item_func_bit_and($1,$3);
  890. if ($$ == NULL)
  891. MYSQL_YYABORT;
  892. }
  893. | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT
  894. {
  895. - $$= new (YYTHD->mem_root) Item_func_shift_left($1,$3);
  896. + $$= new (thd->mem_root) Item_func_shift_left($1,$3);
  897. if ($$ == NULL)
  898. MYSQL_YYABORT;
  899. }
  900. | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT
  901. {
  902. - $$= new (YYTHD->mem_root) Item_func_shift_right($1,$3);
  903. + $$= new (thd->mem_root) Item_func_shift_right($1,$3);
  904. if ($$ == NULL)
  905. MYSQL_YYABORT;
  906. }
  907. | bit_expr '+' bit_expr %prec '+'
  908. {
  909. - $$= new (YYTHD->mem_root) Item_func_plus($1,$3);
  910. + $$= new (thd->mem_root) Item_func_plus($1,$3);
  911. if ($$ == NULL)
  912. MYSQL_YYABORT;
  913. }
  914. | bit_expr '-' bit_expr %prec '-'
  915. {
  916. - $$= new (YYTHD->mem_root) Item_func_minus($1,$3);
  917. + $$= new (thd->mem_root) Item_func_minus($1,$3);
  918. if ($$ == NULL)
  919. MYSQL_YYABORT;
  920. }
  921. | bit_expr '+' INTERVAL_SYM expr interval %prec '+'
  922. {
  923. - $$= new (YYTHD->mem_root) Item_date_add_interval($1,$4,$5,0);
  924. + $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,0);
  925. if ($$ == NULL)
  926. MYSQL_YYABORT;
  927. }
  928. | bit_expr '-' INTERVAL_SYM expr interval %prec '-'
  929. {
  930. - $$= new (YYTHD->mem_root) Item_date_add_interval($1,$4,$5,1);
  931. + $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,1);
  932. if ($$ == NULL)
  933. MYSQL_YYABORT;
  934. }
  935. | bit_expr '*' bit_expr %prec '*'
  936. {
  937. - $$= new (YYTHD->mem_root) Item_func_mul($1,$3);
  938. + $$= new (thd->mem_root) Item_func_mul($1,$3);
  939. if ($$ == NULL)
  940. MYSQL_YYABORT;
  941. }
  942. | bit_expr '/' bit_expr %prec '/'
  943. {
  944. - $$= new (YYTHD->mem_root) Item_func_div($1,$3);
  945. + $$= new (thd->mem_root) Item_func_div($1,$3);
  946. if ($$ == NULL)
  947. MYSQL_YYABORT;
  948. }
  949. | bit_expr '%' bit_expr %prec '%'
  950. {
  951. - $$= new (YYTHD->mem_root) Item_func_mod($1,$3);
  952. + $$= new (thd->mem_root) Item_func_mod($1,$3);
  953. if ($$ == NULL)
  954. MYSQL_YYABORT;
  955. }
  956. | bit_expr DIV_SYM bit_expr %prec DIV_SYM
  957. {
  958. - $$= new (YYTHD->mem_root) Item_func_int_div($1,$3);
  959. + $$= new (thd->mem_root) Item_func_int_div($1,$3);
  960. if ($$ == NULL)
  961. MYSQL_YYABORT;
  962. }
  963. | bit_expr MOD_SYM bit_expr %prec MOD_SYM
  964. {
  965. - $$= new (YYTHD->mem_root) Item_func_mod($1,$3);
  966. + $$= new (thd->mem_root) Item_func_mod($1,$3);
  967. if ($$ == NULL)
  968. MYSQL_YYABORT;
  969. }
  970. | bit_expr '^' bit_expr
  971. {
  972. - $$= new (YYTHD->mem_root) Item_func_bit_xor($1,$3);
  973. + $$= new (thd->mem_root) Item_func_bit_xor($1,$3);
  974. if ($$ == NULL)
  975. MYSQL_YYABORT;
  976. }
  977. @@ -7299,7 +7276,6 @@ simple_expr:
  978. | function_call_conflict
  979. | simple_expr COLLATE_SYM ident_or_text %prec NEG
  980. {
  981. - THD *thd= YYTHD;
  982. Item *i1= new (thd->mem_root) Item_string($3.str,
  983. $3.length,
  984. thd->charset());
  985. @@ -7315,7 +7291,7 @@ simple_expr:
  986. | sum_expr
  987. | simple_expr OR_OR_SYM simple_expr
  988. {
  989. - $$= new (YYTHD->mem_root) Item_func_concat($1, $3);
  990. + $$= new (thd->mem_root) Item_func_concat($1, $3);
  991. if ($$ == NULL)
  992. MYSQL_YYABORT;
  993. }
  994. @@ -7325,25 +7301,25 @@ simple_expr:
  995. }
  996. | '-' simple_expr %prec NEG
  997. {
  998. - $$= new (YYTHD->mem_root) Item_func_neg($2);
  999. + $$= new (thd->mem_root) Item_func_neg($2);
  1000. if ($$ == NULL)
  1001. MYSQL_YYABORT;
  1002. }
  1003. | '~' simple_expr %prec NEG
  1004. {
  1005. - $$= new (YYTHD->mem_root) Item_func_bit_neg($2);
  1006. + $$= new (thd->mem_root) Item_func_bit_neg($2);
  1007. if ($$ == NULL)
  1008. MYSQL_YYABORT;
  1009. }
  1010. | not2 simple_expr %prec NEG
  1011. {
  1012. - $$= negate_expression(YYTHD, $2);
  1013. + $$= negate_expression(thd, $2);
  1014. if ($$ == NULL)
  1015. MYSQL_YYABORT;
  1016. }
  1017. | '(' subselect ')'
  1018. {
  1019. - $$= new (YYTHD->mem_root) Item_singlerow_subselect($2);
  1020. + $$= new (thd->mem_root) Item_singlerow_subselect($2);
  1021. if ($$ == NULL)
  1022. MYSQL_YYABORT;
  1023. }
  1024. @@ -7352,20 +7328,20 @@ simple_expr:
  1025. | '(' expr ',' expr_list ')'
  1026. {
  1027. $4->push_front($2);
  1028. - $$= new (YYTHD->mem_root) Item_row(*$4);
  1029. + $$= new (thd->mem_root) Item_row(*$4);
  1030. if ($$ == NULL)
  1031. MYSQL_YYABORT;
  1032. }
  1033. | ROW_SYM '(' expr ',' expr_list ')'
  1034. {
  1035. $5->push_front($3);
  1036. - $$= new (YYTHD->mem_root) Item_row(*$5);
  1037. + $$= new (thd->mem_root) Item_row(*$5);
  1038. if ($$ == NULL)
  1039. MYSQL_YYABORT;
  1040. }
  1041. | EXISTS '(' subselect ')'
  1042. {
  1043. - $$= new (YYTHD->mem_root) Item_exists_subselect($3);
  1044. + $$= new (thd->mem_root) Item_exists_subselect($3);
  1045. if ($$ == NULL)
  1046. MYSQL_YYABORT;
  1047. }
  1048. @@ -7374,7 +7350,7 @@ simple_expr:
  1049. | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')'
  1050. {
  1051. $2->push_front($5);
  1052. - Item_func_match *i1= new (YYTHD->mem_root) Item_func_match(*$2, $6);
  1053. + Item_func_match *i1= new (thd->mem_root) Item_func_match(*$2, $6);
  1054. if (i1 == NULL)
  1055. MYSQL_YYABORT;
  1056. Select->add_ftfunc_to_list(i1);
  1057. @@ -7382,7 +7358,7 @@ simple_expr:
  1058. }
  1059. | BINARY simple_expr %prec NEG
  1060. {
  1061. - $$= create_func_cast(YYTHD, $2, ITEM_CAST_CHAR, NULL, NULL,
  1062. + $$= create_func_cast(thd, $2, ITEM_CAST_CHAR, NULL, NULL,
  1063. &my_charset_bin);
  1064. if ($$ == NULL)
  1065. MYSQL_YYABORT;
  1066. @@ -7390,27 +7366,27 @@ simple_expr:
  1067. | CAST_SYM '(' expr AS cast_type ')'
  1068. {
  1069. LEX *lex= Lex;
  1070. - $$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec,
  1071. + $$= create_func_cast(thd, $3, $5, lex->length, lex->dec,
  1072. lex->charset);
  1073. if ($$ == NULL)
  1074. MYSQL_YYABORT;
  1075. }
  1076. | CASE_SYM opt_expr when_list opt_else END
  1077. {
  1078. - $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 );
  1079. + $$= new (thd->mem_root) Item_func_case(* $3, $2, $4 );
  1080. if ($$ == NULL)
  1081. MYSQL_YYABORT;
  1082. }
  1083. | CONVERT_SYM '(' expr ',' cast_type ')'
  1084. {
  1085. - $$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec,
  1086. + $$= create_func_cast(thd, $3, $5, Lex->length, Lex->dec,
  1087. Lex->charset);
  1088. if ($$ == NULL)
  1089. MYSQL_YYABORT;
  1090. }
  1091. | CONVERT_SYM '(' expr USING charset_name ')'
  1092. {
  1093. - $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5);
  1094. + $$= new (thd->mem_root) Item_func_conv_charset($3,$5);
  1095. if ($$ == NULL)
  1096. MYSQL_YYABORT;
  1097. }
  1098. @@ -7423,14 +7399,14 @@ simple_expr:
  1099. my_error(ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str);
  1100. MYSQL_YYABORT;
  1101. }
  1102. - $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(),
  1103. + $$= new (thd->mem_root) Item_default_value(Lex->current_context(),
  1104. $3);
  1105. if ($$ == NULL)
  1106. MYSQL_YYABORT;
  1107. }
  1108. | VALUES '(' simple_ident_nospvar ')'
  1109. {
  1110. - $$= new (YYTHD->mem_root) Item_insert_value(Lex->current_context(),
  1111. + $$= new (thd->mem_root) Item_insert_value(Lex->current_context(),
  1112. $3);
  1113. if ($$ == NULL)
  1114. MYSQL_YYABORT;
  1115. @@ -7438,7 +7414,7 @@ simple_expr:
  1116. | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
  1117. /* we cannot put interval before - */
  1118. {
  1119. - $$= new (YYTHD->mem_root) Item_date_add_interval($5,$2,$3,0);
  1120. + $$= new (thd->mem_root) Item_date_add_interval($5,$2,$3,0);
  1121. if ($$ == NULL)
  1122. MYSQL_YYABORT;
  1123. }
  1124. @@ -7453,19 +7429,19 @@ simple_expr:
  1125. function_call_keyword:
  1126. CHAR_SYM '(' expr_list ')'
  1127. {
  1128. - $$= new (YYTHD->mem_root) Item_func_char(*$3);
  1129. + $$= new (thd->mem_root) Item_func_char(*$3);
  1130. if ($$ == NULL)
  1131. MYSQL_YYABORT;
  1132. }
  1133. | CHAR_SYM '(' expr_list USING charset_name ')'
  1134. {
  1135. - $$= new (YYTHD->mem_root) Item_func_char(*$3, $5);
  1136. + $$= new (thd->mem_root) Item_func_char(*$3, $5);
  1137. if ($$ == NULL)
  1138. MYSQL_YYABORT;
  1139. }
  1140. | CURRENT_USER optional_braces
  1141. {
  1142. - $$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context());
  1143. + $$= new (thd->mem_root) Item_func_current_user(Lex->current_context());
  1144. if ($$ == NULL)
  1145. MYSQL_YYABORT;
  1146. Lex->set_stmt_unsafe();
  1147. @@ -7473,31 +7449,30 @@ function_call_keyword:
  1148. }
  1149. | DATE_SYM '(' expr ')'
  1150. {
  1151. - $$= new (YYTHD->mem_root) Item_date_typecast($3);
  1152. + $$= new (thd->mem_root) Item_date_typecast($3);
  1153. if ($$ == NULL)
  1154. MYSQL_YYABORT;
  1155. }
  1156. | DAY_SYM '(' expr ')'
  1157. {
  1158. - $$= new (YYTHD->mem_root) Item_func_dayofmonth($3);
  1159. + $$= new (thd->mem_root) Item_func_dayofmonth($3);
  1160. if ($$ == NULL)
  1161. MYSQL_YYABORT;
  1162. }
  1163. | HOUR_SYM '(' expr ')'
  1164. {
  1165. - $$= new (YYTHD->mem_root) Item_func_hour($3);
  1166. + $$= new (thd->mem_root) Item_func_hour($3);
  1167. if ($$ == NULL)
  1168. MYSQL_YYABORT;
  1169. }
  1170. | INSERT '(' expr ',' expr ',' expr ',' expr ')'
  1171. {
  1172. - $$= new (YYTHD->mem_root) Item_func_insert($3,$5,$7,$9);
  1173. + $$= new (thd->mem_root) Item_func_insert($3,$5,$7,$9);
  1174. if ($$ == NULL)
  1175. MYSQL_YYABORT;
  1176. }
  1177. | INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
  1178. {
  1179. - THD *thd= YYTHD;
  1180. List<Item> *list= new (thd->mem_root) List<Item>;
  1181. if (list == NULL)
  1182. MYSQL_YYABORT;
  1183. @@ -7512,7 +7487,6 @@ function_call_keyword:
  1184. }
  1185. | INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM
  1186. {
  1187. - THD *thd= YYTHD;
  1188. $7->push_front($5);
  1189. $7->push_front($3);
  1190. Item_row *item= new (thd->mem_root) Item_row(*$7);
  1191. @@ -7524,103 +7498,103 @@ function_call_keyword:
  1192. }
  1193. | LEFT '(' expr ',' expr ')'
  1194. {
  1195. - $$= new (YYTHD->mem_root) Item_func_left($3,$5);
  1196. + $$= new (thd->mem_root) Item_func_left($3,$5);
  1197. if ($$ == NULL)
  1198. MYSQL_YYABORT;
  1199. }
  1200. | MINUTE_SYM '(' expr ')'
  1201. {
  1202. - $$= new (YYTHD->mem_root) Item_func_minute($3);
  1203. + $$= new (thd->mem_root) Item_func_minute($3);
  1204. if ($$ == NULL)
  1205. MYSQL_YYABORT;
  1206. }
  1207. | MONTH_SYM '(' expr ')'
  1208. {
  1209. - $$= new (YYTHD->mem_root) Item_func_month($3);
  1210. + $$= new (thd->mem_root) Item_func_month($3);
  1211. if ($$ == NULL)
  1212. MYSQL_YYABORT;
  1213. }
  1214. | RIGHT '(' expr ',' expr ')'
  1215. {
  1216. - $$= new (YYTHD->mem_root) Item_func_right($3,$5);
  1217. + $$= new (thd->mem_root) Item_func_right($3,$5);
  1218. if ($$ == NULL)
  1219. MYSQL_YYABORT;
  1220. }
  1221. | SECOND_SYM '(' expr ')'
  1222. {
  1223. - $$= new (YYTHD->mem_root) Item_func_second($3);
  1224. + $$= new (thd->mem_root) Item_func_second($3);
  1225. if ($$ == NULL)
  1226. MYSQL_YYABORT;
  1227. }
  1228. | TIME_SYM '(' expr ')'
  1229. {
  1230. - $$= new (YYTHD->mem_root) Item_time_typecast($3);
  1231. + $$= new (thd->mem_root) Item_time_typecast($3);
  1232. if ($$ == NULL)
  1233. MYSQL_YYABORT;
  1234. }
  1235. | TIMESTAMP '(' expr ')'
  1236. {
  1237. - $$= new (YYTHD->mem_root) Item_datetime_typecast($3);
  1238. + $$= new (thd->mem_root) Item_datetime_typecast($3);
  1239. if ($$ == NULL)
  1240. MYSQL_YYABORT;
  1241. }
  1242. | TIMESTAMP '(' expr ',' expr ')'
  1243. {
  1244. - $$= new (YYTHD->mem_root) Item_func_add_time($3, $5, 1, 0);
  1245. + $$= new (thd->mem_root) Item_func_add_time($3, $5, 1, 0);
  1246. if ($$ == NULL)
  1247. MYSQL_YYABORT;
  1248. }
  1249. | TRIM '(' expr ')'
  1250. {
  1251. - $$= new (YYTHD->mem_root) Item_func_trim($3);
  1252. + $$= new (thd->mem_root) Item_func_trim($3);
  1253. if ($$ == NULL)
  1254. MYSQL_YYABORT;
  1255. }
  1256. | TRIM '(' LEADING expr FROM expr ')'
  1257. {
  1258. - $$= new (YYTHD->mem_root) Item_func_ltrim($6,$4);
  1259. + $$= new (thd->mem_root) Item_func_ltrim($6,$4);
  1260. if ($$ == NULL)
  1261. MYSQL_YYABORT;
  1262. }
  1263. | TRIM '(' TRAILING expr FROM expr ')'
  1264. {
  1265. - $$= new (YYTHD->mem_root) Item_func_rtrim($6,$4);
  1266. + $$= new (thd->mem_root) Item_func_rtrim($6,$4);
  1267. if ($$ == NULL)
  1268. MYSQL_YYABORT;
  1269. }
  1270. | TRIM '(' BOTH expr FROM expr ')'
  1271. {
  1272. - $$= new (YYTHD->mem_root) Item_func_trim($6,$4);
  1273. + $$= new (thd->mem_root) Item_func_trim($6,$4);
  1274. if ($$ == NULL)
  1275. MYSQL_YYABORT;
  1276. }
  1277. | TRIM '(' LEADING FROM expr ')'
  1278. {
  1279. - $$= new (YYTHD->mem_root) Item_func_ltrim($5);
  1280. + $$= new (thd->mem_root) Item_func_ltrim($5);
  1281. if ($$ == NULL)
  1282. MYSQL_YYABORT;
  1283. }
  1284. | TRIM '(' TRAILING FROM expr ')'
  1285. {
  1286. - $$= new (YYTHD->mem_root) Item_func_rtrim($5);
  1287. + $$= new (thd->mem_root) Item_func_rtrim($5);
  1288. if ($$ == NULL)
  1289. MYSQL_YYABORT;
  1290. }
  1291. | TRIM '(' BOTH FROM expr ')'
  1292. {
  1293. - $$= new (YYTHD->mem_root) Item_func_trim($5);
  1294. + $$= new (thd->mem_root) Item_func_trim($5);
  1295. if ($$ == NULL)
  1296. MYSQL_YYABORT;
  1297. }
  1298. | TRIM '(' expr FROM expr ')'
  1299. {
  1300. - $$= new (YYTHD->mem_root) Item_func_trim($5,$3);
  1301. + $$= new (thd->mem_root) Item_func_trim($5,$3);
  1302. if ($$ == NULL)
  1303. MYSQL_YYABORT;
  1304. }
  1305. | USER '(' ')'
  1306. {
  1307. - $$= new (YYTHD->mem_root) Item_func_user();
  1308. + $$= new (thd->mem_root) Item_func_user();
  1309. if ($$ == NULL)
  1310. MYSQL_YYABORT;
  1311. Lex->set_stmt_unsafe();
  1312. @@ -7628,7 +7602,7 @@ function_call_keyword:
  1313. }
  1314. | YEAR_SYM '(' expr ')'
  1315. {
  1316. - $$= new (YYTHD->mem_root) Item_func_year($3);
  1317. + $$= new (thd->mem_root) Item_func_year($3);
  1318. if ($$ == NULL)
  1319. MYSQL_YYABORT;
  1320. }
  1321. @@ -7649,34 +7623,34 @@ function_call_keyword:
  1322. function_call_nonkeyword:
  1323. ADDDATE_SYM '(' expr ',' expr ')'
  1324. {
  1325. - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
  1326. + $$= new (thd->mem_root) Item_date_add_interval($3, $5,
  1327. INTERVAL_DAY, 0);
  1328. if ($$ == NULL)
  1329. MYSQL_YYABORT;
  1330. }
  1331. | ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
  1332. {
  1333. - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 0);
  1334. + $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 0);
  1335. if ($$ == NULL)
  1336. MYSQL_YYABORT;
  1337. }
  1338. | CURDATE optional_braces
  1339. {
  1340. - $$= new (YYTHD->mem_root) Item_func_curdate_local();
  1341. + $$= new (thd->mem_root) Item_func_curdate_local();
  1342. if ($$ == NULL)
  1343. MYSQL_YYABORT;
  1344. Lex->safe_to_cache_query=0;
  1345. }
  1346. | CURTIME optional_braces
  1347. {
  1348. - $$= new (YYTHD->mem_root) Item_func_curtime_local();
  1349. + $$= new (thd->mem_root) Item_func_curtime_local();
  1350. if ($$ == NULL)
  1351. MYSQL_YYABORT;
  1352. Lex->safe_to_cache_query=0;
  1353. }
  1354. | CURTIME '(' expr ')'
  1355. {
  1356. - $$= new (YYTHD->mem_root) Item_func_curtime_local($3);
  1357. + $$= new (thd->mem_root) Item_func_curtime_local($3);
  1358. if ($$ == NULL)
  1359. MYSQL_YYABORT;
  1360. Lex->safe_to_cache_query=0;
  1361. @@ -7684,83 +7658,83 @@ function_call_nonkeyword:
  1362. | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
  1363. %prec INTERVAL_SYM
  1364. {
  1365. - $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,0);
  1366. + $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,0);
  1367. if ($$ == NULL)
  1368. MYSQL_YYABORT;
  1369. }
  1370. | DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
  1371. %prec INTERVAL_SYM
  1372. {
  1373. - $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,1);
  1374. + $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,1);
  1375. if ($$ == NULL)
  1376. MYSQL_YYABORT;
  1377. }
  1378. | EXTRACT_SYM '(' interval FROM expr ')'
  1379. {
  1380. - $$=new (YYTHD->mem_root) Item_extract( $3, $5);
  1381. + $$=new (thd->mem_root) Item_extract( $3, $5);
  1382. if ($$ == NULL)
  1383. MYSQL_YYABORT;
  1384. }
  1385. | GET_FORMAT '(' date_time_type ',' expr ')'
  1386. {
  1387. - $$= new (YYTHD->mem_root) Item_func_get_format($3, $5);
  1388. + $$= new (thd->mem_root) Item_func_get_format($3, $5);
  1389. if ($$ == NULL)
  1390. MYSQL_YYABORT;
  1391. }
  1392. | NOW_SYM optional_braces
  1393. {
  1394. - $$= new (YYTHD->mem_root) Item_func_now_local();
  1395. + $$= new (thd->mem_root) Item_func_now_local();
  1396. if ($$ == NULL)
  1397. MYSQL_YYABORT;
  1398. Lex->safe_to_cache_query=0;
  1399. }
  1400. | NOW_SYM '(' expr ')'
  1401. {
  1402. - $$= new (YYTHD->mem_root) Item_func_now_local($3);
  1403. + $$= new (thd->mem_root) Item_func_now_local($3);
  1404. if ($$ == NULL)
  1405. MYSQL_YYABORT;
  1406. Lex->safe_to_cache_query=0;
  1407. }
  1408. | POSITION_SYM '(' bit_expr IN_SYM expr ')'
  1409. {
  1410. - $$ = new (YYTHD->mem_root) Item_func_locate($5,$3);
  1411. + $$ = new (thd->mem_root) Item_func_locate($5,$3);
  1412. if ($$ == NULL)
  1413. MYSQL_YYABORT;
  1414. }
  1415. | SUBDATE_SYM '(' expr ',' expr ')'
  1416. {
  1417. - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
  1418. + $$= new (thd->mem_root) Item_date_add_interval($3, $5,
  1419. INTERVAL_DAY, 1);
  1420. if ($$ == NULL)
  1421. MYSQL_YYABORT;
  1422. }
  1423. | SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
  1424. {
  1425. - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 1);
  1426. + $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 1);
  1427. if ($$ == NULL)
  1428. MYSQL_YYABORT;
  1429. }
  1430. | SUBSTRING '(' expr ',' expr ',' expr ')'
  1431. {
  1432. - $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7);
  1433. + $$= new (thd->mem_root) Item_func_substr($3,$5,$7);
  1434. if ($$ == NULL)
  1435. MYSQL_YYABORT;
  1436. }
  1437. | SUBSTRING '(' expr ',' expr ')'
  1438. {
  1439. - $$= new (YYTHD->mem_root) Item_func_substr($3,$5);
  1440. + $$= new (thd->mem_root) Item_func_substr($3,$5);
  1441. if ($$ == NULL)
  1442. MYSQL_YYABORT;
  1443. }
  1444. | SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
  1445. {
  1446. - $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7);
  1447. + $$= new (thd->mem_root) Item_func_substr($3,$5,$7);
  1448. if ($$ == NULL)
  1449. MYSQL_YYABORT;
  1450. }
  1451. | SUBSTRING '(' expr FROM expr ')'
  1452. {
  1453. - $$= new (YYTHD->mem_root) Item_func_substr($3,$5);
  1454. + $$= new (thd->mem_root) Item_func_substr($3,$5);
  1455. if ($$ == NULL)
  1456. MYSQL_YYABORT;
  1457. }
  1458. @@ -7775,9 +7749,9 @@ function_call_nonkeyword:
  1459. */
  1460. Lex->set_stmt_unsafe();
  1461. if (global_system_variables.sysdate_is_now == 0)
  1462. - $$= new (YYTHD->mem_root) Item_func_sysdate_local();
  1463. + $$= new (thd->mem_root) Item_func_sysdate_local();
  1464. else
  1465. - $$= new (YYTHD->mem_root) Item_func_now_local();
  1466. + $$= new (thd->mem_root) Item_func_now_local();
  1467. if ($$ == NULL)
  1468. MYSQL_YYABORT;
  1469. Lex->safe_to_cache_query=0;
  1470. @@ -7785,42 +7759,42 @@ function_call_nonkeyword:
  1471. | SYSDATE '(' expr ')'
  1472. {
  1473. if (global_system_variables.sysdate_is_now == 0)
  1474. - $$= new (YYTHD->mem_root) Item_func_sysdate_local($3);
  1475. + $$= new (thd->mem_root) Item_func_sysdate_local($3);
  1476. else
  1477. - $$= new (YYTHD->mem_root) Item_func_now_local($3);
  1478. + $$= new (thd->mem_root) Item_func_now_local($3);
  1479. if ($$ == NULL)
  1480. MYSQL_YYABORT;
  1481. Lex->safe_to_cache_query=0;
  1482. }
  1483. | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
  1484. {
  1485. - $$= new (YYTHD->mem_root) Item_date_add_interval($7,$5,$3,0);
  1486. + $$= new (thd->mem_root) Item_date_add_interval($7,$5,$3,0);
  1487. if ($$ == NULL)
  1488. MYSQL_YYABORT;
  1489. }
  1490. | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
  1491. {
  1492. - $$= new (YYTHD->mem_root) Item_func_timestamp_diff($5,$7,$3);
  1493. + $$= new (thd->mem_root) Item_func_timestamp_diff($5,$7,$3);
  1494. if ($$ == NULL)
  1495. MYSQL_YYABORT;
  1496. }
  1497. | UTC_DATE_SYM optional_braces
  1498. {
  1499. - $$= new (YYTHD->mem_root) Item_func_curdate_utc();
  1500. + $$= new (thd->mem_root) Item_func_curdate_utc();
  1501. if ($$ == NULL)
  1502. MYSQL_YYABORT;
  1503. Lex->safe_to_cache_query=0;
  1504. }
  1505. | UTC_TIME_SYM optional_braces
  1506. {
  1507. - $$= new (YYTHD->mem_root) Item_func_curtime_utc();
  1508. + $$= new (thd->mem_root) Item_func_curtime_utc();
  1509. if ($$ == NULL)
  1510. MYSQL_YYABORT;
  1511. Lex->safe_to_cache_query=0;
  1512. }
  1513. | UTC_TIMESTAMP_SYM optional_braces
  1514. {
  1515. - $$= new (YYTHD->mem_root) Item_func_now_utc();
  1516. + $$= new (thd->mem_root) Item_func_now_utc();
  1517. if ($$ == NULL)
  1518. MYSQL_YYABORT;
  1519. Lex->safe_to_cache_query=0;
  1520. @@ -7835,62 +7809,61 @@ function_call_nonkeyword:
  1521. function_call_conflict:
  1522. ASCII_SYM '(' expr ')'
  1523. {
  1524. - $$= new (YYTHD->mem_root) Item_func_ascii($3);
  1525. + $$= new (thd->mem_root) Item_func_ascii($3);
  1526. if ($$ == NULL)
  1527. MYSQL_YYABORT;
  1528. }
  1529. | CHARSET '(' expr ')'
  1530. {
  1531. - $$= new (YYTHD->mem_root) Item_func_charset($3);
  1532. + $$= new (thd->mem_root) Item_func_charset($3);
  1533. if ($$ == NULL)
  1534. MYSQL_YYABORT;
  1535. }
  1536. | COALESCE '(' expr_list ')'
  1537. {
  1538. - $$= new (YYTHD->mem_root) Item_func_coalesce(* $3);
  1539. + $$= new (thd->mem_root) Item_func_coalesce(* $3);
  1540. if ($$ == NULL)
  1541. MYSQL_YYABORT;
  1542. }
  1543. | COLLATION_SYM '(' expr ')'
  1544. {
  1545. - $$= new (YYTHD->mem_root) Item_func_collation($3);
  1546. + $$= new (thd->mem_root) Item_func_collation($3);
  1547. if ($$ == NULL)
  1548. MYSQL_YYABORT;
  1549. }
  1550. | DATABASE '(' ')'
  1551. {
  1552. - $$= new (YYTHD->mem_root) Item_func_database();
  1553. + $$= new (thd->mem_root) Item_func_database();
  1554. if ($$ == NULL)
  1555. MYSQL_YYABORT;
  1556. Lex->safe_to_cache_query=0;
  1557. }
  1558. | IF '(' expr ',' expr ',' expr ')'
  1559. {
  1560. - $$= new (YYTHD->mem_root) Item_func_if($3,$5,$7);
  1561. + $$= new (thd->mem_root) Item_func_if($3,$5,$7);
  1562. if ($$ == NULL)
  1563. MYSQL_YYABORT;
  1564. }
  1565. | MICROSECOND_SYM '(' expr ')'
  1566. {
  1567. - $$= new (YYTHD->mem_root) Item_func_microsecond($3);
  1568. + $$= new (thd->mem_root) Item_func_microsecond($3);
  1569. if ($$ == NULL)
  1570. MYSQL_YYABORT;
  1571. }
  1572. | MOD_SYM '(' expr ',' expr ')'
  1573. {
  1574. - $$ = new (YYTHD->mem_root) Item_func_mod($3, $5);
  1575. + $$ = new (thd->mem_root) Item_func_mod($3, $5);
  1576. if ($$ == NULL)
  1577. MYSQL_YYABORT;
  1578. }
  1579. | OLD_PASSWORD '(' expr ')'
  1580. {
  1581. - $$= new (YYTHD->mem_root) Item_func_old_password($3);
  1582. + $$= new (thd->mem_root) Item_func_old_password($3);
  1583. if ($$ == NULL)
  1584. MYSQL_YYABORT;
  1585. }
  1586. | PASSWORD '(' expr ')'
  1587. {
  1588. - THD *thd= YYTHD;
  1589. Item* i1;
  1590. if (thd->variables.old_passwords)
  1591. i1= new (thd->mem_root) Item_func_old_password($3);
  1592. @@ -7902,31 +7875,30 @@ function_call_conflict:
  1593. }
  1594. | QUARTER_SYM '(' expr ')'
  1595. {
  1596. - $$ = new (YYTHD->mem_root) Item_func_quarter($3);
  1597. + $$ = new (thd->mem_root) Item_func_quarter($3);
  1598. if ($$ == NULL)
  1599. MYSQL_YYABORT;
  1600. }
  1601. | REPEAT_SYM '(' expr ',' expr ')'
  1602. {
  1603. - $$= new (YYTHD->mem_root) Item_func_repeat($3,$5);
  1604. + $$= new (thd->mem_root) Item_func_repeat($3,$5);
  1605. if ($$ == NULL)
  1606. MYSQL_YYABORT;
  1607. }
  1608. | REPLACE '(' expr ',' expr ',' expr ')'
  1609. {
  1610. - $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7);
  1611. + $$= new (thd->mem_root) Item_func_replace($3,$5,$7);
  1612. if ($$ == NULL)
  1613. MYSQL_YYABORT;
  1614. }
  1615. | TRUNCATE_SYM '(' expr ',' expr ')'
  1616. {
  1617. - $$= new (YYTHD->mem_root) Item_func_round($3,$5,1);
  1618. + $$= new (thd->mem_root) Item_func_round($3,$5,1);
  1619. if ($$ == NULL)
  1620. MYSQL_YYABORT;
  1621. }
  1622. | WEEK_SYM '(' expr ')'
  1623. {
  1624. - THD *thd= YYTHD;
  1625. Item *i1= new (thd->mem_root) Item_int((char*) "0",
  1626. thd->variables.default_week_format,
  1627. 1);
  1628. @@ -7938,7 +7910,7 @@ function_call_conflict:
  1629. }
  1630. | WEEK_SYM '(' expr ',' expr ')'
  1631. {
  1632. - $$= new (YYTHD->mem_root) Item_func_week($3,$5);
  1633. + $$= new (thd->mem_root) Item_func_week($3,$5);
  1634. if ($$ == NULL)
  1635. MYSQL_YYABORT;
  1636. }
  1637. @@ -7960,52 +7932,52 @@ function_call_conflict:
  1638. geometry_function:
  1639. CONTAINS_SYM '(' expr ',' expr ')'
  1640. {
  1641. - $$= GEOM_NEW(YYTHD,
  1642. + $$= GEOM_NEW(thd,
  1643. Item_func_spatial_rel($3, $5,
  1644. Item_func::SP_CONTAINS_FUNC));
  1645. }
  1646. | GEOMETRYCOLLECTION '(' expr_list ')'
  1647. {
  1648. - $$= GEOM_NEW(YYTHD,
  1649. + $$= GEOM_NEW(thd,
  1650. Item_func_spatial_collection(* $3,
  1651. Geometry::wkb_geometrycollection,
  1652. Geometry::wkb_point));
  1653. }
  1654. | LINESTRING '(' expr_list ')'
  1655. {
  1656. - $$= GEOM_NEW(YYTHD,
  1657. + $$= GEOM_NEW(thd,
  1658. Item_func_spatial_collection(* $3,
  1659. Geometry::wkb_linestring,
  1660. Geometry::wkb_point));
  1661. }
  1662. | MULTILINESTRING '(' expr_list ')'
  1663. {
  1664. - $$= GEOM_NEW(YYTHD,
  1665. + $$= GEOM_NEW(thd,
  1666. Item_func_spatial_collection(* $3,
  1667. Geometry::wkb_multilinestring,
  1668. Geometry::wkb_linestring));
  1669. }
  1670. | MULTIPOINT '(' expr_list ')'
  1671. {
  1672. - $$= GEOM_NEW(YYTHD,
  1673. + $$= GEOM_NEW(thd,
  1674. Item_func_spatial_collection(* $3,
  1675. Geometry::wkb_multipoint,
  1676. Geometry::wkb_point));
  1677. }
  1678. | MULTIPOLYGON '(' expr_list ')'
  1679. {
  1680. - $$= GEOM_NEW(YYTHD,
  1681. + $$= GEOM_NEW(thd,
  1682. Item_func_spatial_collection(* $3,
  1683. Geometry::wkb_multipolygon,
  1684. Geometry::wkb_polygon));
  1685. }
  1686. | POINT_SYM '(' expr ',' expr ')'
  1687. {
  1688. - $$= GEOM_NEW(YYTHD, Item_func_point($3,$5));
  1689. + $$= GEOM_NEW(thd, Item_func_point($3,$5));
  1690. }
  1691. | POLYGON '(' expr_list ')'
  1692. {
  1693. - $$= GEOM_NEW(YYTHD,
  1694. + $$= GEOM_NEW(thd,
  1695. Item_func_spatial_collection(* $3,
  1696. Geometry::wkb_polygon,
  1697. Geometry::wkb_linestring));
  1698. @@ -8043,7 +8015,6 @@ function_call_generic:
  1699. }
  1700. opt_udf_expr_list ')'
  1701. {
  1702. - THD *thd= YYTHD;
  1703. Create_func *builder;
  1704. Item *item= NULL;
  1705. @@ -8097,7 +8068,6 @@ function_call_generic:
  1706. }
  1707. | ident '.' ident '(' opt_expr_list ')'
  1708. {
  1709. - THD *thd= YYTHD;
  1710. Create_qfunc *builder;
  1711. Item *item= NULL;
  1712. @@ -8161,7 +8131,7 @@ opt_udf_expr_list:
  1713. udf_expr_list:
  1714. udf_expr
  1715. {
  1716. - $$= new (YYTHD->mem_root) List<Item>;
  1717. + $$= new (thd->mem_root) List<Item>;
  1718. if ($$ == NULL)
  1719. MYSQL_YYABORT;
  1720. $$->push_back($1);
  1721. @@ -8194,7 +8164,7 @@ udf_expr:
  1722. remember_name we may get quoted or escaped names.
  1723. */
  1724. else if ($2->type() != Item::FIELD_ITEM)
  1725. - $2->set_name($1, (uint) ($3 - $1), YYTHD->charset());
  1726. + $2->set_name($1, (uint) ($3 - $1), thd->charset());
  1727. $$= $2;
  1728. }
  1729. ;
  1730. @@ -8202,46 +8172,46 @@ udf_expr:
  1731. sum_expr:
  1732. AVG_SYM '(' in_sum_expr ')'
  1733. {
  1734. - $$= new (YYTHD->mem_root) Item_sum_avg($3);
  1735. + $$= new (thd->mem_root) Item_sum_avg($3);
  1736. if ($$ == NULL)
  1737. MYSQL_YYABORT;
  1738. }
  1739. | AVG_SYM '(' DISTINCT in_sum_expr ')'
  1740. {
  1741. - $$= new (YYTHD->mem_root) Item_sum_avg_distinct($4);
  1742. + $$= new (thd->mem_root) Item_sum_avg_distinct($4);
  1743. if ($$ == NULL)
  1744. MYSQL_YYABORT;
  1745. }
  1746. | BIT_AND '(' in_sum_expr ')'
  1747. {
  1748. - $$= new (YYTHD->mem_root) Item_sum_and($3);
  1749. + $$= new (thd->mem_root) Item_sum_and($3);
  1750. if ($$ == NULL)
  1751. MYSQL_YYABORT;
  1752. }
  1753. | BIT_OR '(' in_sum_expr ')'
  1754. {
  1755. - $$= new (YYTHD->mem_root) Item_sum_or($3);
  1756. + $$= new (thd->mem_root) Item_sum_or($3);
  1757. if ($$ == NULL)
  1758. MYSQL_YYABORT;
  1759. }
  1760. | BIT_XOR '(' in_sum_expr ')'
  1761. {
  1762. - $$= new (YYTHD->mem_root) Item_sum_xor($3);
  1763. + $$= new (thd->mem_root) Item_sum_xor($3);
  1764. if ($$ == NULL)
  1765. MYSQL_YYABORT;
  1766. }
  1767. | COUNT_SYM '(' opt_all '*' ')'
  1768. {
  1769. - Item *item= new (YYTHD->mem_root) Item_int((int32) 0L,1);
  1770. + Item *item= new (thd->mem_root) Item_int((int32) 0L,1);
  1771. if (item == NULL)
  1772. MYSQL_YYABORT;
  1773. - $$= new (YYTHD->mem_root) Item_sum_count(item);
  1774. + $$= new (thd->mem_root) Item_sum_count(item);
  1775. if ($$ == NULL)
  1776. MYSQL_YYABORT;
  1777. }
  1778. | COUNT_SYM '(' in_sum_expr ')'
  1779. {
  1780. - $$= new (YYTHD->mem_root) Item_sum_count($3);
  1781. + $$= new (thd->mem_root) Item_sum_count($3);
  1782. if ($$ == NULL)
  1783. MYSQL_YYABORT;
  1784. }
  1785. @@ -8251,13 +8221,13 @@ sum_expr:
  1786. { Select->in_sum_expr--; }
  1787. ')'
  1788. {
  1789. - $$= new (YYTHD->mem_root) Item_sum_count_distinct(* $5);
  1790. + $$= new (thd->mem_root) Item_sum_count_distinct(* $5);
  1791. if ($$ == NULL)
  1792. MYSQL_YYABORT;
  1793. }
  1794. | MIN_SYM '(' in_sum_expr ')'
  1795. {
  1796. - $$= new (YYTHD->mem_root) Item_sum_min($3);
  1797. + $$= new (thd->mem_root) Item_sum_min($3);
  1798. if ($$ == NULL)
  1799. MYSQL_YYABORT;
  1800. }
  1801. @@ -8268,55 +8238,55 @@ sum_expr:
  1802. */
  1803. | MIN_SYM '(' DISTINCT in_sum_expr ')'
  1804. {
  1805. - $$= new (YYTHD->mem_root) Item_sum_min($4);
  1806. + $$= new (thd->mem_root) Item_sum_min($4);
  1807. if ($$ == NULL)
  1808. MYSQL_YYABORT;
  1809. }
  1810. | MAX_SYM '(' in_sum_expr ')'
  1811. {
  1812. - $$= new (YYTHD->mem_root) Item_sum_max($3);
  1813. + $$= new (thd->mem_root) Item_sum_max($3);
  1814. if ($$ == NULL)
  1815. MYSQL_YYABORT;
  1816. }
  1817. | MAX_SYM '(' DISTINCT in_sum_expr ')'
  1818. {
  1819. - $$= new (YYTHD->mem_root) Item_sum_max($4);
  1820. + $$= new (thd->mem_root) Item_sum_max($4);
  1821. if ($$ == NULL)
  1822. MYSQL_YYABORT;
  1823. }
  1824. | STD_SYM '(' in_sum_expr ')'
  1825. {
  1826. - $$= new (YYTHD->mem_root) Item_sum_std($3, 0);
  1827. + $$= new (thd->mem_root) Item_sum_std($3, 0);
  1828. if ($$ == NULL)
  1829. MYSQL_YYABORT;
  1830. }
  1831. | VARIANCE_SYM '(' in_sum_expr ')'
  1832. {
  1833. - $$= new (YYTHD->mem_root) Item_sum_variance($3, 0);
  1834. + $$= new (thd->mem_root) Item_sum_variance($3, 0);
  1835. if ($$ == NULL)
  1836. MYSQL_YYABORT;
  1837. }
  1838. | STDDEV_SAMP_SYM '(' in_sum_expr ')'
  1839. {
  1840. - $$= new (YYTHD->mem_root) Item_sum_std($3, 1);
  1841. + $$= new (thd->mem_root) Item_sum_std($3, 1);
  1842. if ($$ == NULL)
  1843. MYSQL_YYABORT;
  1844. }
  1845. | VAR_SAMP_SYM '(' in_sum_expr ')'
  1846. {
  1847. - $$= new (YYTHD->mem_root) Item_sum_variance($3, 1);
  1848. + $$= new (thd->mem_root) Item_sum_variance($3, 1);
  1849. if ($$ == NULL)
  1850. MYSQL_YYABORT;
  1851. }
  1852. | SUM_SYM '(' in_sum_expr ')'
  1853. {
  1854. - $$= new (YYTHD->mem_root) Item_sum_sum($3);
  1855. + $$= new (thd->mem_root) Item_sum_sum($3);
  1856. if ($$ == NULL)
  1857. MYSQL_YYABORT;
  1858. }
  1859. | SUM_SYM '(' DISTINCT in_sum_expr ')'
  1860. {
  1861. - $$= new (YYTHD->mem_root) Item_sum_sum_distinct($4);
  1862. + $$= new (thd->mem_root) Item_sum_sum_distinct($4);
  1863. if ($$ == NULL)
  1864. MYSQL_YYABORT;
  1865. }
  1866. @@ -8328,7 +8298,7 @@ sum_expr:
  1867. {
  1868. SELECT_LEX *sel= Select;
  1869. sel->in_sum_expr--;
  1870. - $$= new (YYTHD->mem_root)
  1871. + $$= new (thd->mem_root)
  1872. Item_func_group_concat(Lex->current_context(), $3, $5,
  1873. sel->gorder_list, $7);
  1874. if ($$ == NULL)
  1875. @@ -8357,7 +8327,7 @@ variable_aux:
  1876. ident_or_text SET_VAR expr
  1877. {
  1878. Item_func_set_user_var *item;
  1879. - $$= item= new (YYTHD->mem_root) Item_func_set_user_var($1, $3);
  1880. + $$= item= new (thd->mem_root) Item_func_set_user_var($1, $3);
  1881. if ($$ == NULL)
  1882. MYSQL_YYABORT;
  1883. LEX *lex= Lex;
  1884. @@ -8366,7 +8336,7 @@ variable_aux:
  1885. }
  1886. | ident_or_text
  1887. {
  1888. - $$= new (YYTHD->mem_root) Item_func_get_user_var($1);
  1889. + $$= new (thd->mem_root) Item_func_get_user_var($1);
  1890. if ($$ == NULL)
  1891. MYSQL_YYABORT;
  1892. LEX *lex= Lex;
  1893. @@ -8380,7 +8350,7 @@ variable_aux:
  1894. my_parse_error(ER(ER_SYNTAX_ERROR));
  1895. MYSQL_YYABORT;
  1896. }
  1897. - if (!($$= get_system_var(YYTHD, $2, $3, $4)))
  1898. + if (!($$= get_system_var(thd, $2, $3, $4)))
  1899. MYSQL_YYABORT;
  1900. if (!((Item_func_get_system_var*) $$)->is_written_to_binlog())
  1901. Lex->set_stmt_unsafe();
  1902. @@ -8395,7 +8365,7 @@ opt_distinct:
  1903. opt_gconcat_separator:
  1904. /* empty */
  1905. {
  1906. - $$= new (YYTHD->mem_root) String(",", 1, &my_charset_latin1);
  1907. + $$= new (thd->mem_root) String(",", 1, &my_charset_latin1);
  1908. if ($$ == NULL)
  1909. MYSQL_YYABORT;
  1910. }
  1911. @@ -8422,9 +8392,9 @@ opt_gorder_clause:
  1912. gorder_list:
  1913. gorder_list ',' order_ident order_dir
  1914. - { if (add_gorder_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
  1915. + { if (add_gorder_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; }
  1916. | order_ident order_dir
  1917. - { if (add_gorder_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
  1918. + { if (add_gorder_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; }
  1919. ;
  1920. in_sum_expr:
  1921. @@ -8477,7 +8447,7 @@ opt_expr_list:
  1922. expr_list:
  1923. expr
  1924. {
  1925. - $$= new (YYTHD->mem_root) List<Item>;
  1926. + $$= new (thd->mem_root) List<Item>;
  1927. if ($$ == NULL)
  1928. MYSQL_YYABORT;
  1929. $$->push_back($1);
  1930. @@ -8497,7 +8467,7 @@ ident_list_arg:
  1931. ident_list:
  1932. simple_ident
  1933. {
  1934. - $$= new (YYTHD->mem_root) List<Item>;
  1935. + $$= new (thd->mem_root) List<Item>;
  1936. if ($$ == NULL)
  1937. MYSQL_YYABORT;
  1938. $$->push_back($1);
  1939. @@ -8595,7 +8565,7 @@ join_table:
  1940. {
  1941. MYSQL_YYABORT_UNLESS($1 && $3);
  1942. /* Change the current name resolution context to a local context. */
  1943. - if (push_new_name_resolution_context(YYTHD, $1, $3))
  1944. + if (push_new_name_resolution_context(thd, $1, $3))
  1945. MYSQL_YYABORT;
  1946. Select->parsing_place= IN_ON;
  1947. }
  1948. @@ -8610,7 +8580,7 @@ join_table:
  1949. {
  1950. MYSQL_YYABORT_UNLESS($1 && $3);
  1951. /* Change the current name resolution context to a local context. */
  1952. - if (push_new_name_resolution_context(YYTHD, $1, $3))
  1953. + if (push_new_name_resolution_context(thd, $1, $3))
  1954. MYSQL_YYABORT;
  1955. Select->parsing_place= IN_ON;
  1956. }
  1957. @@ -8640,7 +8610,7 @@ join_table:
  1958. {
  1959. MYSQL_YYABORT_UNLESS($1 && $5);
  1960. /* Change the current name resolution context to a local context. */
  1961. - if (push_new_name_resolution_context(YYTHD, $1, $5))
  1962. + if (push_new_name_resolution_context(thd, $1, $5))
  1963. MYSQL_YYABORT;
  1964. Select->parsing_place= IN_ON;
  1965. }
  1966. @@ -8676,7 +8646,7 @@ join_table:
  1967. {
  1968. MYSQL_YYABORT_UNLESS($1 && $5);
  1969. /* Change the current name resolution context to a local context. */
  1970. - if (push_new_name_resolution_context(YYTHD, $1, $5))
  1971. + if (push_new_name_resolution_context(thd, $1, $5))
  1972. MYSQL_YYABORT;
  1973. Select->parsing_place= IN_ON;
  1974. }
  1975. @@ -8724,7 +8694,7 @@ table_factor:
  1976. }
  1977. table_ident opt_table_alias opt_key_definition
  1978. {
  1979. - if (!($$= Select->add_table_to_list(YYTHD, $2, $3,
  1980. + if (!($$= Select->add_table_to_list(thd, $2, $3,
  1981. Select->get_table_join_options(),
  1982. Lex->lock_option,
  1983. Select->pop_index_hints())))
  1984. @@ -8922,7 +8892,7 @@ index_hints_list:
  1985. opt_index_hints_list:
  1986. /* empty */
  1987. - | { Select->alloc_index_hints(YYTHD); } index_hints_list
  1988. + | { Select->alloc_index_hints(thd); } index_hints_list
  1989. ;
  1990. opt_key_definition:
  1991. @@ -8931,15 +8901,15 @@ opt_key_definition:
  1992. ;
  1993. opt_key_usage_list:
  1994. - /* empty */ { Select->add_index_hint(YYTHD, NULL, 0); }
  1995. + /* empty */ { Select->add_index_hint(thd, NULL, 0); }
  1996. | key_usage_list {}
  1997. ;
  1998. key_usage_element:
  1999. ident
  2000. - { Select->add_index_hint(YYTHD, $1.str, $1.length); }
  2001. + { Select->add_index_hint(thd, $1.str, $1.length); }
  2002. | PRIMARY_SYM
  2003. - { Select->add_index_hint(YYTHD, (char *)"PRIMARY", 7); }
  2004. + { Select->add_index_hint(thd, (char *)"PRIMARY", 7); }
  2005. ;
  2006. key_usage_list:
  2007. @@ -8952,7 +8922,7 @@ using_list:
  2008. {
  2009. if (!($$= new List<String>))
  2010. MYSQL_YYABORT;
  2011. - String *s= new (YYTHD->mem_root) String((const char *) $1.str,
  2012. + String *s= new (thd->mem_root) String((const char *) $1.str,
  2013. $1.length,
  2014. system_charset_info);
  2015. if (s == NULL)
  2016. @@ -8961,7 +8931,7 @@ using_list:
  2017. }
  2018. | using_list ',' ident
  2019. {
  2020. - String *s= new (YYTHD->mem_root) String((const char *) $3.str,
  2021. + String *s= new (thd->mem_root) String((const char *) $3.str,
  2022. $3.length,
  2023. system_charset_info);
  2024. if (s == NULL)
  2025. @@ -9002,7 +8972,7 @@ interval_time_stamp:
  2026. implementation without changing its
  2027. resolution.
  2028. */
  2029. - WARN_DEPRECATED(yythd, VER_CELOSIA, "FRAC_SECOND", "MICROSECOND");
  2030. + WARN_DEPRECATED(thd, VER_CELOSIA, "FRAC_SECOND", "MICROSECOND");
  2031. }
  2032. ;
  2033. @@ -9086,7 +9056,6 @@ opt_escape:
  2034. }
  2035. | /* empty */
  2036. {
  2037. - THD *thd= YYTHD;
  2038. Lex->escape_used= FALSE;
  2039. $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ?
  2040. new (thd->mem_root) Item_string("", 0, &my_charset_latin1) :
  2041. @@ -9107,9 +9076,9 @@ group_clause:
  2042. group_list:
  2043. group_list ',' order_ident order_dir
  2044. - { if (add_group_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
  2045. + { if (add_group_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; }
  2046. | order_ident order_dir
  2047. - { if (add_group_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
  2048. + { if (add_group_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; }
  2049. ;
  2050. olap_opt:
  2051. @@ -9156,7 +9125,6 @@ alter_order_list:
  2052. alter_order_item:
  2053. simple_ident_nospvar order_dir
  2054. {
  2055. - THD *thd= YYTHD;
  2056. bool ascending= ($2 == 1) ? true : false;
  2057. if (add_order_to_list(thd, $1, ascending))
  2058. MYSQL_YYABORT;
  2059. @@ -9209,9 +9177,9 @@ order_clause:
  2060. order_list:
  2061. order_list ',' order_ident order_dir
  2062. - { if (add_order_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
  2063. + { if (add_order_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; }
  2064. | order_ident order_dir
  2065. - { if (add_order_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
  2066. + { if (add_order_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; }
  2067. ;
  2068. order_dir:
  2069. @@ -9271,19 +9239,19 @@ limit_option:
  2070. }
  2071. | ULONGLONG_NUM
  2072. {
  2073. - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length);
  2074. + $$= new (thd->mem_root) Item_uint($1.str, $1.length);
  2075. if ($$ == NULL)
  2076. MYSQL_YYABORT;
  2077. }
  2078. | LONG_NUM
  2079. {
  2080. - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length);
  2081. + $$= new (thd->mem_root) Item_uint($1.str, $1.length);
  2082. if ($$ == NULL)
  2083. MYSQL_YYABORT;
  2084. }
  2085. | NUM
  2086. {
  2087. - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length);
  2088. + $$= new (thd->mem_root) Item_uint($1.str, $1.length);
  2089. if ($$ == NULL)
  2090. MYSQL_YYABORT;
  2091. }
  2092. @@ -9365,7 +9333,7 @@ procedure_clause:
  2093. lex->proc_list.elements=0;
  2094. lex->proc_list.first=0;
  2095. lex->proc_list.next= &lex->proc_list.first;
  2096. - Item_field *item= new (YYTHD->mem_root)
  2097. + Item_field *item= new (thd->mem_root)
  2098. Item_field(&lex->current_select->context,
  2099. NULL, NULL, $2.str);
  2100. if (item == NULL)
  2101. @@ -9390,8 +9358,6 @@ procedure_list2:
  2102. procedure_item:
  2103. remember_name expr remember_end
  2104. {
  2105. - THD *thd= YYTHD;
  2106. -
  2107. if (add_proc_to_list(thd, $2))
  2108. MYSQL_YYABORT;
  2109. if (!$2->name)
  2110. @@ -9560,7 +9526,6 @@ drop:
  2111. }
  2112. | DROP FUNCTION_SYM if_exists ident '.' ident
  2113. {
  2114. - THD *thd= YYTHD;
  2115. LEX *lex= thd->lex;
  2116. sp_name *spname;
  2117. if ($4.str && check_db_name(&$4))
  2118. @@ -9583,7 +9548,6 @@ drop:
  2119. }
  2120. | DROP FUNCTION_SYM if_exists ident
  2121. {
  2122. - THD *thd= YYTHD;
  2123. LEX *lex= thd->lex;
  2124. LEX_STRING db= {0, 0};
  2125. sp_name *spname;
  2126. @@ -9664,7 +9628,7 @@ table_list:
  2127. table_name:
  2128. table_ident
  2129. {
  2130. - if (!Select->add_table_to_list(YYTHD, $1, NULL, TL_OPTION_UPDATING))
  2131. + if (!Select->add_table_to_list(thd, $1, NULL, TL_OPTION_UPDATING))
  2132. MYSQL_YYABORT;
  2133. }
  2134. ;
  2135. @@ -9677,7 +9641,7 @@ table_alias_ref_list:
  2136. table_alias_ref:
  2137. table_ident_opt_wild
  2138. {
  2139. - if (!Select->add_table_to_list(YYTHD, $1, NULL,
  2140. + if (!Select->add_table_to_list(thd, $1, NULL,
  2141. TL_OPTION_UPDATING | TL_OPTION_ALIAS,
  2142. Lex->lock_option ))
  2143. MYSQL_YYABORT;
  2144. @@ -9868,7 +9832,7 @@ expr_or_default:
  2145. expr { $$= $1;}
  2146. | DEFAULT
  2147. {
  2148. - $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context());
  2149. + $$= new (thd->mem_root) Item_default_value(Lex->current_context());
  2150. if ($$ == NULL)
  2151. MYSQL_YYABORT;
  2152. }
  2153. @@ -9922,7 +9886,7 @@ update_list:
  2154. update_elem:
  2155. simple_ident_nospvar equal expr_or_default
  2156. {
  2157. - if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
  2158. + if (add_item_to_list(thd, $1) || add_value_to_list(thd, $3))
  2159. MYSQL_YYABORT;
  2160. }
  2161. ;
  2162. @@ -9965,7 +9929,7 @@ delete:
  2163. single_multi:
  2164. FROM table_ident
  2165. {
  2166. - if (!Select->add_table_to_list(YYTHD, $2, NULL, TL_OPTION_UPDATING,
  2167. + if (!Select->add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING,
  2168. Lex->lock_option))
  2169. MYSQL_YYABORT;
  2170. }
  2171. @@ -9998,7 +9962,7 @@ table_wild_one:
  2172. Table_ident *ti= new Table_ident($1);
  2173. if (ti == NULL)
  2174. MYSQL_YYABORT;
  2175. - if (!Select->add_table_to_list(YYTHD,
  2176. + if (!Select->add_table_to_list(thd,
  2177. ti,
  2178. $3,
  2179. TL_OPTION_UPDATING | TL_OPTION_ALIAS,
  2180. @@ -10007,10 +9971,10 @@ table_wild_one:
  2181. }
  2182. | ident '.' ident opt_wild opt_table_alias
  2183. {
  2184. - Table_ident *ti= new Table_ident(YYTHD, $1, $3, 0);
  2185. + Table_ident *ti= new Table_ident(thd, $1, $3, 0);
  2186. if (ti == NULL)
  2187. MYSQL_YYABORT;
  2188. - if (!Select->add_table_to_list(YYTHD,
  2189. + if (!Select->add_table_to_list(thd,
  2190. ti,
  2191. $5,
  2192. TL_OPTION_UPDATING | TL_OPTION_ALIAS,
  2193. @@ -10130,7 +10094,7 @@ show_param:
  2194. {
  2195. LEX *lex= Lex;
  2196. lex->sql_command= SQLCOM_SHOW_DATABASES;
  2197. - if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
  2198. + if (prepare_schema_table(thd, lex, 0, SCH_SCHEMATA))
  2199. MYSQL_YYABORT;
  2200. }
  2201. | opt_full TABLES opt_db wild_and_where
  2202. @@ -10138,7 +10102,7 @@ show_param:
  2203. LEX *lex= Lex;
  2204. lex->sql_command= SQLCOM_SHOW_TABLES;
  2205. lex->select_lex.db= $3;
  2206. - if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
  2207. + if (prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES))
  2208. MYSQL_YYABORT;
  2209. }
  2210. | opt_full TRIGGERS_SYM opt_db wild_and_where
  2211. @@ -10146,7 +10110,7 @@ show_param:
  2212. LEX *lex= Lex;
  2213. lex->sql_command= SQLCOM_SHOW_TRIGGERS;
  2214. lex->select_lex.db= $3;
  2215. - if (prepare_schema_table(YYTHD, lex, 0, SCH_TRIGGERS))
  2216. + if (prepare_schema_table(thd, lex, 0, SCH_TRIGGERS))
  2217. MYSQL_YYABORT;
  2218. }
  2219. | EVENTS_SYM opt_db wild_and_where
  2220. @@ -10154,7 +10118,7 @@ show_param:
  2221. LEX *lex= Lex;
  2222. lex->sql_command= SQLCOM_SHOW_EVENTS;
  2223. lex->select_lex.db= $2;
  2224. - if (prepare_schema_table(YYTHD, lex, 0, SCH_EVENTS))
  2225. + if (prepare_schema_table(thd, lex, 0, SCH_EVENTS))
  2226. MYSQL_YYABORT;
  2227. }
  2228. | TABLE_SYM STATUS_SYM opt_db wild_and_where
  2229. @@ -10162,7 +10126,7 @@ show_param:
  2230. LEX *lex= Lex;
  2231. lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
  2232. lex->select_lex.db= $3;
  2233. - if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
  2234. + if (prepare_schema_table(thd, lex, 0, SCH_TABLES))
  2235. MYSQL_YYABORT;
  2236. }
  2237. | OPEN_SYM TABLES opt_db wild_and_where
  2238. @@ -10170,22 +10134,22 @@ show_param:
  2239. LEX *lex= Lex;
  2240. lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
  2241. lex->select_lex.db= $3;
  2242. - if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
  2243. + if (prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES))
  2244. MYSQL_YYABORT;
  2245. }
  2246. | opt_full PLUGIN_SYM
  2247. {
  2248. LEX *lex= Lex;
  2249. - WARN_DEPRECATED(yythd, "6.0", "SHOW PLUGIN", "'SHOW PLUGINS'");
  2250. + WARN_DEPRECATED(thd, "6.0", "SHOW PLUGIN", "'SHOW PLUGINS'");
  2251. lex->sql_command= SQLCOM_SHOW_PLUGINS;
  2252. - if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
  2253. + if (prepare_schema_table(thd, lex, 0, SCH_PLUGINS))
  2254. MYSQL_YYABORT;
  2255. }
  2256. | PLUGINS_SYM
  2257. {
  2258. LEX *lex= Lex;
  2259. lex->sql_command= SQLCOM_SHOW_PLUGINS;
  2260. - if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
  2261. + if (prepare_schema_table(thd, lex, 0, SCH_PLUGINS))
  2262. MYSQL_YYABORT;
  2263. }
  2264. | ENGINE_SYM known_storage_engines show_engine_param
  2265. @@ -10198,7 +10162,7 @@ show_param:
  2266. lex->sql_command= SQLCOM_SHOW_FIELDS;
  2267. if ($5)
  2268. $4->change_db($5);
  2269. - if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
  2270. + if (prepare_schema_table(thd, lex, $4, SCH_COLUMNS))
  2271. MYSQL_YYABORT;
  2272. }
  2273. | NEW_SYM MASTER_SYM FOR_SYM SLAVE
  2274. @@ -10233,7 +10197,7 @@ show_param:
  2275. lex->sql_command= SQLCOM_SHOW_KEYS;
  2276. if ($4)
  2277. $3->change_db($4);
  2278. - if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
  2279. + if (prepare_schema_table(thd, lex, $3, SCH_STATISTICS))
  2280. MYSQL_YYABORT;
  2281. }
  2282. | COLUMN_SYM TYPES_SYM
  2283. @@ -10245,15 +10209,15 @@ show_param:
  2284. {
  2285. LEX *lex=Lex;
  2286. lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
  2287. - WARN_DEPRECATED(yythd, "6.0", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
  2288. - if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES))
  2289. + WARN_DEPRECATED(thd, "6.0", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
  2290. + if (prepare_schema_table(thd, lex, 0, SCH_ENGINES))
  2291. MYSQL_YYABORT;
  2292. }
  2293. | opt_storage ENGINES_SYM
  2294. {
  2295. LEX *lex=Lex;
  2296. lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
  2297. - if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES))
  2298. + if (prepare_schema_table(thd, lex, 0, SCH_ENGINES))
  2299. MYSQL_YYABORT;
  2300. }
  2301. | AUTHORS_SYM
  2302. @@ -10285,7 +10249,7 @@ show_param:
  2303. {
  2304. LEX *lex= Lex;
  2305. lex->sql_command= SQLCOM_SHOW_PROFILE;
  2306. - if (prepare_schema_table(YYTHD, lex, NULL, SCH_PROFILES) != 0)
  2307. + if (prepare_schema_table(thd, lex, NULL, SCH_PROFILES) != 0)
  2308. YYABORT;
  2309. }
  2310. | opt_var_type STATUS_SYM wild_and_where
  2311. @@ -10293,7 +10257,7 @@ show_param:
  2312. LEX *lex= Lex;
  2313. lex->sql_command= SQLCOM_SHOW_STATUS;
  2314. lex->option_type= $1;
  2315. - if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
  2316. + if (prepare_schema_table(thd, lex, 0, SCH_STATUS))
  2317. MYSQL_YYABORT;
  2318. }
  2319. | INNOBASE_SYM STATUS_SYM
  2320. @@ -10301,24 +10265,24 @@ show_param:
  2321. LEX *lex= Lex;
  2322. lex->sql_command = SQLCOM_SHOW_ENGINE_STATUS;
  2323. if (!(lex->create_info.db_type=
  2324. - ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
  2325. + ha_resolve_by_legacy_type(thd, DB_TYPE_INNODB)))
  2326. {
  2327. my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
  2328. MYSQL_YYABORT;
  2329. }
  2330. - WARN_DEPRECATED(yythd, "6.0", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
  2331. + WARN_DEPRECATED(thd, "6.0", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
  2332. }
  2333. | MUTEX_SYM STATUS_SYM
  2334. {
  2335. LEX *lex= Lex;
  2336. lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
  2337. if (!(lex->create_info.db_type=
  2338. - ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
  2339. + ha_resolve_by_legacy_type(thd, DB_TYPE_INNODB)))
  2340. {
  2341. my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
  2342. MYSQL_YYABORT;
  2343. }
  2344. - WARN_DEPRECATED(yythd, "6.0", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
  2345. + WARN_DEPRECATED(thd, "6.0", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
  2346. }
  2347. | opt_full PROCESSLIST_SYM
  2348. { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
  2349. @@ -10327,21 +10291,21 @@ show_param:
  2350. LEX *lex= Lex;
  2351. lex->sql_command= SQLCOM_SHOW_VARIABLES;
  2352. lex->option_type= $1;
  2353. - if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
  2354. + if (prepare_schema_table(thd, lex, 0, SCH_VARIABLES))
  2355. MYSQL_YYABORT;
  2356. }
  2357. | charset wild_and_where
  2358. {
  2359. LEX *lex= Lex;
  2360. lex->sql_command= SQLCOM_SHOW_CHARSETS;
  2361. - if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
  2362. + if (prepare_schema_table(thd, lex, 0, SCH_CHARSETS))
  2363. MYSQL_YYABORT;
  2364. }
  2365. | COLLATION_SYM wild_and_where
  2366. {
  2367. LEX *lex= Lex;
  2368. lex->sql_command= SQLCOM_SHOW_COLLATIONS;
  2369. - if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS))
  2370. + if (prepare_schema_table(thd, lex, 0, SCH_COLLATIONS))
  2371. MYSQL_YYABORT;
  2372. }
  2373. | GRANTS
  2374. @@ -10371,7 +10335,7 @@ show_param:
  2375. {
  2376. LEX *lex= Lex;
  2377. lex->sql_command = SQLCOM_SHOW_CREATE;
  2378. - if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
  2379. + if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0))
  2380. MYSQL_YYABORT;
  2381. lex->only_view= 0;
  2382. lex->create_info.storage_media= HA_SM_DEFAULT;
  2383. @@ -10380,7 +10344,7 @@ show_param:
  2384. {
  2385. LEX *lex= Lex;
  2386. lex->sql_command = SQLCOM_SHOW_CREATE;
  2387. - if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL, 0))
  2388. + if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0))
  2389. MYSQL_YYABORT;
  2390. lex->only_view= 1;
  2391. }
  2392. @@ -10416,14 +10380,14 @@ show_param:
  2393. {
  2394. LEX *lex= Lex;
  2395. lex->sql_command= SQLCOM_SHOW_STATUS_PROC;
  2396. - if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES))
  2397. + if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))
  2398. MYSQL_YYABORT;
  2399. }
  2400. | FUNCTION_SYM STATUS_SYM wild_and_where
  2401. {
  2402. LEX *lex= Lex;
  2403. lex->sql_command= SQLCOM_SHOW_STATUS_FUNC;
  2404. - if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES))
  2405. + if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))
  2406. MYSQL_YYABORT;
  2407. }
  2408. | PROCEDURE CODE_SYM sp_name
  2409. @@ -10501,7 +10465,7 @@ wild_and_where:
  2410. /* empty */
  2411. | LIKE TEXT_STRING_sys
  2412. {
  2413. - Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length,
  2414. + Lex->wild= new (thd->mem_root) String($2.str, $2.length,
  2415. system_charset_info);
  2416. if (Lex->wild == NULL)
  2417. MYSQL_YYABORT;
  2418. @@ -10525,7 +10489,7 @@ describe:
  2419. lex->sql_command= SQLCOM_SHOW_FIELDS;
  2420. lex->select_lex.db= 0;
  2421. lex->verbose= 0;
  2422. - if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS))
  2423. + if (prepare_schema_table(thd, lex, $2, SCH_COLUMNS))
  2424. MYSQL_YYABORT;
  2425. }
  2426. opt_describe_column {}
  2427. @@ -10554,7 +10518,7 @@ opt_describe_column:
  2428. | text_string { Lex->wild= $1; }
  2429. | ident
  2430. {
  2431. - Lex->wild= new (YYTHD->mem_root) String((const char*) $1.str,
  2432. + Lex->wild= new (thd->mem_root) String((const char*) $1.str,
  2433. $1.length,
  2434. system_charset_info);
  2435. if (Lex->wild == NULL)
  2436. @@ -10697,7 +10661,6 @@ use:
  2437. load:
  2438. LOAD DATA_SYM
  2439. {
  2440. - THD *thd= YYTHD;
  2441. LEX *lex= thd->lex;
  2442. if (lex->sphead)
  2443. @@ -10711,7 +10674,7 @@ load:
  2444. | LOAD TABLE_SYM table_ident FROM MASTER_SYM
  2445. {
  2446. LEX *lex=Lex;
  2447. - WARN_DEPRECATED(yythd, "6.0", "LOAD TABLE FROM MASTER",
  2448. + WARN_DEPRECATED(thd, "6.0", "LOAD TABLE FROM MASTER",
  2449. "MySQL Administrator (mysqldump, mysql)");
  2450. if (lex->sphead)
  2451. {
  2452. @@ -10719,7 +10682,7 @@ load:
  2453. MYSQL_YYABORT;
  2454. }
  2455. lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
  2456. - if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
  2457. + if (!Select->add_table_to_list(thd, $3, NULL, TL_OPTION_UPDATING))
  2458. MYSQL_YYABORT;
  2459. }
  2460. ;
  2461. @@ -10739,7 +10702,7 @@ load_data:
  2462. opt_duplicate INTO TABLE_SYM table_ident
  2463. {
  2464. LEX *lex=Lex;
  2465. - if (!Select->add_table_to_list(YYTHD, $9, NULL, TL_OPTION_UPDATING,
  2466. + if (!Select->add_table_to_list(thd, $9, NULL, TL_OPTION_UPDATING,
  2467. lex->lock_option))
  2468. MYSQL_YYABORT;
  2469. lex->field_list.empty();
  2470. @@ -10754,7 +10717,7 @@ load_data:
  2471. | FROM MASTER_SYM
  2472. {
  2473. Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
  2474. - WARN_DEPRECATED(yythd, "6.0", "LOAD DATA FROM MASTER",
  2475. + WARN_DEPRECATED(thd, "6.0", "LOAD DATA FROM MASTER",
  2476. "mysqldump or future "
  2477. "BACKUP/RESTORE DATABASE facility");
  2478. }
  2479. @@ -10872,7 +10835,7 @@ field_or_var:
  2480. simple_ident_nospvar {$$= $1;}
  2481. | '@' ident_or_text
  2482. {
  2483. - $$= new (YYTHD->mem_root) Item_user_var_as_out_param($2);
  2484. + $$= new (thd->mem_root) Item_user_var_as_out_param($2);
  2485. if ($$ == NULL)
  2486. MYSQL_YYABORT;
  2487. }
  2488. @@ -10889,7 +10852,6 @@ text_literal:
  2489. TEXT_STRING
  2490. {
  2491. LEX_STRING tmp;
  2492. - THD *thd= YYTHD;
  2493. CHARSET_INFO *cs_con= thd->variables.collation_connection;
  2494. CHARSET_INFO *cs_cli= thd->variables.character_set_client;
  2495. uint repertoire= thd->lex->text_string_is_7bit &&
  2496. @@ -10915,7 +10877,7 @@ text_literal:
  2497. uint repertoire= Lex->text_string_is_7bit ?
  2498. MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
  2499. DBUG_ASSERT(my_charset_is_ascii_based(national_charset_info));
  2500. - $$= new (YYTHD->mem_root) Item_string($1.str, $1.length,
  2501. + $$= new (thd->mem_root) Item_string($1.str, $1.length,
  2502. national_charset_info,
  2503. DERIVATION_COERCIBLE,
  2504. repertoire);
  2505. @@ -10924,7 +10886,7 @@ text_literal:
  2506. }
  2507. | UNDERSCORE_CHARSET TEXT_STRING
  2508. {
  2509. - Item_string *str= new (YYTHD->mem_root) Item_string($2.str,
  2510. + Item_string *str= new (thd->mem_root) Item_string($2.str,
  2511. $2.length, $1);
  2512. if (str == NULL)
  2513. MYSQL_YYABORT;
  2514. @@ -10943,7 +10905,7 @@ text_literal:
  2515. If the string has been pure ASCII so far,
  2516. check the new part.
  2517. */
  2518. - CHARSET_INFO *cs= YYTHD->variables.collation_connection;
  2519. + CHARSET_INFO *cs= thd->variables.collation_connection;
  2520. item->collation.repertoire|= my_string_repertoire(cs,
  2521. $2.str,
  2522. $2.length);
  2523. @@ -10954,15 +10916,15 @@ text_literal:
  2524. text_string:
  2525. TEXT_STRING_literal
  2526. {
  2527. - $$= new (YYTHD->mem_root) String($1.str,
  2528. + $$= new (thd->mem_root) String($1.str,
  2529. $1.length,
  2530. - YYTHD->variables.collation_connection);
  2531. + thd->variables.collation_connection);
  2532. if ($$ == NULL)
  2533. MYSQL_YYABORT;
  2534. }
  2535. | HEX_NUM
  2536. {
  2537. - Item *tmp= new (YYTHD->mem_root) Item_hex_string($1.str, $1.length);
  2538. + Item *tmp= new (thd->mem_root) Item_hex_string($1.str, $1.length);
  2539. if (tmp == NULL)
  2540. MYSQL_YYABORT;
  2541. /*
  2542. @@ -10974,7 +10936,7 @@ text_string:
  2543. }
  2544. | BIN_NUM
  2545. {
  2546. - Item *tmp= new (YYTHD->mem_root) Item_bin_string($1.str, $1.length);
  2547. + Item *tmp= new (thd->mem_root) Item_bin_string($1.str, $1.length);
  2548. if (tmp == NULL)
  2549. MYSQL_YYABORT;
  2550. /*
  2551. @@ -10989,7 +10951,6 @@ text_string:
  2552. param_marker:
  2553. PARAM_MARKER
  2554. {
  2555. - THD *thd= YYTHD;
  2556. LEX *lex= thd->lex;
  2557. Lex_input_stream *lip= YYLIP;
  2558. Item_param *item;
  2559. @@ -11022,38 +10983,38 @@ literal:
  2560. | NUM_literal { $$ = $1; }
  2561. | NULL_SYM
  2562. {
  2563. - $$ = new (YYTHD->mem_root) Item_null();
  2564. + $$ = new (thd->mem_root) Item_null();
  2565. if ($$ == NULL)
  2566. MYSQL_YYABORT;
  2567. YYLIP->next_state= MY_LEX_OPERATOR_OR_IDENT;
  2568. }
  2569. | FALSE_SYM
  2570. {
  2571. - $$= new (YYTHD->mem_root) Item_int((char*) "FALSE",0,1);
  2572. + $$= new (thd->mem_root) Item_int((char*) "FALSE",0,1);
  2573. if ($$ == NULL)
  2574. MYSQL_YYABORT;
  2575. }
  2576. | TRUE_SYM
  2577. {
  2578. - $$= new (YYTHD->mem_root) Item_int((char*) "TRUE",1,1);
  2579. + $$= new (thd->mem_root) Item_int((char*) "TRUE",1,1);
  2580. if ($$ == NULL)
  2581. MYSQL_YYABORT;
  2582. }
  2583. | HEX_NUM
  2584. {
  2585. - $$ = new (YYTHD->mem_root) Item_hex_string($1.str, $1.length);
  2586. + $$ = new (thd->mem_root) Item_hex_string($1.str, $1.length);
  2587. if ($$ == NULL)
  2588. MYSQL_YYABORT;
  2589. }
  2590. | BIN_NUM
  2591. {
  2592. - $$= new (YYTHD->mem_root) Item_bin_string($1.str, $1.length);
  2593. + $$= new (thd->mem_root) Item_bin_string($1.str, $1.length);
  2594. if ($$ == NULL)
  2595. MYSQL_YYABORT;
  2596. }
  2597. | UNDERSCORE_CHARSET HEX_NUM
  2598. {
  2599. - Item *tmp= new (YYTHD->mem_root) Item_hex_string($2.str, $2.length);
  2600. + Item *tmp= new (thd->mem_root) Item_hex_string($2.str, $2.length);
  2601. if (tmp == NULL)
  2602. MYSQL_YYABORT;
  2603. /*
  2604. @@ -11064,7 +11025,7 @@ literal:
  2605. String *str= tmp->val_str((String*) 0);
  2606. Item_string *item_str;
  2607. - item_str= new (YYTHD->mem_root)
  2608. + item_str= new (thd->mem_root)
  2609. Item_string(NULL, /* name will be set in select_item */
  2610. str ? str->ptr() : "",
  2611. str ? str->length() : 0,
  2612. @@ -11082,7 +11043,7 @@ literal:
  2613. }
  2614. | UNDERSCORE_CHARSET BIN_NUM
  2615. {
  2616. - Item *tmp= new (YYTHD->mem_root) Item_bin_string($2.str, $2.length);
  2617. + Item *tmp= new (thd->mem_root) Item_bin_string($2.str, $2.length);
  2618. if (tmp == NULL)
  2619. MYSQL_YYABORT;
  2620. /*
  2621. @@ -11093,7 +11054,7 @@ literal:
  2622. String *str= tmp->val_str((String*) 0);
  2623. Item_string *item_str;
  2624. - item_str= new (YYTHD->mem_root)
  2625. + item_str= new (thd->mem_root)
  2626. Item_string(NULL, /* name will be set in select_item */
  2627. str ? str->ptr() : "",
  2628. str ? str->length() : 0,
  2629. @@ -11117,7 +11078,7 @@ NUM_literal:
  2630. NUM
  2631. {
  2632. int error;
  2633. - $$= new (YYTHD->mem_root)
  2634. + $$= new (thd->mem_root)
  2635. Item_int($1.str,
  2636. (longlong) my_strtoll10($1.str, NULL, &error),
  2637. $1.length);
  2638. @@ -11127,7 +11088,7 @@ NUM_literal:
  2639. | LONG_NUM
  2640. {
  2641. int error;
  2642. - $$= new (YYTHD->mem_root)
  2643. + $$= new (thd->mem_root)
  2644. Item_int($1.str,
  2645. (longlong) my_strtoll10($1.str, NULL, &error),
  2646. $1.length);
  2647. @@ -11136,23 +11097,23 @@ NUM_literal:
  2648. }
  2649. | ULONGLONG_NUM
  2650. {
  2651. - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length);
  2652. + $$= new (thd->mem_root) Item_uint($1.str, $1.length);
  2653. if ($$ == NULL)
  2654. MYSQL_YYABORT;
  2655. }
  2656. | DECIMAL_NUM
  2657. {
  2658. - $$= new (YYTHD->mem_root) Item_decimal($1.str, $1.length,
  2659. - YYTHD->charset());
  2660. - if (($$ == NULL) || (YYTHD->is_error()))
  2661. + $$= new (thd->mem_root) Item_decimal($1.str, $1.length,
  2662. + thd->charset());
  2663. + if (($$ == NULL) || (thd->is_error()))
  2664. {
  2665. MYSQL_YYABORT;
  2666. }
  2667. }
  2668. | FLOAT_NUM
  2669. {
  2670. - $$= new (YYTHD->mem_root) Item_float($1.str, $1.length);
  2671. - if (($$ == NULL) || (YYTHD->is_error()))
  2672. + $$= new (thd->mem_root) Item_float($1.str, $1.length);
  2673. + if (($$ == NULL) || (thd->is_error()))
  2674. {
  2675. MYSQL_YYABORT;
  2676. }
  2677. @@ -11172,7 +11133,7 @@ table_wild:
  2678. ident '.' '*'
  2679. {
  2680. SELECT_LEX *sel= Select;
  2681. - $$= new (YYTHD->mem_root) Item_field(Lex->current_context(),
  2682. + $$= new (thd->mem_root) Item_field(Lex->current_context(),
  2683. NullS, $1.str, "*");
  2684. if ($$ == NULL)
  2685. MYSQL_YYABORT;
  2686. @@ -11180,7 +11141,6 @@ table_wild:
  2687. }
  2688. | ident '.' ident '.' '*'
  2689. {
  2690. - THD *thd= YYTHD;
  2691. SELECT_LEX *sel= Select;
  2692. const char* schema= thd->client_capabilities & CLIENT_NO_SCHEMA ?
  2693. NullS : $1.str;
  2694. @@ -11200,7 +11160,6 @@ order_ident:
  2695. simple_ident:
  2696. ident
  2697. {
  2698. - THD *thd= YYTHD;
  2699. LEX *lex= thd->lex;
  2700. Lex_input_stream *lip= YYLIP;
  2701. sp_variable_t *spv;
  2702. @@ -11251,7 +11210,6 @@ simple_ident:
  2703. simple_ident_nospvar:
  2704. ident
  2705. {
  2706. - THD *thd= YYTHD;
  2707. SELECT_LEX *sel=Select;
  2708. if ((sel->parsing_place != IN_HAVING) ||
  2709. (sel->get_in_sum_expr() > 0))
  2710. @@ -11273,7 +11231,6 @@ simple_ident_nospvar:
  2711. simple_ident_q:
  2712. ident '.' ident
  2713. {
  2714. - THD *thd= YYTHD;
  2715. LEX *lex= thd->lex;
  2716. /*
  2717. @@ -11352,7 +11309,6 @@ simple_ident_q:
  2718. }
  2719. | '.' ident '.' ident
  2720. {
  2721. - THD *thd= YYTHD;
  2722. LEX *lex= thd->lex;
  2723. SELECT_LEX *sel= lex->current_select;
  2724. if (sel->no_table_names_allowed)
  2725. @@ -11377,7 +11333,6 @@ simple_ident_q:
  2726. }
  2727. | ident '.' ident '.' ident
  2728. {
  2729. - THD *thd= YYTHD;
  2730. LEX *lex= thd->lex;
  2731. SELECT_LEX *sel= lex->current_select;
  2732. const char* schema= (thd->client_capabilities & CLIENT_NO_SCHEMA ?
  2733. @@ -11445,7 +11400,7 @@ table_ident:
  2734. }
  2735. | ident '.' ident
  2736. {
  2737. - $$= new Table_ident(YYTHD, $1,$3,0);
  2738. + $$= new Table_ident(thd, $1,$3,0);
  2739. if ($$ == NULL)
  2740. MYSQL_YYABORT;
  2741. }
  2742. @@ -11467,7 +11422,7 @@ table_ident_opt_wild:
  2743. }
  2744. | ident '.' ident opt_wild
  2745. {
  2746. - $$= new Table_ident(YYTHD, $1,$3,0);
  2747. + $$= new Table_ident(thd, $1,$3,0);
  2748. if ($$ == NULL)
  2749. MYSQL_YYABORT;
  2750. }
  2751. @@ -11477,7 +11432,7 @@ table_ident_nodb:
  2752. ident
  2753. {
  2754. LEX_STRING db={(char*) any_db,3};
  2755. - $$= new Table_ident(YYTHD, db,$1,0);
  2756. + $$= new Table_ident(thd, db,$1,0);
  2757. if ($$ == NULL)
  2758. MYSQL_YYABORT;
  2759. }
  2760. @@ -11487,8 +11442,6 @@ IDENT_sys:
  2761. IDENT { $$= $1; }
  2762. | IDENT_QUOTED
  2763. {
  2764. - THD *thd= YYTHD;
  2765. -
  2766. if (thd->charset_is_system_charset)
  2767. {
  2768. CHARSET_INFO *cs= system_charset_info;
  2769. @@ -11516,8 +11469,6 @@ IDENT_sys:
  2770. TEXT_STRING_sys:
  2771. TEXT_STRING
  2772. {
  2773. - THD *thd= YYTHD;
  2774. -
  2775. if (thd->charset_is_system_charset)
  2776. $$= $1;
  2777. else
  2778. @@ -11532,8 +11483,6 @@ TEXT_STRING_sys:
  2779. TEXT_STRING_literal:
  2780. TEXT_STRING
  2781. {
  2782. - THD *thd= YYTHD;
  2783. -
  2784. if (thd->charset_is_collation_connection)
  2785. $$= $1;
  2786. else
  2787. @@ -11548,8 +11497,6 @@ TEXT_STRING_literal:
  2788. TEXT_STRING_filesystem:
  2789. TEXT_STRING
  2790. {
  2791. - THD *thd= YYTHD;
  2792. -
  2793. if (thd->charset_is_character_set_filesystem)
  2794. $$= $1;
  2795. else
  2796. @@ -11566,7 +11513,6 @@ ident:
  2797. IDENT_sys { $$=$1; }
  2798. | keyword
  2799. {
  2800. - THD *thd= YYTHD;
  2801. $$.str= thd->strmake($1.str, $1.length);
  2802. if ($$.str == NULL)
  2803. MYSQL_YYABORT;
  2804. @@ -11578,7 +11524,6 @@ label_ident:
  2805. IDENT_sys { $$=$1; }
  2806. | keyword_sp
  2807. {
  2808. - THD *thd= YYTHD;
  2809. $$.str= thd->strmake($1.str, $1.length);
  2810. if ($$.str == NULL)
  2811. MYSQL_YYABORT;
  2812. @@ -11595,7 +11540,6 @@ ident_or_text:
  2813. user:
  2814. ident_or_text
  2815. {
  2816. - THD *thd= YYTHD;
  2817. if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
  2818. MYSQL_YYABORT;
  2819. $$->user = $1;
  2820. @@ -11609,7 +11553,6 @@ user:
  2821. }
  2822. | ident_or_text '@' ident_or_text
  2823. {
  2824. - THD *thd= YYTHD;
  2825. if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
  2826. MYSQL_YYABORT;
  2827. $$->user = $1; $$->host=$3;
  2828. @@ -11628,7 +11571,7 @@ user:
  2829. }
  2830. | CURRENT_USER optional_braces
  2831. {
  2832. - if (!($$=(LEX_USER*) YYTHD->alloc(sizeof(st_lex_user))))
  2833. + if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
  2834. MYSQL_YYABORT;
  2835. /*
  2836. empty LEX_USER means current_user and
  2837. @@ -11991,7 +11934,6 @@ option_value_list:
  2838. option_type_value:
  2839. {
  2840. - THD *thd= YYTHD;
  2841. LEX *lex= thd->lex;
  2842. Lex_input_stream *lip= YYLIP;
  2843. @@ -12022,7 +11964,6 @@ option_type_value:
  2844. }
  2845. ext_option_value
  2846. {
  2847. - THD *thd= YYTHD;
  2848. LEX *lex= thd->lex;
  2849. Lex_input_stream *lip= YYLIP;
  2850. @@ -12105,7 +12046,6 @@ ext_option_value:
  2851. sys_option_value:
  2852. option_type internal_variable_name equal set_expr_or_default
  2853. {
  2854. - THD *thd= YYTHD;
  2855. LEX *lex= Lex;
  2856. LEX_STRING *name= &$2.base_name;
  2857. @@ -12117,7 +12057,7 @@ sys_option_value:
  2858. my_parse_error(ER(ER_SYNTAX_ERROR));
  2859. MYSQL_YYABORT;
  2860. }
  2861. - if (set_trigger_new_row(YYTHD, name, $4))
  2862. + if (set_trigger_new_row(thd, name, $4))
  2863. MYSQL_YYABORT;
  2864. }
  2865. else if ($2.var)
  2866. @@ -12147,7 +12087,6 @@ sys_option_value:
  2867. }
  2868. | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
  2869. {
  2870. - THD *thd= YYTHD;
  2871. LEX *lex=Lex;
  2872. lex->option_type= $1;
  2873. Item *item= new (thd->mem_root) Item_int((int32) $5);
  2874. @@ -12167,7 +12106,7 @@ option_value:
  2875. '@' ident_or_text equal expr
  2876. {
  2877. Item_func_set_user_var *item;
  2878. - item= new (YYTHD->mem_root) Item_func_set_user_var($2, $4);
  2879. + item= new (thd->mem_root) Item_func_set_user_var($2, $4);
  2880. if (item == NULL)
  2881. MYSQL_YYABORT;
  2882. set_var_user *var= new set_var_user(item);
  2883. @@ -12177,7 +12116,6 @@ option_value:
  2884. }
  2885. | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
  2886. {
  2887. - THD *thd= YYTHD;
  2888. struct sys_var_with_base tmp= $4;
  2889. /* Lookup if necessary: must be a system variable. */
  2890. if (tmp.var == NULL)
  2891. @@ -12190,7 +12128,6 @@ option_value:
  2892. }
  2893. | charset old_or_new_charset_name_or_default
  2894. {
  2895. - THD *thd= YYTHD;
  2896. LEX *lex= thd->lex;
  2897. CHARSET_INFO *cs2;
  2898. cs2= $2 ? $2: global_system_variables.character_set_client;
  2899. @@ -12238,7 +12175,6 @@ option_value:
  2900. }
  2901. | PASSWORD equal text_or_password
  2902. {
  2903. - THD *thd= YYTHD;
  2904. LEX *lex= thd->lex;
  2905. LEX_USER *user;
  2906. sp_pcontext *spc= lex->spcont;
  2907. @@ -12278,7 +12214,6 @@ option_value:
  2908. internal_variable_name:
  2909. ident
  2910. {
  2911. - THD *thd= YYTHD;
  2912. sp_pcontext *spc= thd->lex->spcont;
  2913. sp_variable_t *spv;
  2914. @@ -12337,7 +12272,7 @@ internal_variable_name:
  2915. }
  2916. else
  2917. {
  2918. - sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
  2919. + sys_var *tmp=find_sys_var(thd, $3.str, $3.length);
  2920. if (!tmp)
  2921. MYSQL_YYABORT;
  2922. if (!tmp->is_struct())
  2923. @@ -12348,7 +12283,7 @@ internal_variable_name:
  2924. }
  2925. | DEFAULT '.' ident
  2926. {
  2927. - sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
  2928. + sys_var *tmp=find_sys_var(thd, $3.str, $3.length);
  2929. if (!tmp)
  2930. MYSQL_YYABORT;
  2931. if (!tmp->is_struct())
  2932. @@ -12370,16 +12305,16 @@ text_or_password:
  2933. TEXT_STRING { $$=$1.str;}
  2934. | PASSWORD '(' TEXT_STRING ')'
  2935. {
  2936. - $$= $3.length ? YYTHD->variables.old_passwords ?
  2937. - Item_func_old_password::alloc(YYTHD, $3.str, $3.length) :
  2938. - Item_func_password::alloc(YYTHD, $3.str, $3.length) :
  2939. + $$= $3.length ? thd->variables.old_passwords ?
  2940. + Item_func_old_password::alloc(thd, $3.str, $3.length) :
  2941. + Item_func_password::alloc(thd, $3.str, $3.length) :
  2942. $3.str;
  2943. if ($$ == NULL)
  2944. MYSQL_YYABORT;
  2945. }
  2946. | OLD_PASSWORD '(' TEXT_STRING ')'
  2947. {
  2948. - $$= $3.length ? Item_func_old_password::alloc(YYTHD, $3.str,
  2949. + $$= $3.length ? Item_func_old_password::alloc(thd, $3.str,
  2950. $3.length) :
  2951. $3.str;
  2952. if ($$ == NULL)
  2953. @@ -12393,19 +12328,19 @@ set_expr_or_default:
  2954. | DEFAULT { $$=0; }
  2955. | ON
  2956. {
  2957. - $$=new (YYTHD->mem_root) Item_string("ON", 2, system_charset_info);
  2958. + $$=new (thd->mem_root) Item_string("ON", 2, system_charset_info);
  2959. if ($$ == NULL)
  2960. MYSQL_YYABORT;
  2961. }
  2962. | ALL
  2963. {
  2964. - $$=new (YYTHD->mem_root) Item_string("ALL", 3, system_charset_info);
  2965. + $$=new (thd->mem_root) Item_string("ALL", 3, system_charset_info);
  2966. if ($$ == NULL)
  2967. MYSQL_YYABORT;
  2968. }
  2969. | BINARY
  2970. {
  2971. - $$=new (YYTHD->mem_root) Item_string("binary", 6, system_charset_info);
  2972. + $$=new (thd->mem_root) Item_string("binary", 6, system_charset_info);
  2973. if ($$ == NULL)
  2974. MYSQL_YYABORT;
  2975. }
  2976. @@ -12443,7 +12378,7 @@ table_lock:
  2977. table_ident opt_table_alias lock_option
  2978. {
  2979. thr_lock_type lock_type= (thr_lock_type) $3;
  2980. - if (!Select->add_table_to_list(YYTHD, $1, $2, 0, lock_type))
  2981. + if (!Select->add_table_to_list(thd, $1, $2, 0, lock_type))
  2982. MYSQL_YYABORT;
  2983. /* If table is to be write locked, protect from a impending GRL. */
  2984. if (lock_type >= TL_WRITE_ALLOW_WRITE)
  2985. @@ -12514,7 +12449,7 @@ handler:
  2986. lex->expr_allows_subselect= FALSE;
  2987. lex->sql_command = SQLCOM_HA_READ;
  2988. lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */
  2989. - Item *one= new (YYTHD->mem_root) Item_int((int32) 1);
  2990. + Item *one= new (thd->mem_root) Item_int((int32) 1);
  2991. if (one == NULL)
  2992. MYSQL_YYABORT;
  2993. lex->current_select->select_limit= one;
  2994. @@ -12836,10 +12771,10 @@ grant_user:
  2995. $$=$1; $1->password=$4;
  2996. if ($4.length)
  2997. {
  2998. - if (YYTHD->variables.old_passwords)
  2999. + if (thd->variables.old_passwords)
  3000. {
  3001. char *buff=
  3002. - (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1);
  3003. + (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1);
  3004. if (buff == NULL)
  3005. MYSQL_YYABORT;
  3006. my_make_scrambled_password_323(buff, $4.str, $4.length);
  3007. @@ -12849,7 +12784,7 @@ grant_user:
  3008. else
  3009. {
  3010. char *buff=
  3011. - (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1);
  3012. + (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1);
  3013. if (buff == NULL)
  3014. MYSQL_YYABORT;
  3015. my_make_scrambled_password(buff, $4.str, $4.length);
  3016. @@ -12881,7 +12816,7 @@ column_list:
  3017. column_list_id:
  3018. ident
  3019. {
  3020. - String *new_str = new (YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info);
  3021. + String *new_str = new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info);
  3022. if (new_str == NULL)
  3023. MYSQL_YYABORT;
  3024. List_iterator <LEX_COLUMN> iter(Lex->columns);
  3025. @@ -12981,14 +12916,14 @@ opt_work:
  3026. opt_chain:
  3027. /* empty */
  3028. - { $$= (YYTHD->variables.completion_type == 1); }
  3029. + { $$= (thd->variables.completion_type == 1); }
  3030. | AND_SYM NO_SYM CHAIN_SYM { $$=0; }
  3031. | AND_SYM CHAIN_SYM { $$=1; }
  3032. ;
  3033. opt_release:
  3034. /* empty */
  3035. - { $$= (YYTHD->variables.completion_type == 2); }
  3036. + { $$= (thd->variables.completion_type == 2); }
  3037. | RELEASE_SYM { $$=1; }
  3038. | NO_SYM RELEASE_SYM { $$=0; }
  3039. ;
  3040. @@ -13102,7 +13037,6 @@ union_opt:
  3041. union_order_or_limit:
  3042. {
  3043. - THD *thd= YYTHD;
  3044. LEX *lex= thd->lex;
  3045. DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
  3046. SELECT_LEX *sel= lex->current_select;
  3047. @@ -13118,7 +13052,6 @@ union_order_or_limit:
  3048. }
  3049. order_or_limit
  3050. {
  3051. - THD *thd= YYTHD;
  3052. thd->lex->current_select->no_table_names_allowed= 0;
  3053. thd->where= "";
  3054. }
  3055. @@ -13255,14 +13188,14 @@ no_definer:
  3056. from older master servers (i.e. to create non-suid trigger in this
  3057. case).
  3058. */
  3059. - YYTHD->lex->definer= 0;
  3060. + thd->lex->definer= 0;
  3061. }
  3062. ;
  3063. definer:
  3064. DEFINER_SYM EQ user
  3065. {
  3066. - YYTHD->lex->definer= get_current_user(YYTHD, $3);
  3067. + thd->lex->definer= get_current_user(thd, $3);
  3068. }
  3069. ;
  3070. @@ -13307,7 +13240,6 @@ view_suid:
  3071. view_tail:
  3072. view_suid VIEW_SYM table_ident
  3073. {
  3074. - THD *thd= YYTHD;
  3075. LEX *lex= thd->lex;
  3076. lex->sql_command= SQLCOM_CREATE_VIEW;
  3077. /* first table in list is target VIEW name */
  3078. @@ -13347,7 +13279,6 @@ view_select:
  3079. }
  3080. view_select_aux view_check_option
  3081. {
  3082. - THD *thd= YYTHD;
  3083. LEX *lex= Lex;
  3084. uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str;
  3085. void *create_view_select= thd->memdup(lex->create_view_select.str, len);
  3086. @@ -13403,7 +13334,6 @@ trigger_tail:
  3087. EACH_SYM
  3088. ROW_SYM
  3089. { /* $15 */
  3090. - THD *thd= YYTHD;
  3091. LEX *lex= thd->lex;
  3092. Lex_input_stream *lip= YYLIP;
  3093. sp_head *sp;
  3094. @@ -13437,8 +13367,8 @@ trigger_tail:
  3095. sp_head *sp= lex->sphead;
  3096. lex->sql_command= SQLCOM_CREATE_TRIGGER;
  3097. - sp->set_stmt_end(YYTHD);
  3098. - sp->restore_thd_mem_root(YYTHD);
  3099. + sp->set_stmt_end(thd);
  3100. + sp->restore_thd_mem_root(thd);
  3101. if (sp->is_not_allowed_in_function("trigger"))
  3102. MYSQL_YYABORT;
  3103. @@ -13448,7 +13378,7 @@ trigger_tail:
  3104. sp_proc_stmt alternatives are not saving/restoring LEX, so
  3105. lex->query_tables can be wiped out.
  3106. */
  3107. - if (!lex->select_lex.add_table_to_list(YYTHD, $9,
  3108. + if (!lex->select_lex.add_table_to_list(thd, $9,
  3109. (LEX_STRING*) 0,
  3110. TL_OPTION_UPDATING,
  3111. TL_IGNORE))
  3112. @@ -13466,7 +13396,6 @@ udf_tail:
  3113. AGGREGATE_SYM remember_name FUNCTION_SYM ident
  3114. RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys
  3115. {
  3116. - THD *thd= YYTHD;
  3117. LEX *lex= thd->lex;
  3118. if (is_native_function(thd, & $4))
  3119. {
  3120. @@ -13484,7 +13413,6 @@ udf_tail:
  3121. | remember_name FUNCTION_SYM ident
  3122. RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys
  3123. {
  3124. - THD *thd= YYTHD;
  3125. LEX *lex= thd->lex;
  3126. if (is_native_function(thd, & $3))
  3127. {
  3128. @@ -13507,7 +13435,6 @@ sf_tail:
  3129. sp_name /* $3 */
  3130. '(' /* $4 */
  3131. { /* $5 */
  3132. - THD *thd= YYTHD;
  3133. LEX *lex= thd->lex;
  3134. Lex_input_stream *lip= YYLIP;
  3135. sp_head *sp;
  3136. @@ -13565,7 +13492,7 @@ sf_tail:
  3137. MYSQL_YYABORT;
  3138. }
  3139. - if (sp->fill_field_definition(YYTHD, lex,
  3140. + if (sp->fill_field_definition(thd, lex,
  3141. (enum enum_field_types) $11,
  3142. &sp->m_return_field_def))
  3143. MYSQL_YYABORT;
  3144. @@ -13574,7 +13501,6 @@ sf_tail:
  3145. }
  3146. sp_c_chistics /* $13 */
  3147. { /* $14 */
  3148. - THD *thd= YYTHD;
  3149. LEX *lex= thd->lex;
  3150. Lex_input_stream *lip= YYLIP;
  3151. @@ -13583,7 +13509,6 @@ sf_tail:
  3152. }
  3153. sp_proc_stmt /* $15 */
  3154. {
  3155. - THD *thd= YYTHD;
  3156. LEX *lex= thd->lex;
  3157. sp_head *sp= lex->sphead;
  3158. @@ -13654,10 +13579,10 @@ sp_tail:
  3159. sp= new sp_head();
  3160. if (sp == NULL)
  3161. MYSQL_YYABORT;
  3162. - sp->reset_thd_mem_root(YYTHD);
  3163. + sp->reset_thd_mem_root(thd);
  3164. sp->init(lex);
  3165. sp->m_type= TYPE_ENUM_PROCEDURE;
  3166. - sp->init_sp_name(YYTHD, $3);
  3167. + sp->init_sp_name(thd, $3);
  3168. lex->sphead= sp;
  3169. }
  3170. @@ -13672,7 +13597,6 @@ sp_tail:
  3171. sp_pdparam_list
  3172. ')'
  3173. {
  3174. - THD *thd= YYTHD;
  3175. LEX *lex= thd->lex;
  3176. lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
  3177. @@ -13680,7 +13604,6 @@ sp_tail:
  3178. }
  3179. sp_c_chistics
  3180. {
  3181. - THD *thd= YYTHD;
  3182. LEX *lex= thd->lex;
  3183. lex->sphead->m_chistics= &lex->sp_chistics;
  3184. @@ -13691,9 +13614,9 @@ sp_tail:
  3185. LEX *lex= Lex;
  3186. sp_head *sp= lex->sphead;
  3187. - sp->set_stmt_end(YYTHD);
  3188. + sp->set_stmt_end(thd);
  3189. lex->sql_command= SQLCOM_CREATE_PROCEDURE;
  3190. - sp->restore_thd_mem_root(YYTHD);
  3191. + sp->restore_thd_mem_root(thd);
  3192. }
  3193. ;
  3194. @@ -13730,21 +13653,21 @@ xid:
  3195. text_string
  3196. {
  3197. MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE);
  3198. - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID))))
  3199. + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
  3200. MYSQL_YYABORT;
  3201. Lex->xid->set(1L, $1->ptr(), $1->length(), 0, 0);
  3202. }
  3203. | text_string ',' text_string
  3204. {
  3205. MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE);
  3206. - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID))))
  3207. + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
  3208. MYSQL_YYABORT;
  3209. Lex->xid->set(1L, $1->ptr(), $1->length(), $3->ptr(), $3->length());
  3210. }
  3211. | text_string ',' text_string ',' ulong_num
  3212. {
  3213. MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE);
  3214. - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID))))
  3215. + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
  3216. MYSQL_YYABORT;
  3217. Lex->xid->set($5, $1->ptr(), $1->length(), $3->ptr(), $3->length());
  3218. }