/release/src/router/mysql/sql/item_create.cc

https://gitlab.com/envieidoc/advancedtomato2 · C++ · 2539 lines · 1710 code · 689 blank · 140 comment · 37 complexity · 04865e6b3384cd368e59c8788fa6b41c MD5 · raw file

  1. /*
  2. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  13. */
  14. /**
  15. @file
  16. @brief
  17. Functions to create an item. Used by sql_yac.yy
  18. */
  19. #include "mysql_priv.h"
  20. #include "item_create.h"
  21. #include "sp_head.h"
  22. #include "sp.h"
  23. /*
  24. =============================================================================
  25. LOCAL DECLARATIONS
  26. =============================================================================
  27. */
  28. /**
  29. Adapter for native functions with a variable number of arguments.
  30. The main use of this class is to discard the following calls:
  31. <code>foo(expr1 AS name1, expr2 AS name2, ...)</code>
  32. which are syntactically correct (the syntax can refer to a UDF),
  33. but semantically invalid for native functions.
  34. */
  35. class Create_native_func : public Create_func
  36. {
  37. public:
  38. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  39. /**
  40. Builder method, with no arguments.
  41. @param thd The current thread
  42. @param name The native function name
  43. @param item_list The function parameters, none of which are named
  44. @return An item representing the function call
  45. */
  46. virtual Item *create_native(THD *thd, LEX_STRING name,
  47. List<Item> *item_list) = 0;
  48. protected:
  49. /** Constructor. */
  50. Create_native_func() {}
  51. /** Destructor. */
  52. virtual ~Create_native_func() {}
  53. };
  54. /**
  55. Adapter for functions that takes exactly zero arguments.
  56. */
  57. class Create_func_arg0 : public Create_func
  58. {
  59. public:
  60. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  61. /**
  62. Builder method, with no arguments.
  63. @param thd The current thread
  64. @return An item representing the function call
  65. */
  66. virtual Item *create(THD *thd) = 0;
  67. protected:
  68. /** Constructor. */
  69. Create_func_arg0() {}
  70. /** Destructor. */
  71. virtual ~Create_func_arg0() {}
  72. };
  73. /**
  74. Adapter for functions that takes exactly one argument.
  75. */
  76. class Create_func_arg1 : public Create_func
  77. {
  78. public:
  79. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  80. /**
  81. Builder method, with one argument.
  82. @param thd The current thread
  83. @param arg1 The first argument of the function
  84. @return An item representing the function call
  85. */
  86. virtual Item *create(THD *thd, Item *arg1) = 0;
  87. protected:
  88. /** Constructor. */
  89. Create_func_arg1() {}
  90. /** Destructor. */
  91. virtual ~Create_func_arg1() {}
  92. };
  93. /**
  94. Adapter for functions that takes exactly two arguments.
  95. */
  96. class Create_func_arg2 : public Create_func
  97. {
  98. public:
  99. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  100. /**
  101. Builder method, with two arguments.
  102. @param thd The current thread
  103. @param arg1 The first argument of the function
  104. @param arg2 The second argument of the function
  105. @return An item representing the function call
  106. */
  107. virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0;
  108. protected:
  109. /** Constructor. */
  110. Create_func_arg2() {}
  111. /** Destructor. */
  112. virtual ~Create_func_arg2() {}
  113. };
  114. /**
  115. Adapter for functions that takes exactly three arguments.
  116. */
  117. class Create_func_arg3 : public Create_func
  118. {
  119. public:
  120. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  121. /**
  122. Builder method, with three arguments.
  123. @param thd The current thread
  124. @param arg1 The first argument of the function
  125. @param arg2 The second argument of the function
  126. @param arg3 The third argument of the function
  127. @return An item representing the function call
  128. */
  129. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
  130. protected:
  131. /** Constructor. */
  132. Create_func_arg3() {}
  133. /** Destructor. */
  134. virtual ~Create_func_arg3() {}
  135. };
  136. /**
  137. Function builder for Stored Functions.
  138. */
  139. class Create_sp_func : public Create_qfunc
  140. {
  141. public:
  142. virtual Item *create(THD *thd, LEX_STRING db, LEX_STRING name,
  143. bool use_explicit_name, List<Item> *item_list);
  144. static Create_sp_func s_singleton;
  145. protected:
  146. /** Constructor. */
  147. Create_sp_func() {}
  148. /** Destructor. */
  149. virtual ~Create_sp_func() {}
  150. };
  151. #ifndef HAVE_SPATIAL
  152. /**
  153. Common (non) builder for geometry functions.
  154. This builder is used in <code>--without-geometry</code> builds only,
  155. to report an error.
  156. */
  157. class Create_func_no_geom : public Create_func
  158. {
  159. public:
  160. virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
  161. /** Singleton. */
  162. static Create_func_no_geom s_singleton;
  163. protected:
  164. /** Constructor. */
  165. Create_func_no_geom() {}
  166. /** Destructor. */
  167. virtual ~Create_func_no_geom() {}
  168. };
  169. #endif
  170. /*
  171. Concrete functions builders (native functions).
  172. Please keep this list sorted in alphabetical order,
  173. it helps to compare code between versions, and helps with merges conflicts.
  174. */
  175. class Create_func_abs : public Create_func_arg1
  176. {
  177. public:
  178. virtual Item *create(THD *thd, Item *arg1);
  179. static Create_func_abs s_singleton;
  180. protected:
  181. Create_func_abs() {}
  182. virtual ~Create_func_abs() {}
  183. };
  184. class Create_func_acos : public Create_func_arg1
  185. {
  186. public:
  187. virtual Item *create(THD *thd, Item *arg1);
  188. static Create_func_acos s_singleton;
  189. protected:
  190. Create_func_acos() {}
  191. virtual ~Create_func_acos() {}
  192. };
  193. class Create_func_addtime : public Create_func_arg2
  194. {
  195. public:
  196. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  197. static Create_func_addtime s_singleton;
  198. protected:
  199. Create_func_addtime() {}
  200. virtual ~Create_func_addtime() {}
  201. };
  202. class Create_func_aes_encrypt : public Create_func_arg2
  203. {
  204. public:
  205. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  206. static Create_func_aes_encrypt s_singleton;
  207. protected:
  208. Create_func_aes_encrypt() {}
  209. virtual ~Create_func_aes_encrypt() {}
  210. };
  211. class Create_func_aes_decrypt : public Create_func_arg2
  212. {
  213. public:
  214. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  215. static Create_func_aes_decrypt s_singleton;
  216. protected:
  217. Create_func_aes_decrypt() {}
  218. virtual ~Create_func_aes_decrypt() {}
  219. };
  220. #ifdef HAVE_SPATIAL
  221. class Create_func_area : public Create_func_arg1
  222. {
  223. public:
  224. virtual Item *create(THD *thd, Item *arg1);
  225. static Create_func_area s_singleton;
  226. protected:
  227. Create_func_area() {}
  228. virtual ~Create_func_area() {}
  229. };
  230. #endif
  231. #ifdef HAVE_SPATIAL
  232. class Create_func_as_wkb : public Create_func_arg1
  233. {
  234. public:
  235. virtual Item *create(THD *thd, Item *arg1);
  236. static Create_func_as_wkb s_singleton;
  237. protected:
  238. Create_func_as_wkb() {}
  239. virtual ~Create_func_as_wkb() {}
  240. };
  241. #endif
  242. #ifdef HAVE_SPATIAL
  243. class Create_func_as_wkt : public Create_func_arg1
  244. {
  245. public:
  246. virtual Item *create(THD *thd, Item *arg1);
  247. static Create_func_as_wkt s_singleton;
  248. protected:
  249. Create_func_as_wkt() {}
  250. virtual ~Create_func_as_wkt() {}
  251. };
  252. #endif
  253. class Create_func_asin : public Create_func_arg1
  254. {
  255. public:
  256. virtual Item *create(THD *thd, Item *arg1);
  257. static Create_func_asin s_singleton;
  258. protected:
  259. Create_func_asin() {}
  260. virtual ~Create_func_asin() {}
  261. };
  262. class Create_func_atan : public Create_native_func
  263. {
  264. public:
  265. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  266. static Create_func_atan s_singleton;
  267. protected:
  268. Create_func_atan() {}
  269. virtual ~Create_func_atan() {}
  270. };
  271. class Create_func_benchmark : public Create_func_arg2
  272. {
  273. public:
  274. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  275. static Create_func_benchmark s_singleton;
  276. protected:
  277. Create_func_benchmark() {}
  278. virtual ~Create_func_benchmark() {}
  279. };
  280. class Create_func_bin : public Create_func_arg1
  281. {
  282. public:
  283. virtual Item *create(THD *thd, Item *arg1);
  284. static Create_func_bin s_singleton;
  285. protected:
  286. Create_func_bin() {}
  287. virtual ~Create_func_bin() {}
  288. };
  289. class Create_func_bit_count : public Create_func_arg1
  290. {
  291. public:
  292. virtual Item *create(THD *thd, Item *arg1);
  293. static Create_func_bit_count s_singleton;
  294. protected:
  295. Create_func_bit_count() {}
  296. virtual ~Create_func_bit_count() {}
  297. };
  298. class Create_func_bit_length : public Create_func_arg1
  299. {
  300. public:
  301. virtual Item *create(THD *thd, Item *arg1);
  302. static Create_func_bit_length s_singleton;
  303. protected:
  304. Create_func_bit_length() {}
  305. virtual ~Create_func_bit_length() {}
  306. };
  307. class Create_func_ceiling : public Create_func_arg1
  308. {
  309. public:
  310. virtual Item *create(THD *thd, Item *arg1);
  311. static Create_func_ceiling s_singleton;
  312. protected:
  313. Create_func_ceiling() {}
  314. virtual ~Create_func_ceiling() {}
  315. };
  316. #ifdef HAVE_SPATIAL
  317. class Create_func_centroid : public Create_func_arg1
  318. {
  319. public:
  320. virtual Item *create(THD *thd, Item *arg1);
  321. static Create_func_centroid s_singleton;
  322. protected:
  323. Create_func_centroid() {}
  324. virtual ~Create_func_centroid() {}
  325. };
  326. #endif
  327. class Create_func_char_length : public Create_func_arg1
  328. {
  329. public:
  330. virtual Item *create(THD *thd, Item *arg1);
  331. static Create_func_char_length s_singleton;
  332. protected:
  333. Create_func_char_length() {}
  334. virtual ~Create_func_char_length() {}
  335. };
  336. class Create_func_coercibility : public Create_func_arg1
  337. {
  338. public:
  339. virtual Item *create(THD *thd, Item *arg1);
  340. static Create_func_coercibility s_singleton;
  341. protected:
  342. Create_func_coercibility() {}
  343. virtual ~Create_func_coercibility() {}
  344. };
  345. class Create_func_compress : public Create_func_arg1
  346. {
  347. public:
  348. virtual Item *create(THD *thd, Item *arg1);
  349. static Create_func_compress s_singleton;
  350. protected:
  351. Create_func_compress() {}
  352. virtual ~Create_func_compress() {}
  353. };
  354. class Create_func_concat : public Create_native_func
  355. {
  356. public:
  357. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  358. static Create_func_concat s_singleton;
  359. protected:
  360. Create_func_concat() {}
  361. virtual ~Create_func_concat() {}
  362. };
  363. class Create_func_concat_ws : public Create_native_func
  364. {
  365. public:
  366. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  367. static Create_func_concat_ws s_singleton;
  368. protected:
  369. Create_func_concat_ws() {}
  370. virtual ~Create_func_concat_ws() {}
  371. };
  372. class Create_func_connection_id : public Create_func_arg0
  373. {
  374. public:
  375. virtual Item *create(THD *thd);
  376. static Create_func_connection_id s_singleton;
  377. protected:
  378. Create_func_connection_id() {}
  379. virtual ~Create_func_connection_id() {}
  380. };
  381. #ifdef HAVE_SPATIAL
  382. class Create_func_contains : public Create_func_arg2
  383. {
  384. public:
  385. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  386. static Create_func_contains s_singleton;
  387. protected:
  388. Create_func_contains() {}
  389. virtual ~Create_func_contains() {}
  390. };
  391. #endif
  392. class Create_func_conv : public Create_func_arg3
  393. {
  394. public:
  395. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  396. static Create_func_conv s_singleton;
  397. protected:
  398. Create_func_conv() {}
  399. virtual ~Create_func_conv() {}
  400. };
  401. class Create_func_convert_tz : public Create_func_arg3
  402. {
  403. public:
  404. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  405. static Create_func_convert_tz s_singleton;
  406. protected:
  407. Create_func_convert_tz() {}
  408. virtual ~Create_func_convert_tz() {}
  409. };
  410. class Create_func_cos : public Create_func_arg1
  411. {
  412. public:
  413. virtual Item *create(THD *thd, Item *arg1);
  414. static Create_func_cos s_singleton;
  415. protected:
  416. Create_func_cos() {}
  417. virtual ~Create_func_cos() {}
  418. };
  419. class Create_func_cot : public Create_func_arg1
  420. {
  421. public:
  422. virtual Item *create(THD *thd, Item *arg1);
  423. static Create_func_cot s_singleton;
  424. protected:
  425. Create_func_cot() {}
  426. virtual ~Create_func_cot() {}
  427. };
  428. class Create_func_crc32 : public Create_func_arg1
  429. {
  430. public:
  431. virtual Item *create(THD *thd, Item *arg1);
  432. static Create_func_crc32 s_singleton;
  433. protected:
  434. Create_func_crc32() {}
  435. virtual ~Create_func_crc32() {}
  436. };
  437. #ifdef HAVE_SPATIAL
  438. class Create_func_crosses : public Create_func_arg2
  439. {
  440. public:
  441. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  442. static Create_func_crosses s_singleton;
  443. protected:
  444. Create_func_crosses() {}
  445. virtual ~Create_func_crosses() {}
  446. };
  447. #endif
  448. class Create_func_date_format : public Create_func_arg2
  449. {
  450. public:
  451. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  452. static Create_func_date_format s_singleton;
  453. protected:
  454. Create_func_date_format() {}
  455. virtual ~Create_func_date_format() {}
  456. };
  457. class Create_func_datediff : public Create_func_arg2
  458. {
  459. public:
  460. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  461. static Create_func_datediff s_singleton;
  462. protected:
  463. Create_func_datediff() {}
  464. virtual ~Create_func_datediff() {}
  465. };
  466. class Create_func_dayname : public Create_func_arg1
  467. {
  468. public:
  469. virtual Item *create(THD *thd, Item *arg1);
  470. static Create_func_dayname s_singleton;
  471. protected:
  472. Create_func_dayname() {}
  473. virtual ~Create_func_dayname() {}
  474. };
  475. class Create_func_dayofmonth : public Create_func_arg1
  476. {
  477. public:
  478. virtual Item *create(THD *thd, Item *arg1);
  479. static Create_func_dayofmonth s_singleton;
  480. protected:
  481. Create_func_dayofmonth() {}
  482. virtual ~Create_func_dayofmonth() {}
  483. };
  484. class Create_func_dayofweek : public Create_func_arg1
  485. {
  486. public:
  487. virtual Item *create(THD *thd, Item *arg1);
  488. static Create_func_dayofweek s_singleton;
  489. protected:
  490. Create_func_dayofweek() {}
  491. virtual ~Create_func_dayofweek() {}
  492. };
  493. class Create_func_dayofyear : public Create_func_arg1
  494. {
  495. public:
  496. virtual Item *create(THD *thd, Item *arg1);
  497. static Create_func_dayofyear s_singleton;
  498. protected:
  499. Create_func_dayofyear() {}
  500. virtual ~Create_func_dayofyear() {}
  501. };
  502. class Create_func_decode : public Create_func_arg2
  503. {
  504. public:
  505. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  506. static Create_func_decode s_singleton;
  507. protected:
  508. Create_func_decode() {}
  509. virtual ~Create_func_decode() {}
  510. };
  511. class Create_func_degrees : public Create_func_arg1
  512. {
  513. public:
  514. virtual Item *create(THD *thd, Item *arg1);
  515. static Create_func_degrees s_singleton;
  516. protected:
  517. Create_func_degrees() {}
  518. virtual ~Create_func_degrees() {}
  519. };
  520. class Create_func_des_decrypt : public Create_native_func
  521. {
  522. public:
  523. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  524. static Create_func_des_decrypt s_singleton;
  525. protected:
  526. Create_func_des_decrypt() {}
  527. virtual ~Create_func_des_decrypt() {}
  528. };
  529. class Create_func_des_encrypt : public Create_native_func
  530. {
  531. public:
  532. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  533. static Create_func_des_encrypt s_singleton;
  534. protected:
  535. Create_func_des_encrypt() {}
  536. virtual ~Create_func_des_encrypt() {}
  537. };
  538. #ifdef HAVE_SPATIAL
  539. class Create_func_dimension : public Create_func_arg1
  540. {
  541. public:
  542. virtual Item *create(THD *thd, Item *arg1);
  543. static Create_func_dimension s_singleton;
  544. protected:
  545. Create_func_dimension() {}
  546. virtual ~Create_func_dimension() {}
  547. };
  548. #endif
  549. #ifdef HAVE_SPATIAL
  550. class Create_func_disjoint : public Create_func_arg2
  551. {
  552. public:
  553. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  554. static Create_func_disjoint s_singleton;
  555. protected:
  556. Create_func_disjoint() {}
  557. virtual ~Create_func_disjoint() {}
  558. };
  559. #endif
  560. class Create_func_elt : public Create_native_func
  561. {
  562. public:
  563. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  564. static Create_func_elt s_singleton;
  565. protected:
  566. Create_func_elt() {}
  567. virtual ~Create_func_elt() {}
  568. };
  569. class Create_func_encode : public Create_func_arg2
  570. {
  571. public:
  572. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  573. static Create_func_encode s_singleton;
  574. protected:
  575. Create_func_encode() {}
  576. virtual ~Create_func_encode() {}
  577. };
  578. class Create_func_encrypt : public Create_native_func
  579. {
  580. public:
  581. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  582. static Create_func_encrypt s_singleton;
  583. protected:
  584. Create_func_encrypt() {}
  585. virtual ~Create_func_encrypt() {}
  586. };
  587. #ifdef HAVE_SPATIAL
  588. class Create_func_endpoint : public Create_func_arg1
  589. {
  590. public:
  591. virtual Item *create(THD *thd, Item *arg1);
  592. static Create_func_endpoint s_singleton;
  593. protected:
  594. Create_func_endpoint() {}
  595. virtual ~Create_func_endpoint() {}
  596. };
  597. #endif
  598. #ifdef HAVE_SPATIAL
  599. class Create_func_envelope : public Create_func_arg1
  600. {
  601. public:
  602. virtual Item *create(THD *thd, Item *arg1);
  603. static Create_func_envelope s_singleton;
  604. protected:
  605. Create_func_envelope() {}
  606. virtual ~Create_func_envelope() {}
  607. };
  608. #endif
  609. #ifdef HAVE_SPATIAL
  610. class Create_func_equals : public Create_func_arg2
  611. {
  612. public:
  613. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  614. static Create_func_equals s_singleton;
  615. protected:
  616. Create_func_equals() {}
  617. virtual ~Create_func_equals() {}
  618. };
  619. #endif
  620. class Create_func_exp : public Create_func_arg1
  621. {
  622. public:
  623. virtual Item *create(THD *thd, Item *arg1);
  624. static Create_func_exp s_singleton;
  625. protected:
  626. Create_func_exp() {}
  627. virtual ~Create_func_exp() {}
  628. };
  629. class Create_func_export_set : public Create_native_func
  630. {
  631. public:
  632. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  633. static Create_func_export_set s_singleton;
  634. protected:
  635. Create_func_export_set() {}
  636. virtual ~Create_func_export_set() {}
  637. };
  638. #ifdef HAVE_SPATIAL
  639. class Create_func_exteriorring : public Create_func_arg1
  640. {
  641. public:
  642. virtual Item *create(THD *thd, Item *arg1);
  643. static Create_func_exteriorring s_singleton;
  644. protected:
  645. Create_func_exteriorring() {}
  646. virtual ~Create_func_exteriorring() {}
  647. };
  648. #endif
  649. class Create_func_field : public Create_native_func
  650. {
  651. public:
  652. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  653. static Create_func_field s_singleton;
  654. protected:
  655. Create_func_field() {}
  656. virtual ~Create_func_field() {}
  657. };
  658. class Create_func_find_in_set : public Create_func_arg2
  659. {
  660. public:
  661. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  662. static Create_func_find_in_set s_singleton;
  663. protected:
  664. Create_func_find_in_set() {}
  665. virtual ~Create_func_find_in_set() {}
  666. };
  667. class Create_func_floor : public Create_func_arg1
  668. {
  669. public:
  670. virtual Item *create(THD *thd, Item *arg1);
  671. static Create_func_floor s_singleton;
  672. protected:
  673. Create_func_floor() {}
  674. virtual ~Create_func_floor() {}
  675. };
  676. class Create_func_format : public Create_func_arg2
  677. {
  678. public:
  679. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  680. static Create_func_format s_singleton;
  681. protected:
  682. Create_func_format() {}
  683. virtual ~Create_func_format() {}
  684. };
  685. class Create_func_found_rows : public Create_func_arg0
  686. {
  687. public:
  688. virtual Item *create(THD *thd);
  689. static Create_func_found_rows s_singleton;
  690. protected:
  691. Create_func_found_rows() {}
  692. virtual ~Create_func_found_rows() {}
  693. };
  694. class Create_func_from_days : public Create_func_arg1
  695. {
  696. public:
  697. virtual Item *create(THD *thd, Item *arg1);
  698. static Create_func_from_days s_singleton;
  699. protected:
  700. Create_func_from_days() {}
  701. virtual ~Create_func_from_days() {}
  702. };
  703. class Create_func_from_unixtime : public Create_native_func
  704. {
  705. public:
  706. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  707. static Create_func_from_unixtime s_singleton;
  708. protected:
  709. Create_func_from_unixtime() {}
  710. virtual ~Create_func_from_unixtime() {}
  711. };
  712. #ifdef HAVE_SPATIAL
  713. class Create_func_geometry_from_text : public Create_native_func
  714. {
  715. public:
  716. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  717. static Create_func_geometry_from_text s_singleton;
  718. protected:
  719. Create_func_geometry_from_text() {}
  720. virtual ~Create_func_geometry_from_text() {}
  721. };
  722. #endif
  723. #ifdef HAVE_SPATIAL
  724. class Create_func_geometry_from_wkb : public Create_native_func
  725. {
  726. public:
  727. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  728. static Create_func_geometry_from_wkb s_singleton;
  729. protected:
  730. Create_func_geometry_from_wkb() {}
  731. virtual ~Create_func_geometry_from_wkb() {}
  732. };
  733. #endif
  734. #ifdef HAVE_SPATIAL
  735. class Create_func_geometry_type : public Create_func_arg1
  736. {
  737. public:
  738. virtual Item *create(THD *thd, Item *arg1);
  739. static Create_func_geometry_type s_singleton;
  740. protected:
  741. Create_func_geometry_type() {}
  742. virtual ~Create_func_geometry_type() {}
  743. };
  744. #endif
  745. #ifdef HAVE_SPATIAL
  746. class Create_func_geometryn : public Create_func_arg2
  747. {
  748. public:
  749. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  750. static Create_func_geometryn s_singleton;
  751. protected:
  752. Create_func_geometryn() {}
  753. virtual ~Create_func_geometryn() {}
  754. };
  755. #endif
  756. class Create_func_get_lock : public Create_func_arg2
  757. {
  758. public:
  759. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  760. static Create_func_get_lock s_singleton;
  761. protected:
  762. Create_func_get_lock() {}
  763. virtual ~Create_func_get_lock() {}
  764. };
  765. #ifdef HAVE_SPATIAL
  766. class Create_func_glength : public Create_func_arg1
  767. {
  768. public:
  769. virtual Item *create(THD *thd, Item *arg1);
  770. static Create_func_glength s_singleton;
  771. protected:
  772. Create_func_glength() {}
  773. virtual ~Create_func_glength() {}
  774. };
  775. #endif
  776. class Create_func_greatest : public Create_native_func
  777. {
  778. public:
  779. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  780. static Create_func_greatest s_singleton;
  781. protected:
  782. Create_func_greatest() {}
  783. virtual ~Create_func_greatest() {}
  784. };
  785. class Create_func_hex : public Create_func_arg1
  786. {
  787. public:
  788. virtual Item *create(THD *thd, Item *arg1);
  789. static Create_func_hex s_singleton;
  790. protected:
  791. Create_func_hex() {}
  792. virtual ~Create_func_hex() {}
  793. };
  794. class Create_func_ifnull : public Create_func_arg2
  795. {
  796. public:
  797. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  798. static Create_func_ifnull s_singleton;
  799. protected:
  800. Create_func_ifnull() {}
  801. virtual ~Create_func_ifnull() {}
  802. };
  803. class Create_func_inet_ntoa : public Create_func_arg1
  804. {
  805. public:
  806. virtual Item *create(THD *thd, Item *arg1);
  807. static Create_func_inet_ntoa s_singleton;
  808. protected:
  809. Create_func_inet_ntoa() {}
  810. virtual ~Create_func_inet_ntoa() {}
  811. };
  812. class Create_func_inet_aton : public Create_func_arg1
  813. {
  814. public:
  815. virtual Item *create(THD *thd, Item *arg1);
  816. static Create_func_inet_aton s_singleton;
  817. protected:
  818. Create_func_inet_aton() {}
  819. virtual ~Create_func_inet_aton() {}
  820. };
  821. class Create_func_instr : public Create_func_arg2
  822. {
  823. public:
  824. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  825. static Create_func_instr s_singleton;
  826. protected:
  827. Create_func_instr() {}
  828. virtual ~Create_func_instr() {}
  829. };
  830. #ifdef HAVE_SPATIAL
  831. class Create_func_interiorringn : public Create_func_arg2
  832. {
  833. public:
  834. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  835. static Create_func_interiorringn s_singleton;
  836. protected:
  837. Create_func_interiorringn() {}
  838. virtual ~Create_func_interiorringn() {}
  839. };
  840. #endif
  841. #ifdef HAVE_SPATIAL
  842. class Create_func_intersects : public Create_func_arg2
  843. {
  844. public:
  845. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  846. static Create_func_intersects s_singleton;
  847. protected:
  848. Create_func_intersects() {}
  849. virtual ~Create_func_intersects() {}
  850. };
  851. #endif
  852. class Create_func_is_free_lock : public Create_func_arg1
  853. {
  854. public:
  855. virtual Item *create(THD *thd, Item *arg1);
  856. static Create_func_is_free_lock s_singleton;
  857. protected:
  858. Create_func_is_free_lock() {}
  859. virtual ~Create_func_is_free_lock() {}
  860. };
  861. class Create_func_is_used_lock : public Create_func_arg1
  862. {
  863. public:
  864. virtual Item *create(THD *thd, Item *arg1);
  865. static Create_func_is_used_lock s_singleton;
  866. protected:
  867. Create_func_is_used_lock() {}
  868. virtual ~Create_func_is_used_lock() {}
  869. };
  870. #ifdef HAVE_SPATIAL
  871. class Create_func_isclosed : public Create_func_arg1
  872. {
  873. public:
  874. virtual Item *create(THD *thd, Item *arg1);
  875. static Create_func_isclosed s_singleton;
  876. protected:
  877. Create_func_isclosed() {}
  878. virtual ~Create_func_isclosed() {}
  879. };
  880. #endif
  881. #ifdef HAVE_SPATIAL
  882. class Create_func_isempty : public Create_func_arg1
  883. {
  884. public:
  885. virtual Item *create(THD *thd, Item *arg1);
  886. static Create_func_isempty s_singleton;
  887. protected:
  888. Create_func_isempty() {}
  889. virtual ~Create_func_isempty() {}
  890. };
  891. #endif
  892. class Create_func_isnull : public Create_func_arg1
  893. {
  894. public:
  895. virtual Item *create(THD *thd, Item *arg1);
  896. static Create_func_isnull s_singleton;
  897. protected:
  898. Create_func_isnull() {}
  899. virtual ~Create_func_isnull() {}
  900. };
  901. #ifdef HAVE_SPATIAL
  902. class Create_func_issimple : public Create_func_arg1
  903. {
  904. public:
  905. virtual Item *create(THD *thd, Item *arg1);
  906. static Create_func_issimple s_singleton;
  907. protected:
  908. Create_func_issimple() {}
  909. virtual ~Create_func_issimple() {}
  910. };
  911. #endif
  912. class Create_func_last_day : public Create_func_arg1
  913. {
  914. public:
  915. virtual Item *create(THD *thd, Item *arg1);
  916. static Create_func_last_day s_singleton;
  917. protected:
  918. Create_func_last_day() {}
  919. virtual ~Create_func_last_day() {}
  920. };
  921. class Create_func_last_insert_id : public Create_native_func
  922. {
  923. public:
  924. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  925. static Create_func_last_insert_id s_singleton;
  926. protected:
  927. Create_func_last_insert_id() {}
  928. virtual ~Create_func_last_insert_id() {}
  929. };
  930. class Create_func_lcase : public Create_func_arg1
  931. {
  932. public:
  933. virtual Item *create(THD *thd, Item *arg1);
  934. static Create_func_lcase s_singleton;
  935. protected:
  936. Create_func_lcase() {}
  937. virtual ~Create_func_lcase() {}
  938. };
  939. class Create_func_least : public Create_native_func
  940. {
  941. public:
  942. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  943. static Create_func_least s_singleton;
  944. protected:
  945. Create_func_least() {}
  946. virtual ~Create_func_least() {}
  947. };
  948. class Create_func_length : public Create_func_arg1
  949. {
  950. public:
  951. virtual Item *create(THD *thd, Item *arg1);
  952. static Create_func_length s_singleton;
  953. protected:
  954. Create_func_length() {}
  955. virtual ~Create_func_length() {}
  956. };
  957. class Create_func_ln : public Create_func_arg1
  958. {
  959. public:
  960. virtual Item *create(THD *thd, Item *arg1);
  961. static Create_func_ln s_singleton;
  962. protected:
  963. Create_func_ln() {}
  964. virtual ~Create_func_ln() {}
  965. };
  966. class Create_func_load_file : public Create_func_arg1
  967. {
  968. public:
  969. virtual Item *create(THD *thd, Item *arg1);
  970. static Create_func_load_file s_singleton;
  971. protected:
  972. Create_func_load_file() {}
  973. virtual ~Create_func_load_file() {}
  974. };
  975. class Create_func_locate : public Create_native_func
  976. {
  977. public:
  978. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  979. static Create_func_locate s_singleton;
  980. protected:
  981. Create_func_locate() {}
  982. virtual ~Create_func_locate() {}
  983. };
  984. class Create_func_log : public Create_native_func
  985. {
  986. public:
  987. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  988. static Create_func_log s_singleton;
  989. protected:
  990. Create_func_log() {}
  991. virtual ~Create_func_log() {}
  992. };
  993. class Create_func_log10 : public Create_func_arg1
  994. {
  995. public:
  996. virtual Item *create(THD *thd, Item *arg1);
  997. static Create_func_log10 s_singleton;
  998. protected:
  999. Create_func_log10() {}
  1000. virtual ~Create_func_log10() {}
  1001. };
  1002. class Create_func_log2 : public Create_func_arg1
  1003. {
  1004. public:
  1005. virtual Item *create(THD *thd, Item *arg1);
  1006. static Create_func_log2 s_singleton;
  1007. protected:
  1008. Create_func_log2() {}
  1009. virtual ~Create_func_log2() {}
  1010. };
  1011. class Create_func_lpad : public Create_func_arg3
  1012. {
  1013. public:
  1014. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  1015. static Create_func_lpad s_singleton;
  1016. protected:
  1017. Create_func_lpad() {}
  1018. virtual ~Create_func_lpad() {}
  1019. };
  1020. class Create_func_ltrim : public Create_func_arg1
  1021. {
  1022. public:
  1023. virtual Item *create(THD *thd, Item *arg1);
  1024. static Create_func_ltrim s_singleton;
  1025. protected:
  1026. Create_func_ltrim() {}
  1027. virtual ~Create_func_ltrim() {}
  1028. };
  1029. class Create_func_makedate : public Create_func_arg2
  1030. {
  1031. public:
  1032. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1033. static Create_func_makedate s_singleton;
  1034. protected:
  1035. Create_func_makedate() {}
  1036. virtual ~Create_func_makedate() {}
  1037. };
  1038. class Create_func_maketime : public Create_func_arg3
  1039. {
  1040. public:
  1041. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  1042. static Create_func_maketime s_singleton;
  1043. protected:
  1044. Create_func_maketime() {}
  1045. virtual ~Create_func_maketime() {}
  1046. };
  1047. class Create_func_make_set : public Create_native_func
  1048. {
  1049. public:
  1050. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1051. static Create_func_make_set s_singleton;
  1052. protected:
  1053. Create_func_make_set() {}
  1054. virtual ~Create_func_make_set() {}
  1055. };
  1056. class Create_func_master_pos_wait : public Create_native_func
  1057. {
  1058. public:
  1059. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1060. static Create_func_master_pos_wait s_singleton;
  1061. protected:
  1062. Create_func_master_pos_wait() {}
  1063. virtual ~Create_func_master_pos_wait() {}
  1064. };
  1065. class Create_func_md5 : public Create_func_arg1
  1066. {
  1067. public:
  1068. virtual Item *create(THD *thd, Item *arg1);
  1069. static Create_func_md5 s_singleton;
  1070. protected:
  1071. Create_func_md5() {}
  1072. virtual ~Create_func_md5() {}
  1073. };
  1074. class Create_func_monthname : public Create_func_arg1
  1075. {
  1076. public:
  1077. virtual Item *create(THD *thd, Item *arg1);
  1078. static Create_func_monthname s_singleton;
  1079. protected:
  1080. Create_func_monthname() {}
  1081. virtual ~Create_func_monthname() {}
  1082. };
  1083. class Create_func_name_const : public Create_func_arg2
  1084. {
  1085. public:
  1086. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1087. static Create_func_name_const s_singleton;
  1088. protected:
  1089. Create_func_name_const() {}
  1090. virtual ~Create_func_name_const() {}
  1091. };
  1092. class Create_func_nullif : public Create_func_arg2
  1093. {
  1094. public:
  1095. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1096. static Create_func_nullif s_singleton;
  1097. protected:
  1098. Create_func_nullif() {}
  1099. virtual ~Create_func_nullif() {}
  1100. };
  1101. #ifdef HAVE_SPATIAL
  1102. class Create_func_numgeometries : public Create_func_arg1
  1103. {
  1104. public:
  1105. virtual Item *create(THD *thd, Item *arg1);
  1106. static Create_func_numgeometries s_singleton;
  1107. protected:
  1108. Create_func_numgeometries() {}
  1109. virtual ~Create_func_numgeometries() {}
  1110. };
  1111. #endif
  1112. #ifdef HAVE_SPATIAL
  1113. class Create_func_numinteriorring : public Create_func_arg1
  1114. {
  1115. public:
  1116. virtual Item *create(THD *thd, Item *arg1);
  1117. static Create_func_numinteriorring s_singleton;
  1118. protected:
  1119. Create_func_numinteriorring() {}
  1120. virtual ~Create_func_numinteriorring() {}
  1121. };
  1122. #endif
  1123. #ifdef HAVE_SPATIAL
  1124. class Create_func_numpoints : public Create_func_arg1
  1125. {
  1126. public:
  1127. virtual Item *create(THD *thd, Item *arg1);
  1128. static Create_func_numpoints s_singleton;
  1129. protected:
  1130. Create_func_numpoints() {}
  1131. virtual ~Create_func_numpoints() {}
  1132. };
  1133. #endif
  1134. class Create_func_oct : public Create_func_arg1
  1135. {
  1136. public:
  1137. virtual Item *create(THD *thd, Item *arg1);
  1138. static Create_func_oct s_singleton;
  1139. protected:
  1140. Create_func_oct() {}
  1141. virtual ~Create_func_oct() {}
  1142. };
  1143. class Create_func_ord : public Create_func_arg1
  1144. {
  1145. public:
  1146. virtual Item *create(THD *thd, Item *arg1);
  1147. static Create_func_ord s_singleton;
  1148. protected:
  1149. Create_func_ord() {}
  1150. virtual ~Create_func_ord() {}
  1151. };
  1152. #ifdef HAVE_SPATIAL
  1153. class Create_func_overlaps : public Create_func_arg2
  1154. {
  1155. public:
  1156. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1157. static Create_func_overlaps s_singleton;
  1158. protected:
  1159. Create_func_overlaps() {}
  1160. virtual ~Create_func_overlaps() {}
  1161. };
  1162. #endif
  1163. class Create_func_period_add : public Create_func_arg2
  1164. {
  1165. public:
  1166. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1167. static Create_func_period_add s_singleton;
  1168. protected:
  1169. Create_func_period_add() {}
  1170. virtual ~Create_func_period_add() {}
  1171. };
  1172. class Create_func_period_diff : public Create_func_arg2
  1173. {
  1174. public:
  1175. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1176. static Create_func_period_diff s_singleton;
  1177. protected:
  1178. Create_func_period_diff() {}
  1179. virtual ~Create_func_period_diff() {}
  1180. };
  1181. class Create_func_pi : public Create_func_arg0
  1182. {
  1183. public:
  1184. virtual Item *create(THD *thd);
  1185. static Create_func_pi s_singleton;
  1186. protected:
  1187. Create_func_pi() {}
  1188. virtual ~Create_func_pi() {}
  1189. };
  1190. #ifdef HAVE_SPATIAL
  1191. class Create_func_pointn : public Create_func_arg2
  1192. {
  1193. public:
  1194. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1195. static Create_func_pointn s_singleton;
  1196. protected:
  1197. Create_func_pointn() {}
  1198. virtual ~Create_func_pointn() {}
  1199. };
  1200. #endif
  1201. class Create_func_pow : public Create_func_arg2
  1202. {
  1203. public:
  1204. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1205. static Create_func_pow s_singleton;
  1206. protected:
  1207. Create_func_pow() {}
  1208. virtual ~Create_func_pow() {}
  1209. };
  1210. class Create_func_quote : public Create_func_arg1
  1211. {
  1212. public:
  1213. virtual Item *create(THD *thd, Item *arg1);
  1214. static Create_func_quote s_singleton;
  1215. protected:
  1216. Create_func_quote() {}
  1217. virtual ~Create_func_quote() {}
  1218. };
  1219. class Create_func_radians : public Create_func_arg1
  1220. {
  1221. public:
  1222. virtual Item *create(THD *thd, Item *arg1);
  1223. static Create_func_radians s_singleton;
  1224. protected:
  1225. Create_func_radians() {}
  1226. virtual ~Create_func_radians() {}
  1227. };
  1228. class Create_func_rand : public Create_native_func
  1229. {
  1230. public:
  1231. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1232. static Create_func_rand s_singleton;
  1233. protected:
  1234. Create_func_rand() {}
  1235. virtual ~Create_func_rand() {}
  1236. };
  1237. class Create_func_release_lock : public Create_func_arg1
  1238. {
  1239. public:
  1240. virtual Item *create(THD *thd, Item *arg1);
  1241. static Create_func_release_lock s_singleton;
  1242. protected:
  1243. Create_func_release_lock() {}
  1244. virtual ~Create_func_release_lock() {}
  1245. };
  1246. class Create_func_reverse : public Create_func_arg1
  1247. {
  1248. public:
  1249. virtual Item *create(THD *thd, Item *arg1);
  1250. static Create_func_reverse s_singleton;
  1251. protected:
  1252. Create_func_reverse() {}
  1253. virtual ~Create_func_reverse() {}
  1254. };
  1255. class Create_func_round : public Create_native_func
  1256. {
  1257. public:
  1258. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1259. static Create_func_round s_singleton;
  1260. protected:
  1261. Create_func_round() {}
  1262. virtual ~Create_func_round() {}
  1263. };
  1264. class Create_func_row_count : public Create_func_arg0
  1265. {
  1266. public:
  1267. virtual Item *create(THD *thd);
  1268. static Create_func_row_count s_singleton;
  1269. protected:
  1270. Create_func_row_count() {}
  1271. virtual ~Create_func_row_count() {}
  1272. };
  1273. class Create_func_rpad : public Create_func_arg3
  1274. {
  1275. public:
  1276. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  1277. static Create_func_rpad s_singleton;
  1278. protected:
  1279. Create_func_rpad() {}
  1280. virtual ~Create_func_rpad() {}
  1281. };
  1282. class Create_func_rtrim : public Create_func_arg1
  1283. {
  1284. public:
  1285. virtual Item *create(THD *thd, Item *arg1);
  1286. static Create_func_rtrim s_singleton;
  1287. protected:
  1288. Create_func_rtrim() {}
  1289. virtual ~Create_func_rtrim() {}
  1290. };
  1291. class Create_func_sec_to_time : public Create_func_arg1
  1292. {
  1293. public:
  1294. virtual Item *create(THD *thd, Item *arg1);
  1295. static Create_func_sec_to_time s_singleton;
  1296. protected:
  1297. Create_func_sec_to_time() {}
  1298. virtual ~Create_func_sec_to_time() {}
  1299. };
  1300. class Create_func_sha : public Create_func_arg1
  1301. {
  1302. public:
  1303. virtual Item *create(THD *thd, Item *arg1);
  1304. static Create_func_sha s_singleton;
  1305. protected:
  1306. Create_func_sha() {}
  1307. virtual ~Create_func_sha() {}
  1308. };
  1309. class Create_func_sign : public Create_func_arg1
  1310. {
  1311. public:
  1312. virtual Item *create(THD *thd, Item *arg1);
  1313. static Create_func_sign s_singleton;
  1314. protected:
  1315. Create_func_sign() {}
  1316. virtual ~Create_func_sign() {}
  1317. };
  1318. class Create_func_sin : public Create_func_arg1
  1319. {
  1320. public:
  1321. virtual Item *create(THD *thd, Item *arg1);
  1322. static Create_func_sin s_singleton;
  1323. protected:
  1324. Create_func_sin() {}
  1325. virtual ~Create_func_sin() {}
  1326. };
  1327. class Create_func_sleep : public Create_func_arg1
  1328. {
  1329. public:
  1330. virtual Item *create(THD *thd, Item *arg1);
  1331. static Create_func_sleep s_singleton;
  1332. protected:
  1333. Create_func_sleep() {}
  1334. virtual ~Create_func_sleep() {}
  1335. };
  1336. class Create_func_soundex : public Create_func_arg1
  1337. {
  1338. public:
  1339. virtual Item *create(THD *thd, Item *arg1);
  1340. static Create_func_soundex s_singleton;
  1341. protected:
  1342. Create_func_soundex() {}
  1343. virtual ~Create_func_soundex() {}
  1344. };
  1345. class Create_func_space : public Create_func_arg1
  1346. {
  1347. public:
  1348. virtual Item *create(THD *thd, Item *arg1);
  1349. static Create_func_space s_singleton;
  1350. protected:
  1351. Create_func_space() {}
  1352. virtual ~Create_func_space() {}
  1353. };
  1354. class Create_func_sqrt : public Create_func_arg1
  1355. {
  1356. public:
  1357. virtual Item *create(THD *thd, Item *arg1);
  1358. static Create_func_sqrt s_singleton;
  1359. protected:
  1360. Create_func_sqrt() {}
  1361. virtual ~Create_func_sqrt() {}
  1362. };
  1363. #ifdef HAVE_SPATIAL
  1364. class Create_func_srid : public Create_func_arg1
  1365. {
  1366. public:
  1367. virtual Item *create(THD *thd, Item *arg1);
  1368. static Create_func_srid s_singleton;
  1369. protected:
  1370. Create_func_srid() {}
  1371. virtual ~Create_func_srid() {}
  1372. };
  1373. #endif
  1374. #ifdef HAVE_SPATIAL
  1375. class Create_func_startpoint : public Create_func_arg1
  1376. {
  1377. public:
  1378. virtual Item *create(THD *thd, Item *arg1);
  1379. static Create_func_startpoint s_singleton;
  1380. protected:
  1381. Create_func_startpoint() {}
  1382. virtual ~Create_func_startpoint() {}
  1383. };
  1384. #endif
  1385. class Create_func_str_to_date : public Create_func_arg2
  1386. {
  1387. public:
  1388. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1389. static Create_func_str_to_date s_singleton;
  1390. protected:
  1391. Create_func_str_to_date() {}
  1392. virtual ~Create_func_str_to_date() {}
  1393. };
  1394. class Create_func_strcmp : public Create_func_arg2
  1395. {
  1396. public:
  1397. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1398. static Create_func_strcmp s_singleton;
  1399. protected:
  1400. Create_func_strcmp() {}
  1401. virtual ~Create_func_strcmp() {}
  1402. };
  1403. class Create_func_substr_index : public Create_func_arg3
  1404. {
  1405. public:
  1406. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  1407. static Create_func_substr_index s_singleton;
  1408. protected:
  1409. Create_func_substr_index() {}
  1410. virtual ~Create_func_substr_index() {}
  1411. };
  1412. class Create_func_subtime : public Create_func_arg2
  1413. {
  1414. public:
  1415. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1416. static Create_func_subtime s_singleton;
  1417. protected:
  1418. Create_func_subtime() {}
  1419. virtual ~Create_func_subtime() {}
  1420. };
  1421. class Create_func_tan : public Create_func_arg1
  1422. {
  1423. public:
  1424. virtual Item *create(THD *thd, Item *arg1);
  1425. static Create_func_tan s_singleton;
  1426. protected:
  1427. Create_func_tan() {}
  1428. virtual ~Create_func_tan() {}
  1429. };
  1430. class Create_func_time_format : public Create_func_arg2
  1431. {
  1432. public:
  1433. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1434. static Create_func_time_format s_singleton;
  1435. protected:
  1436. Create_func_time_format() {}
  1437. virtual ~Create_func_time_format() {}
  1438. };
  1439. class Create_func_time_to_sec : public Create_func_arg1
  1440. {
  1441. public:
  1442. virtual Item *create(THD *thd, Item *arg1);
  1443. static Create_func_time_to_sec s_singleton;
  1444. protected:
  1445. Create_func_time_to_sec() {}
  1446. virtual ~Create_func_time_to_sec() {}
  1447. };
  1448. class Create_func_timediff : public Create_func_arg2
  1449. {
  1450. public:
  1451. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1452. static Create_func_timediff s_singleton;
  1453. protected:
  1454. Create_func_timediff() {}
  1455. virtual ~Create_func_timediff() {}
  1456. };
  1457. class Create_func_to_days : public Create_func_arg1
  1458. {
  1459. public:
  1460. virtual Item *create(THD *thd, Item *arg1);
  1461. static Create_func_to_days s_singleton;
  1462. protected:
  1463. Create_func_to_days() {}
  1464. virtual ~Create_func_to_days() {}
  1465. };
  1466. #ifdef HAVE_SPATIAL
  1467. class Create_func_touches : public Create_func_arg2
  1468. {
  1469. public:
  1470. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1471. static Create_func_touches s_singleton;
  1472. protected:
  1473. Create_func_touches() {}
  1474. virtual ~Create_func_touches() {}
  1475. };
  1476. #endif
  1477. class Create_func_ucase : public Create_func_arg1
  1478. {
  1479. public:
  1480. virtual Item *create(THD *thd, Item *arg1);
  1481. static Create_func_ucase s_singleton;
  1482. protected:
  1483. Create_func_ucase() {}
  1484. virtual ~Create_func_ucase() {}
  1485. };
  1486. class Create_func_uncompress : public Create_func_arg1
  1487. {
  1488. public:
  1489. virtual Item *create(THD *thd, Item *arg1);
  1490. static Create_func_uncompress s_singleton;
  1491. protected:
  1492. Create_func_uncompress() {}
  1493. virtual ~Create_func_uncompress() {}
  1494. };
  1495. class Create_func_uncompressed_length : public Create_func_arg1
  1496. {
  1497. public:
  1498. virtual Item *create(THD *thd, Item *arg1);
  1499. static Create_func_uncompressed_length s_singleton;
  1500. protected:
  1501. Create_func_uncompressed_length() {}
  1502. virtual ~Create_func_uncompressed_length() {}
  1503. };
  1504. class Create_func_unhex : public Create_func_arg1
  1505. {
  1506. public:
  1507. virtual Item *create(THD *thd, Item *arg1);
  1508. static Create_func_unhex s_singleton;
  1509. protected:
  1510. Create_func_unhex() {}
  1511. virtual ~Create_func_unhex() {}
  1512. };
  1513. class Create_func_unix_timestamp : public Create_native_func
  1514. {
  1515. public:
  1516. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1517. static Create_func_unix_timestamp s_singleton;
  1518. protected:
  1519. Create_func_unix_timestamp() {}
  1520. virtual ~Create_func_unix_timestamp() {}
  1521. };
  1522. class Create_func_uuid : public Create_func_arg0
  1523. {
  1524. public:
  1525. virtual Item *create(THD *thd);
  1526. static Create_func_uuid s_singleton;
  1527. protected:
  1528. Create_func_uuid() {}
  1529. virtual ~Create_func_uuid() {}
  1530. };
  1531. class Create_func_uuid_short : public Create_func_arg0
  1532. {
  1533. public:
  1534. virtual Item *create(THD *thd);
  1535. static Create_func_uuid_short s_singleton;
  1536. protected:
  1537. Create_func_uuid_short() {}
  1538. virtual ~Create_func_uuid_short() {}
  1539. };
  1540. class Create_func_version : public Create_func_arg0
  1541. {
  1542. public:
  1543. virtual Item *create(THD *thd);
  1544. static Create_func_version s_singleton;
  1545. protected:
  1546. Create_func_version() {}
  1547. virtual ~Create_func_version() {}
  1548. };
  1549. class Create_func_weekday : public Create_func_arg1
  1550. {
  1551. public:
  1552. virtual Item *create(THD *thd, Item *arg1);
  1553. static Create_func_weekday s_singleton;
  1554. protected:
  1555. Create_func_weekday() {}
  1556. virtual ~Create_func_weekday() {}
  1557. };
  1558. class Create_func_weekofyear : public Create_func_arg1
  1559. {
  1560. public:
  1561. virtual Item *create(THD *thd, Item *arg1);
  1562. static Create_func_weekofyear s_singleton;
  1563. protected:
  1564. Create_func_weekofyear() {}
  1565. virtual ~Create_func_weekofyear() {}
  1566. };
  1567. #ifdef HAVE_SPATIAL
  1568. class Create_func_within : public Create_func_arg2
  1569. {
  1570. public:
  1571. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1572. static Create_func_within s_singleton;
  1573. protected:
  1574. Create_func_within() {}
  1575. virtual ~Create_func_within() {}
  1576. };
  1577. #endif
  1578. #ifdef HAVE_SPATIAL
  1579. class Create_func_x : public Create_func_arg1
  1580. {
  1581. public:
  1582. virtual Item *create(THD *thd, Item *arg1);
  1583. static Create_func_x s_singleton;
  1584. protected:
  1585. Create_func_x() {}
  1586. virtual ~Create_func_x() {}
  1587. };
  1588. #endif
  1589. class Create_func_xml_extractvalue : public Create_func_arg2
  1590. {
  1591. public:
  1592. virtual Item *create(THD *thd, Item *arg1, Item *arg2);
  1593. static Create_func_xml_extractvalue s_singleton;
  1594. protected:
  1595. Create_func_xml_extractvalue() {}
  1596. virtual ~Create_func_xml_extractvalue() {}
  1597. };
  1598. class Create_func_xml_update : public Create_func_arg3
  1599. {
  1600. public:
  1601. virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
  1602. static Create_func_xml_update s_singleton;
  1603. protected:
  1604. Create_func_xml_update() {}
  1605. virtual ~Create_func_xml_update() {}
  1606. };
  1607. #ifdef HAVE_SPATIAL
  1608. class Create_func_y : public Create_func_arg1
  1609. {
  1610. public:
  1611. virtual Item *create(THD *thd, Item *arg1);
  1612. static Create_func_y s_singleton;
  1613. protected:
  1614. Create_func_y() {}
  1615. virtual ~Create_func_y() {}
  1616. };
  1617. #endif
  1618. class Create_func_year_week : public Create_native_func
  1619. {
  1620. public:
  1621. virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
  1622. static Create_func_year_week s_singleton;
  1623. protected:
  1624. Create_func_year_week() {}
  1625. virtual ~Create_func_year_week() {}
  1626. };
  1627. /*
  1628. =============================================================================
  1629. IMPLEMENTATION
  1630. =============================================================================
  1631. */
  1632. /**
  1633. Checks if there are named parameters in a parameter list.
  1634. The syntax to name parameters in a function call is as follow:
  1635. <code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
  1636. @param params The parameter list, can be null
  1637. @return true if one or more parameter is named
  1638. */
  1639. static bool has_named_parameters(List<Item> *params)
  1640. {
  1641. if (params)
  1642. {
  1643. Item *param;
  1644. List_iterator<Item> it(*params);
  1645. while ((param= it++))
  1646. {
  1647. if (! param->is_autogenerated_name)
  1648. return true;
  1649. }
  1650. }
  1651. return false;
  1652. }
  1653. #ifndef HAVE_SPATIAL
  1654. Create_func_no_geom Create_func_no_geom::s_singleton;
  1655. Item*
  1656. Create_func_no_geom::create_func(THD * /* unused */,
  1657. LEX_STRING /* unused */,
  1658. List<Item> * /* unused */)
  1659. {
  1660. /* FIXME: error message can't be translated. */
  1661. my_error(ER_FEATURE_DISABLED, MYF(0),
  1662. sym_group_geom.name, sym_group_geom.needed_define);
  1663. return NULL;
  1664. }
  1665. #endif
  1666. Item*
  1667. Create_qfunc::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
  1668. {
  1669. LEX_STRING db;
  1670. if (! thd->db && ! thd->lex->sphead)
  1671. {
  1672. /*
  1673. The proper error message should be in the lines of:
  1674. Can't resolve <name>() to a function call,
  1675. because this function:
  1676. - is not a native function,
  1677. - is not a user defined function,
  1678. - can not match a qualified (read: stored) function
  1679. since no database is selected.
  1680. Reusing ER_SP_DOES_NOT_EXIST have a message consistent with
  1681. the case when a default database exist, see Create_sp_func::create().
  1682. */
  1683. my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
  1684. "FUNCTION", name.str);
  1685. return NULL;
  1686. }
  1687. if (thd->lex->copy_db_to(&db.str, &db.length))
  1688. return NULL;
  1689. return create(thd, db, name, false, item_list);
  1690. }
  1691. #ifdef HAVE_DLOPEN
  1692. Create_udf_func Create_udf_func::s_singleton;
  1693. Item*
  1694. Create_udf_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
  1695. {
  1696. udf_func *udf= find_udf(name.str, name.length);
  1697. DBUG_ASSERT(udf);
  1698. return create(thd, udf, item_list);
  1699. }
  1700. Item*
  1701. Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
  1702. {
  1703. Item *func= NULL;
  1704. int arg_count= 0;
  1705. if (item_list != NULL)
  1706. arg_count= item_list->elements;
  1707. thd->lex->set_stmt_unsafe();
  1708. DBUG_ASSERT( (udf->type == UDFTYPE_FUNCTION)
  1709. || (udf->type == UDFTYPE_AGGREGATE));
  1710. switch(udf->returns) {
  1711. case STRING_RESULT:
  1712. {
  1713. if (udf->type == UDFTYPE_FUNCTION)
  1714. {
  1715. if (arg_count)
  1716. func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
  1717. else
  1718. func= new (thd->mem_root) Item_func_udf_str(udf);
  1719. }
  1720. else
  1721. {
  1722. if (arg_count)
  1723. func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
  1724. else
  1725. func= new (thd->mem_root) Item_sum_udf_str(udf);
  1726. }
  1727. break;
  1728. }
  1729. case REAL_RESULT:
  1730. {
  1731. if (udf->type == UDFTYPE_FUNCTION)
  1732. {
  1733. if (arg_count)
  1734. func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
  1735. else
  1736. func= new (thd->mem_root) Item_func_udf_float(udf);
  1737. }
  1738. else
  1739. {
  1740. if (arg_count)
  1741. func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
  1742. else
  1743. func= new (thd->mem_root) Item_sum_udf_float(udf);
  1744. }
  1745. break;
  1746. }
  1747. case INT_RESULT:
  1748. {
  1749. if (udf->type == UDFTYPE_FUNCTION)
  1750. {
  1751. if (arg_count)
  1752. func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
  1753. else
  1754. func= new (thd->mem_root) Item_func_udf_int(udf);
  1755. }
  1756. else
  1757. {
  1758. if (arg_count)
  1759. func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
  1760. else
  1761. func= new (thd->mem_root) Item_sum_udf_int(udf);
  1762. }
  1763. break;
  1764. }
  1765. case DECIMAL_RESULT:
  1766. {
  1767. if (udf->type == UDFTYPE_FUNCTION)
  1768. {
  1769. if (arg_count)
  1770. func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
  1771. else
  1772. func= new (thd->mem_root) Item_func_udf_decimal(udf);
  1773. }
  1774. else
  1775. {
  1776. if (arg_count)
  1777. func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
  1778. else
  1779. func= new (thd->mem_root) Item_sum_udf_decimal(udf);
  1780. }
  1781. break;
  1782. }
  1783. default:
  1784. {
  1785. my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
  1786. }
  1787. }
  1788. thd->lex->safe_to_cache_query= 0;
  1789. return func;
  1790. }
  1791. #endif
  1792. Create_sp_func Create_sp_func::s_singleton;
  1793. Item*
  1794. Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name,
  1795. bool use_explicit_name, List<Item> *item_list)
  1796. {
  1797. int arg_count= 0;
  1798. Item *func= NULL;
  1799. LEX *lex= thd->lex;
  1800. sp_name *qname;
  1801. if (has_named_parameters(item_list))
  1802. {
  1803. /*
  1804. The syntax "db.foo(expr AS p1, expr AS p2, ...) is invalid,
  1805. and has been rejected during syntactic parsing already,
  1806. because a stored function call may not have named parameters.
  1807. The syntax "foo(expr AS p1, expr AS p2, ...)" is correct,
  1808. because it can refer to a User Defined Function call.
  1809. For a Stored Function however, this has no semantic.
  1810. */
  1811. my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name.str);
  1812. return NULL;
  1813. }
  1814. if (item_list != NULL)
  1815. arg_count= item_list->elements;
  1816. qname= new (thd->mem_root) sp_name(db, name, use_explicit_name);
  1817. qname->init_qname(thd);
  1818. sp_add_used_routine(lex, thd, qname, TYPE_ENUM_FUNCTION);
  1819. if (arg_count > 0)
  1820. func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname,
  1821. *item_list);
  1822. else
  1823. func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname);
  1824. lex->safe_to_cache_query= 0;
  1825. return func;
  1826. }
  1827. Item*
  1828. Create_native_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
  1829. {
  1830. if (has_named_parameters(item_list))
  1831. {
  1832. my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
  1833. return NULL;
  1834. }
  1835. return create_native(thd, name, item_list);
  1836. }
  1837. Item*
  1838. Create_func_arg0::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
  1839. {
  1840. int arg_count= 0;
  1841. if (item_list != NULL)
  1842. arg_count= item_list->elements;
  1843. if (arg_count != 0)
  1844. {
  1845. my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0)