0005-bison_3_breaks_mysql_server_build.patch 116 KB

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