~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Monty Taylor
  • Date: 2010-04-22 02:46:23 UTC
  • mto: (1497.3.4 enable-dtrace)
  • mto: This revision was merged to the branch mainline in revision 1527.
  • Revision ID: mordred@inaugust.com-20100422024623-4urw8fi8eraci08p
Don't overwrite the pandora_vc_revinfo file if we don't have new
authoratative information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/**
17
17
  @file
25
25
#include <drizzled/item/func.h>
26
26
#include <drizzled/error.h>
27
27
 
28
 
#include "drizzled/function_container.h"
29
 
 
30
28
#include <drizzled/function/str/binary.h>
31
29
#include <drizzled/function/str/concat.h>
32
30
#include <drizzled/function/str/conv.h>
 
31
#include <drizzled/function/str/elt.h>
33
32
#include <drizzled/function/str/export_set.h>
 
33
#include <drizzled/function/str/format.h>
34
34
#include <drizzled/function/str/load_file.h>
35
35
#include <drizzled/function/str/make_set.h>
36
36
#include <drizzled/function/str/pad.h>
61
61
/* Function declarations */
62
62
 
63
63
#include <drizzled/function/func.h>
 
64
#include <drizzled/function/math/abs.h>
 
65
#include <drizzled/function/math/acos.h>
64
66
#include <drizzled/function/additive_op.h>
 
67
#include <drizzled/function/math/asin.h>
 
68
#include <drizzled/function/math/atan.h>
 
69
#include <drizzled/function/math/ceiling.h>
 
70
#include <drizzled/function/coercibility.h>
 
71
#include <drizzled/function/math/cos.h>
65
72
#include <drizzled/function/math/dec.h>
66
73
#include <drizzled/function/math/decimal_typecast.h>
 
74
#include <drizzled/function/math/exp.h>
67
75
#include <drizzled/function/field.h>
68
76
#include <drizzled/function/find_in_set.h>
 
77
#include <drizzled/function/math/floor.h>
69
78
#include <drizzled/function/found_rows.h>
70
79
#include <drizzled/function/get_system_var.h>
71
80
#include <drizzled/function/math/int_val.h>
72
81
#include <drizzled/function/math/integer.h>
73
82
#include <drizzled/function/last_insert.h>
 
83
#include <drizzled/function/math/ln.h>
74
84
#include <drizzled/function/locate.h>
 
85
#include <drizzled/function/math/log.h>
75
86
#include <drizzled/function/min_max.h>
76
87
#include <drizzled/function/num1.h>
77
88
#include <drizzled/function/num_op.h>
78
89
#include <drizzled/function/numhybrid.h>
 
90
#include <drizzled/function/math/ord.h>
 
91
#include <drizzled/function/math/pow.h>
 
92
#include <drizzled/function/math/rand.h>
79
93
#include <drizzled/function/math/real.h>
80
94
#include <drizzled/function/row_count.h>
81
95
#include <drizzled/function/set_user_var.h>
82
96
#include <drizzled/function/sign.h>
 
97
#include <drizzled/function/math/sin.h>
 
98
#include <drizzled/function/math/sqrt.h>
 
99
#include <drizzled/function/str/quote.h>
83
100
#include <drizzled/function/math/tan.h>
84
101
#include <drizzled/function/units.h>
85
102
 
 
103
#include <map>
 
104
 
86
105
using namespace std;
87
106
 
88
107
namespace drizzled
240
259
  it helps to compare code between versions, and helps with merges conflicts.
241
260
*/
242
261
 
 
262
class Create_func_abs : public Create_func_arg1
 
263
{
 
264
public:
 
265
  using Create_func_arg1::create;
 
266
 
 
267
  virtual Item *create(Session *session, Item *arg1);
 
268
 
 
269
  static Create_func_abs s_singleton;
 
270
 
 
271
protected:
 
272
  Create_func_abs() {}
 
273
  virtual ~Create_func_abs() {}
 
274
};
 
275
 
 
276
 
 
277
class Create_func_acos : public Create_func_arg1
 
278
{
 
279
public:
 
280
  using Create_func_arg1::create;
 
281
 
 
282
  virtual Item *create(Session *session, Item *arg1);
 
283
 
 
284
  static Create_func_acos s_singleton;
 
285
 
 
286
protected:
 
287
  Create_func_acos() {}
 
288
  virtual ~Create_func_acos() {}
 
289
};
 
290
 
 
291
class Create_func_asin : public Create_func_arg1
 
292
{
 
293
public:
 
294
  using Create_func_arg1::create;
 
295
 
 
296
  virtual Item *create(Session *session, Item *arg1);
 
297
 
 
298
  static Create_func_asin s_singleton;
 
299
 
 
300
protected:
 
301
  Create_func_asin() {}
 
302
  virtual ~Create_func_asin() {}
 
303
};
 
304
 
 
305
 
 
306
class Create_func_atan : public Create_native_func
 
307
{
 
308
public:
 
309
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
 
310
 
 
311
  static Create_func_atan s_singleton;
 
312
 
 
313
protected:
 
314
  Create_func_atan() {}
 
315
  virtual ~Create_func_atan() {}
 
316
};
243
317
 
244
318
class Create_func_bin : public Create_func_arg1
245
319
{
255
329
  virtual ~Create_func_bin() {}
256
330
};
257
331
 
 
332
 
 
333
class Create_func_ceiling : public Create_func_arg1
 
334
{
 
335
public:
 
336
  using Create_func_arg1::create;
 
337
 
 
338
  virtual Item *create(Session *session, Item *arg1);
 
339
 
 
340
  static Create_func_ceiling s_singleton;
 
341
 
 
342
protected:
 
343
  Create_func_ceiling() {}
 
344
  virtual ~Create_func_ceiling() {}
 
345
};
 
346
 
 
347
 
 
348
class Create_func_coercibility : public Create_func_arg1
 
349
{
 
350
public:
 
351
  using Create_func_arg1::create;
 
352
 
 
353
  virtual Item *create(Session *session, Item *arg1);
 
354
 
 
355
  static Create_func_coercibility s_singleton;
 
356
 
 
357
protected:
 
358
  Create_func_coercibility() {}
 
359
  virtual ~Create_func_coercibility() {}
 
360
};
 
361
 
 
362
 
258
363
class Create_func_concat : public Create_native_func
259
364
{
260
365
public:
295
400
  virtual ~Create_func_conv() {}
296
401
};
297
402
 
 
403
 
 
404
class Create_func_cos : public Create_func_arg1
 
405
{
 
406
public:
 
407
  using Create_func_arg1::create;
 
408
 
 
409
  virtual Item *create(Session *session, Item *arg1);
 
410
 
 
411
  static Create_func_cos s_singleton;
 
412
 
 
413
protected:
 
414
  Create_func_cos() {}
 
415
  virtual ~Create_func_cos() {}
 
416
};
 
417
 
 
418
 
298
419
class Create_func_cot : public Create_func_arg1
299
420
{
300
421
public:
428
549
  virtual ~Create_func_degrees() {}
429
550
};
430
551
 
 
552
 
 
553
class Create_func_elt : public Create_native_func
 
554
{
 
555
public:
 
556
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
 
557
 
 
558
  static Create_func_elt s_singleton;
 
559
 
 
560
protected:
 
561
  Create_func_elt() {}
 
562
  virtual ~Create_func_elt() {}
 
563
};
 
564
 
 
565
 
 
566
class Create_func_exp : public Create_func_arg1
 
567
{
 
568
public:
 
569
  using Create_func_arg1::create;
 
570
 
 
571
  virtual Item *create(Session *session, Item *arg1);
 
572
 
 
573
  static Create_func_exp s_singleton;
 
574
 
 
575
protected:
 
576
  Create_func_exp() {}
 
577
  virtual ~Create_func_exp() {}
 
578
};
 
579
 
 
580
 
431
581
class Create_func_export_set : public Create_native_func
432
582
{
433
 
 
434
583
public:
435
584
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
436
585
 
469
618
  virtual ~Create_func_find_in_set() {}
470
619
};
471
620
 
 
621
 
 
622
class Create_func_floor : public Create_func_arg1
 
623
{
 
624
public:
 
625
  using Create_func_arg1::create;
 
626
 
 
627
  virtual Item *create(Session *session, Item *arg1);
 
628
 
 
629
  static Create_func_floor s_singleton;
 
630
 
 
631
protected:
 
632
  Create_func_floor() {}
 
633
  virtual ~Create_func_floor() {}
 
634
};
 
635
 
 
636
 
 
637
class Create_func_format : public Create_func_arg2
 
638
{
 
639
public:
 
640
  using Create_func_arg2::create;
 
641
 
 
642
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
 
643
 
 
644
  static Create_func_format s_singleton;
 
645
 
 
646
protected:
 
647
  Create_func_format() {}
 
648
  virtual ~Create_func_format() {}
 
649
};
 
650
 
 
651
 
472
652
class Create_func_found_rows : public Create_func_arg0
473
653
{
474
654
public:
625
805
  virtual ~Create_func_least() {}
626
806
};
627
807
 
 
808
 
 
809
class Create_func_ln : public Create_func_arg1
 
810
{
 
811
public:
 
812
  using Create_func_arg1::create;
 
813
 
 
814
  virtual Item *create(Session *session, Item *arg1);
 
815
 
 
816
  static Create_func_ln s_singleton;
 
817
 
 
818
protected:
 
819
  Create_func_ln() {}
 
820
  virtual ~Create_func_ln() {}
 
821
};
 
822
 
 
823
 
628
824
class Create_func_load_file : public Create_func_arg1
629
825
{
630
826
public:
653
849
};
654
850
 
655
851
 
 
852
class Create_func_log : public Create_native_func
 
853
{
 
854
public:
 
855
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
 
856
 
 
857
  static Create_func_log s_singleton;
 
858
 
 
859
protected:
 
860
  Create_func_log() {}
 
861
  virtual ~Create_func_log() {}
 
862
};
 
863
 
 
864
 
 
865
class Create_func_log10 : public Create_func_arg1
 
866
{
 
867
public:
 
868
  using Create_func_arg1::create;
 
869
 
 
870
  virtual Item *create(Session *session, Item *arg1);
 
871
 
 
872
  static Create_func_log10 s_singleton;
 
873
 
 
874
protected:
 
875
  Create_func_log10() {}
 
876
  virtual ~Create_func_log10() {}
 
877
};
 
878
 
 
879
 
 
880
class Create_func_log2 : public Create_func_arg1
 
881
{
 
882
public:
 
883
  using Create_func_arg1::create;
 
884
 
 
885
  virtual Item *create(Session *session, Item *arg1);
 
886
 
 
887
  static Create_func_log2 s_singleton;
 
888
 
 
889
protected:
 
890
  Create_func_log2() {}
 
891
  virtual ~Create_func_log2() {}
 
892
};
 
893
 
 
894
 
656
895
class Create_func_lpad : public Create_func_arg3
657
896
{
658
897
public:
769
1008
  virtual ~Create_func_oct() {}
770
1009
};
771
1010
 
 
1011
 
 
1012
class Create_func_ord : public Create_func_arg1
 
1013
{
 
1014
public:
 
1015
  using Create_func_arg1::create;
 
1016
 
 
1017
  virtual Item *create(Session *session, Item *arg1);
 
1018
 
 
1019
  static Create_func_ord s_singleton;
 
1020
 
 
1021
protected:
 
1022
  Create_func_ord() {}
 
1023
  virtual ~Create_func_ord() {}
 
1024
};
 
1025
 
 
1026
 
772
1027
class Create_func_period_add : public Create_func_arg2
773
1028
{
774
1029
public:
813
1068
  virtual ~Create_func_pi() {}
814
1069
};
815
1070
 
 
1071
 
 
1072
class Create_func_pow : public Create_func_arg2
 
1073
{
 
1074
public:
 
1075
  using Create_func_arg2::create;
 
1076
 
 
1077
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
 
1078
 
 
1079
  static Create_func_pow s_singleton;
 
1080
 
 
1081
protected:
 
1082
  Create_func_pow() {}
 
1083
  virtual ~Create_func_pow() {}
 
1084
};
 
1085
 
 
1086
 
 
1087
class Create_func_quote : public Create_func_arg1
 
1088
{
 
1089
public:
 
1090
  using Create_func_arg1::create;
 
1091
 
 
1092
  virtual Item *create(Session *session, Item *arg1);
 
1093
 
 
1094
  static Create_func_quote s_singleton;
 
1095
 
 
1096
protected:
 
1097
  Create_func_quote() {}
 
1098
  virtual ~Create_func_quote() {}
 
1099
};
 
1100
 
 
1101
 
816
1102
class Create_func_radians : public Create_func_arg1
817
1103
{
818
1104
public:
828
1114
};
829
1115
 
830
1116
 
 
1117
class Create_func_rand : public Create_native_func
 
1118
{
 
1119
public:
 
1120
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
 
1121
 
 
1122
  static Create_func_rand s_singleton;
 
1123
 
 
1124
protected:
 
1125
  Create_func_rand() {}
 
1126
  virtual ~Create_func_rand() {}
 
1127
};
 
1128
 
 
1129
 
831
1130
class Create_func_round : public Create_native_func
832
1131
{
833
1132
public:
899
1198
  virtual ~Create_func_sign() {}
900
1199
};
901
1200
 
 
1201
 
 
1202
class Create_func_sin : public Create_func_arg1
 
1203
{
 
1204
public:
 
1205
  using Create_func_arg1::create;
 
1206
 
 
1207
  virtual Item *create(Session *session, Item *arg1);
 
1208
 
 
1209
  static Create_func_sin s_singleton;
 
1210
 
 
1211
protected:
 
1212
  Create_func_sin() {}
 
1213
  virtual ~Create_func_sin() {}
 
1214
};
 
1215
 
 
1216
 
902
1217
class Create_func_space : public Create_func_arg1
903
1218
{
904
1219
public:
913
1228
  virtual ~Create_func_space() {}
914
1229
};
915
1230
 
 
1231
 
 
1232
class Create_func_sqrt : public Create_func_arg1
 
1233
{
 
1234
public:
 
1235
  using Create_func_arg1::create;
 
1236
 
 
1237
  virtual Item *create(Session *session, Item *arg1);
 
1238
 
 
1239
  static Create_func_sqrt s_singleton;
 
1240
 
 
1241
protected:
 
1242
  Create_func_sqrt() {}
 
1243
  virtual ~Create_func_sqrt() {}
 
1244
};
 
1245
 
 
1246
 
916
1247
class Create_func_strcmp : public Create_func_arg2
917
1248
{
918
1249
public:
1210
1541
  return create(session, param_1, param_2, param_3);
1211
1542
}
1212
1543
 
 
1544
 
 
1545
Create_func_abs Create_func_abs::s_singleton;
 
1546
 
 
1547
Item*
 
1548
Create_func_abs::create(Session *session, Item *arg1)
 
1549
{
 
1550
  return new (session->mem_root) Item_func_abs(arg1);
 
1551
}
 
1552
 
 
1553
 
 
1554
Create_func_acos Create_func_acos::s_singleton;
 
1555
 
 
1556
Item*
 
1557
Create_func_acos::create(Session *session, Item *arg1)
 
1558
{
 
1559
  return new (session->mem_root) Item_func_acos(arg1);
 
1560
}
 
1561
 
 
1562
Create_func_asin Create_func_asin::s_singleton;
 
1563
 
 
1564
Item*
 
1565
Create_func_asin::create(Session *session, Item *arg1)
 
1566
{
 
1567
  return new (session->mem_root) Item_func_asin(arg1);
 
1568
}
 
1569
 
 
1570
 
 
1571
Create_func_atan Create_func_atan::s_singleton;
 
1572
 
 
1573
Item*
 
1574
Create_func_atan::create_native(Session *session, LEX_STRING name,
 
1575
                                List<Item> *item_list)
 
1576
{
 
1577
  Item* func= NULL;
 
1578
  int arg_count= 0;
 
1579
 
 
1580
  if (item_list != NULL)
 
1581
    arg_count= item_list->elements;
 
1582
 
 
1583
  switch (arg_count) {
 
1584
  case 1:
 
1585
  {
 
1586
    Item *param_1= item_list->pop();
 
1587
    func= new (session->mem_root) Item_func_atan(param_1);
 
1588
    break;
 
1589
  }
 
1590
  case 2:
 
1591
  {
 
1592
    Item *param_1= item_list->pop();
 
1593
    Item *param_2= item_list->pop();
 
1594
    func= new (session->mem_root) Item_func_atan(param_1, param_2);
 
1595
    break;
 
1596
  }
 
1597
  default:
 
1598
  {
 
1599
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1600
    break;
 
1601
  }
 
1602
  }
 
1603
 
 
1604
  return func;
 
1605
}
 
1606
 
1213
1607
Create_func_bin Create_func_bin::s_singleton;
1214
1608
 
1215
1609
Item*
1220
1614
  return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1221
1615
}
1222
1616
 
 
1617
 
 
1618
Create_func_ceiling Create_func_ceiling::s_singleton;
 
1619
 
 
1620
Item*
 
1621
Create_func_ceiling::create(Session *session, Item *arg1)
 
1622
{
 
1623
  return new (session->mem_root) Item_func_ceiling(arg1);
 
1624
}
 
1625
 
 
1626
 
 
1627
Create_func_coercibility Create_func_coercibility::s_singleton;
 
1628
 
 
1629
Item*
 
1630
Create_func_coercibility::create(Session *session, Item *arg1)
 
1631
{
 
1632
  return new (session->mem_root) Item_func_coercibility(arg1);
 
1633
}
 
1634
 
 
1635
 
1223
1636
Create_func_concat Create_func_concat::s_singleton;
1224
1637
 
1225
1638
Item*
1237
1650
    return NULL;
1238
1651
  }
1239
1652
 
1240
 
  return new (session->mem_root) Item_func_concat(*session, *item_list);
 
1653
  return new (session->mem_root) Item_func_concat(*item_list);
1241
1654
}
1242
1655
 
1243
1656
 
1259
1672
    return NULL;
1260
1673
  }
1261
1674
 
1262
 
  return new (session->mem_root) Item_func_concat_ws(*session, *item_list);
 
1675
  return new (session->mem_root) Item_func_concat_ws(*item_list);
1263
1676
}
1264
1677
 
1265
1678
 
1271
1684
  return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1272
1685
}
1273
1686
 
 
1687
 
 
1688
Create_func_cos Create_func_cos::s_singleton;
 
1689
 
 
1690
Item*
 
1691
Create_func_cos::create(Session *session, Item *arg1)
 
1692
{
 
1693
  return new (session->mem_root) Item_func_cos(arg1);
 
1694
}
 
1695
 
 
1696
 
1274
1697
Create_func_cot Create_func_cot::s_singleton;
1275
1698
 
1276
1699
Item*
1278
1701
{
1279
1702
  Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
1280
1703
  Item *i2= new (session->mem_root) Item_func_tan(arg1);
1281
 
  return new (session->mem_root) Item_func_div(session, i1, i2);
 
1704
  return new (session->mem_root) Item_func_div(i1, i2);
1282
1705
}
1283
1706
 
1284
1707
Create_func_date_format Create_func_date_format::s_singleton;
1347
1770
                                             180/M_PI, 0.0);
1348
1771
}
1349
1772
 
 
1773
 
 
1774
Create_func_elt Create_func_elt::s_singleton;
 
1775
 
 
1776
Item*
 
1777
Create_func_elt::create_native(Session *session, LEX_STRING name,
 
1778
                               List<Item> *item_list)
 
1779
{
 
1780
  int arg_count= 0;
 
1781
 
 
1782
  if (item_list != NULL)
 
1783
    arg_count= item_list->elements;
 
1784
 
 
1785
  if (arg_count < 2)
 
1786
  {
 
1787
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1788
    return NULL;
 
1789
  }
 
1790
 
 
1791
  return new (session->mem_root) Item_func_elt(*item_list);
 
1792
}
 
1793
 
 
1794
 
 
1795
Create_func_exp Create_func_exp::s_singleton;
 
1796
 
 
1797
Item*
 
1798
Create_func_exp::create(Session *session, Item *arg1)
 
1799
{
 
1800
  return new (session->mem_root) Item_func_exp(arg1);
 
1801
}
 
1802
 
 
1803
 
1350
1804
Create_func_export_set Create_func_export_set::s_singleton;
1351
1805
 
1352
1806
Item*
1429
1883
  return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
1430
1884
}
1431
1885
 
 
1886
 
 
1887
Create_func_floor Create_func_floor::s_singleton;
 
1888
 
 
1889
Item*
 
1890
Create_func_floor::create(Session *session, Item *arg1)
 
1891
{
 
1892
  return new (session->mem_root) Item_func_floor(arg1);
 
1893
}
 
1894
 
 
1895
 
 
1896
Create_func_format Create_func_format::s_singleton;
 
1897
 
 
1898
Item*
 
1899
Create_func_format::create(Session *session, Item *arg1, Item *arg2)
 
1900
{
 
1901
  return new (session->mem_root) Item_func_format(arg1, arg2);
 
1902
}
 
1903
 
 
1904
 
1432
1905
Create_func_found_rows Create_func_found_rows::s_singleton;
1433
1906
 
1434
1907
Item*
1605
2078
  return new (session->mem_root) Item_func_min(*item_list);
1606
2079
}
1607
2080
 
 
2081
 
 
2082
Create_func_ln Create_func_ln::s_singleton;
 
2083
 
 
2084
Item*
 
2085
Create_func_ln::create(Session *session, Item *arg1)
 
2086
{
 
2087
  return new (session->mem_root) Item_func_ln(arg1);
 
2088
}
 
2089
 
 
2090
 
1608
2091
Create_func_load_file Create_func_load_file::s_singleton;
1609
2092
 
1610
2093
Item*
1611
2094
Create_func_load_file::create(Session *session, Item *arg1)
1612
2095
{
1613
 
  return new (session->mem_root) Item_load_file(*session, arg1);
 
2096
  return new (session->mem_root) Item_load_file(arg1);
1614
2097
}
1615
2098
 
1616
2099
 
1654
2137
  return func;
1655
2138
}
1656
2139
 
 
2140
 
 
2141
Create_func_log Create_func_log::s_singleton;
 
2142
 
 
2143
Item*
 
2144
Create_func_log::create_native(Session *session, LEX_STRING name,
 
2145
                               List<Item> *item_list)
 
2146
{
 
2147
  Item *func= NULL;
 
2148
  int arg_count= 0;
 
2149
 
 
2150
  if (item_list != NULL)
 
2151
    arg_count= item_list->elements;
 
2152
 
 
2153
  switch (arg_count) {
 
2154
  case 1:
 
2155
  {
 
2156
    Item *param_1= item_list->pop();
 
2157
    func= new (session->mem_root) Item_func_log(param_1);
 
2158
    break;
 
2159
  }
 
2160
  case 2:
 
2161
  {
 
2162
    Item *param_1= item_list->pop();
 
2163
    Item *param_2= item_list->pop();
 
2164
    func= new (session->mem_root) Item_func_log(param_1, param_2);
 
2165
    break;
 
2166
  }
 
2167
  default:
 
2168
  {
 
2169
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2170
    break;
 
2171
  }
 
2172
  }
 
2173
 
 
2174
  return func;
 
2175
}
 
2176
 
 
2177
 
 
2178
Create_func_log10 Create_func_log10::s_singleton;
 
2179
 
 
2180
Item*
 
2181
Create_func_log10::create(Session *session, Item *arg1)
 
2182
{
 
2183
  return new (session->mem_root) Item_func_log10(arg1);
 
2184
}
 
2185
 
 
2186
 
 
2187
Create_func_log2 Create_func_log2::s_singleton;
 
2188
 
 
2189
Item*
 
2190
Create_func_log2::create(Session *session, Item *arg1)
 
2191
{
 
2192
  return new (session->mem_root) Item_func_log2(arg1);
 
2193
}
 
2194
 
 
2195
 
1657
2196
Create_func_lpad Create_func_lpad::s_singleton;
1658
2197
 
1659
2198
Item*
1660
2199
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1661
2200
{
1662
 
  return new (session->mem_root) Item_func_lpad(*session, arg1, arg2, arg3);
 
2201
  return new (session->mem_root) Item_func_lpad(arg1, arg2, arg3);
1663
2202
}
1664
2203
 
1665
2204
 
1684
2223
Create_func_make_set Create_func_make_set::s_singleton;
1685
2224
 
1686
2225
Item*
1687
 
Create_func_make_set::create_native(Session *session_arg, LEX_STRING name,
 
2226
Create_func_make_set::create_native(Session *session, LEX_STRING name,
1688
2227
                                    List<Item> *item_list)
1689
2228
{
1690
2229
  int arg_count= 0;
1699
2238
  }
1700
2239
 
1701
2240
  Item *param_1= item_list->pop();
1702
 
  return new (session_arg->mem_root) Item_func_make_set(*session_arg, param_1, *item_list);
 
2241
  return new (session->mem_root) Item_func_make_set(param_1, *item_list);
1703
2242
}
1704
2243
 
1705
2244
 
1731
2270
  return new (session->mem_root) Item_func_conv(arg1, i10, i8);
1732
2271
}
1733
2272
 
 
2273
 
 
2274
Create_func_ord Create_func_ord::s_singleton;
 
2275
 
 
2276
Item*
 
2277
Create_func_ord::create(Session *session, Item *arg1)
 
2278
{
 
2279
  return new (session->mem_root) Item_func_ord(arg1);
 
2280
}
 
2281
 
 
2282
 
1734
2283
Create_func_period_add Create_func_period_add::s_singleton;
1735
2284
 
1736
2285
Item*
1757
2306
  return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
1758
2307
}
1759
2308
 
 
2309
 
 
2310
Create_func_pow Create_func_pow::s_singleton;
 
2311
 
 
2312
Item*
 
2313
Create_func_pow::create(Session *session, Item *arg1, Item *arg2)
 
2314
{
 
2315
  return new (session->mem_root) Item_func_pow(arg1, arg2);
 
2316
}
 
2317
 
 
2318
 
 
2319
Create_func_quote Create_func_quote::s_singleton;
 
2320
 
 
2321
Item*
 
2322
Create_func_quote::create(Session *session, Item *arg1)
 
2323
{
 
2324
  return new (session->mem_root) Item_func_quote(arg1);
 
2325
}
 
2326
 
 
2327
 
1760
2328
Create_func_radians Create_func_radians::s_singleton;
1761
2329
 
1762
2330
Item*
1766
2334
                                             M_PI/180, 0.0);
1767
2335
}
1768
2336
 
 
2337
 
 
2338
Create_func_rand Create_func_rand::s_singleton;
 
2339
 
 
2340
Item*
 
2341
Create_func_rand::create_native(Session *session, LEX_STRING name,
 
2342
                                List<Item> *item_list)
 
2343
{
 
2344
  Item *func= NULL;
 
2345
  int arg_count= 0;
 
2346
 
 
2347
  if (item_list != NULL)
 
2348
    arg_count= item_list->elements;
 
2349
 
 
2350
  switch (arg_count) {
 
2351
  case 0:
 
2352
  {
 
2353
    func= new (session->mem_root) Item_func_rand();
 
2354
    break;
 
2355
  }
 
2356
  case 1:
 
2357
  {
 
2358
    Item *param_1= item_list->pop();
 
2359
    func= new (session->mem_root) Item_func_rand(param_1);
 
2360
    break;
 
2361
  }
 
2362
  default:
 
2363
  {
 
2364
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2365
    break;
 
2366
  }
 
2367
  }
 
2368
 
 
2369
  return func;
 
2370
}
 
2371
 
 
2372
 
1769
2373
Create_func_round Create_func_round::s_singleton;
1770
2374
 
1771
2375
Item*
1818
2422
Item*
1819
2423
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1820
2424
{
1821
 
  return new (session->mem_root) Item_func_rpad(*session, arg1, arg2, arg3);
 
2425
  return new (session->mem_root) Item_func_rpad(arg1, arg2, arg3);
1822
2426
}
1823
2427
 
1824
2428
 
1839
2443
  return new (session->mem_root) Item_func_sign(arg1);
1840
2444
}
1841
2445
 
 
2446
 
 
2447
Create_func_sin Create_func_sin::s_singleton;
 
2448
 
 
2449
Item*
 
2450
Create_func_sin::create(Session *session, Item *arg1)
 
2451
{
 
2452
  return new (session->mem_root) Item_func_sin(arg1);
 
2453
}
 
2454
 
 
2455
 
1842
2456
Create_func_space Create_func_space::s_singleton;
1843
2457
 
1844
2458
Item*
1854
2468
 
1855
2469
  if (cs->mbminlen > 1)
1856
2470
  {
1857
 
    size_t dummy_errors;
 
2471
    uint32_t dummy_errors;
1858
2472
    sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
1859
2473
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
1860
2474
  }
1863
2477
    sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
1864
2478
  }
1865
2479
 
1866
 
  return new (session->mem_root) Item_func_repeat(*session, sp, arg1);
1867
 
}
 
2480
  return new (session->mem_root) Item_func_repeat(sp, arg1);
 
2481
}
 
2482
 
 
2483
 
 
2484
Create_func_sqrt Create_func_sqrt::s_singleton;
 
2485
 
 
2486
Item*
 
2487
Create_func_sqrt::create(Session *session, Item *arg1)
 
2488
{
 
2489
  return new (session->mem_root) Item_func_sqrt(arg1);
 
2490
}
 
2491
 
1868
2492
 
1869
2493
Create_func_strcmp Create_func_strcmp::s_singleton;
1870
2494
 
1969
2593
 
1970
2594
static Native_func_registry func_array[] =
1971
2595
{
 
2596
  { { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
 
2597
  { { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
 
2598
  { { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
 
2599
  { { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
 
2600
  { { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
1972
2601
  { { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
 
2602
  { { C_STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
 
2603
  { { C_STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
 
2604
  { { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
1973
2605
  { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
1974
2606
  { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
1975
2607
  { { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
 
2608
  { { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
1976
2609
  { { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
1977
2610
  { { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
1978
2611
  { { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
1981
2614
  { { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
1982
2615
  { { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
1983
2616
  { { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
 
2617
  { { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
 
2618
  { { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
1984
2619
  { { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
1985
2620
  { { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
1986
2621
  { { C_STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
 
2622
  { { C_STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
 
2623
  { { C_STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
1987
2624
  { { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
1988
2625
  { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
1989
2626
  { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
1995
2632
  { { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
1996
2633
  { { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
1997
2634
  { { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
 
2635
  { { C_STRING_WITH_LEN("LN") }, BUILDER(Create_func_ln)},
1998
2636
  { { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
1999
2637
  { { C_STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
 
2638
  { { C_STRING_WITH_LEN("LOG") }, BUILDER(Create_func_log)},
 
2639
  { { C_STRING_WITH_LEN("LOG10") }, BUILDER(Create_func_log10)},
 
2640
  { { C_STRING_WITH_LEN("LOG2") }, BUILDER(Create_func_log2)},
2000
2641
  { { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
2001
2642
  { { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
2002
2643
  { { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
2005
2646
  { { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2006
2647
  { { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
2007
2648
  { { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
 
2649
  { { C_STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)},
2008
2650
  { { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
2009
2651
  { { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
2010
2652
  { { C_STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
 
2653
  { { C_STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)},
 
2654
  { { C_STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)},
 
2655
  { { C_STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)},
2011
2656
  { { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
 
2657
  { { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
2012
2658
  { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
2013
2659
  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
2014
2660
  { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
2015
2661
  { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
2016
2662
  { { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
 
2663
  { { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
2017
2664
  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
 
2665
  { { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
2018
2666
  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
2019
2667
  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
2020
2668
  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
2027
2675
  { {0, 0}, NULL}
2028
2676
};
2029
2677
 
 
2678
static map<string, Native_func_registry *> native_functions_map;
 
2679
 
2030
2680
/*
2031
2681
  Load the hash table for native functions.
2032
2682
  Note: this code is not thread safe, and is intended to be used at server
2041
2691
  for (func= func_array; func->builder != NULL; func++)
2042
2692
  {
2043
2693
    func_name.assign(func->name.str, func->name.length);
 
2694
    transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
2044
2695
 
2045
 
    FunctionContainer::getMap()[func_name]= func;
 
2696
    native_functions_map[func_name]= func;
2046
2697
  }
2047
2698
 
2048
2699
  return 0;
2056
2707
  Create_func *builder= NULL;
2057
2708
 
2058
2709
  string func_name(name.str, name.length);
2059
 
 
2060
 
  NativeFunctionsMap::iterator func_iter=
2061
 
    FunctionContainer::getMap().find(func_name);
2062
 
 
2063
 
  if (func_iter != FunctionContainer::getMap().end())
 
2710
  transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
 
2711
 
 
2712
  map<string, Native_func_registry *>::iterator func_iter=
 
2713
    native_functions_map.find(func_name);
 
2714
 
 
2715
  if (func_iter != native_functions_map.end())
2064
2716
  {
2065
2717
    func= (*func_iter).second;
2066
2718
    builder= func->builder;