~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-07-30 02:39:13 UTC
  • mto: (1115.3.11 captain)
  • mto: This revision was merged to the branch mainline in revision 1121.
  • Revision ID: osullivan.padraig@gmail.com-20090730023913-o2zuocp32l6btnc2
Removing references to MY_BITMAP throughout the code base and updating calls
to MyBitmap in various places to use the new interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  Functions to create an item. Used by sql_yac.yy
21
21
*/
22
22
 
23
 
#include "config.h"
 
23
#include <drizzled/server_includes.h>
24
24
#include <drizzled/item/create.h>
25
25
#include <drizzled/item/func.h>
26
26
#include <drizzled/error.h>
31
31
#include <drizzled/function/str/elt.h>
32
32
#include <drizzled/function/str/export_set.h>
33
33
#include <drizzled/function/str/format.h>
 
34
#include <drizzled/function/str/hex.h>
34
35
#include <drizzled/function/str/load_file.h>
35
36
#include <drizzled/function/str/make_set.h>
36
37
#include <drizzled/function/str/pad.h>
37
38
#include <drizzled/function/str/repeat.h>
38
39
#include <drizzled/function/str/str_conv.h>
 
40
#include <drizzled/function/str/substr.h>
39
41
#include <drizzled/function/str/trim.h>
 
42
#include <drizzled/function/str/uuid.h>
40
43
 
41
44
#include <drizzled/function/time/date_format.h>
42
45
#include <drizzled/function/time/dayname.h>
55
58
#include <drizzled/function/time/weekday.h>
56
59
 
57
60
#include <drizzled/item/cmpfunc.h>
58
 
#include <drizzled/plugin/function.h>
 
61
#include <drizzled/sql_udf.h>
59
62
#include <drizzled/session.h>
60
63
 
61
64
/* Function declarations */
71
74
#include <drizzled/function/math/cos.h>
72
75
#include <drizzled/function/math/dec.h>
73
76
#include <drizzled/function/math/decimal_typecast.h>
74
 
#include <drizzled/function/math/exp.h>
 
77
#include <drizzled/function/math//exp.h>
75
78
#include <drizzled/function/field.h>
76
79
#include <drizzled/function/find_in_set.h>
77
80
#include <drizzled/function/math/floor.h>
94
97
#include <drizzled/function/row_count.h>
95
98
#include <drizzled/function/set_user_var.h>
96
99
#include <drizzled/function/sign.h>
 
100
#include <drizzled/function/signed.h>
97
101
#include <drizzled/function/math/sin.h>
98
102
#include <drizzled/function/math/sqrt.h>
99
103
#include <drizzled/function/str/quote.h>
100
104
#include <drizzled/function/math/tan.h>
101
105
#include <drizzled/function/units.h>
 
106
#include <drizzled/function/unsigned.h>
102
107
 
103
108
#include <map>
104
109
 
105
110
using namespace std;
106
111
 
107
 
namespace drizzled
108
 
{
109
 
 
110
112
class Item;
111
113
 
112
114
 
705
707
};
706
708
 
707
709
 
 
710
class Create_func_hex : public Create_func_arg1
 
711
{
 
712
public:
 
713
  using Create_func_arg1::create;
 
714
 
 
715
  virtual Item *create(Session *session, Item *arg1);
 
716
 
 
717
  static Create_func_hex s_singleton;
 
718
 
 
719
protected:
 
720
  Create_func_hex() {}
 
721
  virtual ~Create_func_hex() {}
 
722
};
 
723
 
 
724
 
708
725
class Create_func_ifnull : public Create_func_arg2
709
726
{
710
727
public:
1259
1276
};
1260
1277
 
1261
1278
 
 
1279
class Create_func_substr_index : public Create_func_arg3
 
1280
{
 
1281
public:
 
1282
  using Create_func_arg3::create;
 
1283
 
 
1284
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
 
1285
 
 
1286
  static Create_func_substr_index s_singleton;
 
1287
 
 
1288
protected:
 
1289
  Create_func_substr_index() {}
 
1290
  virtual ~Create_func_substr_index() {}
 
1291
};
 
1292
 
 
1293
 
1262
1294
class Create_func_tan : public Create_func_arg1
1263
1295
{
1264
1296
public:
1334
1366
};
1335
1367
 
1336
1368
 
 
1369
class Create_func_unhex : public Create_func_arg1
 
1370
{
 
1371
public:
 
1372
  using Create_func_arg1::create;
 
1373
 
 
1374
  virtual Item *create(Session *session, Item *arg1);
 
1375
 
 
1376
  static Create_func_unhex s_singleton;
 
1377
 
 
1378
protected:
 
1379
  Create_func_unhex() {}
 
1380
  virtual ~Create_func_unhex() {}
 
1381
};
 
1382
 
 
1383
 
1337
1384
class Create_func_unix_timestamp : public Create_native_func
1338
1385
{
1339
1386
public:
1347
1394
};
1348
1395
 
1349
1396
 
 
1397
class Create_func_uuid : public Create_func_arg0
 
1398
{
 
1399
public:
 
1400
  using Create_func_arg0::create;
 
1401
 
 
1402
  virtual Item *create(Session *session);
 
1403
 
 
1404
  static Create_func_uuid s_singleton;
 
1405
 
 
1406
protected:
 
1407
  Create_func_uuid() {}
 
1408
  virtual ~Create_func_uuid() {}
 
1409
};
 
1410
 
 
1411
 
1350
1412
class Create_func_weekday : public Create_func_arg1
1351
1413
{
1352
1414
public:
1396
1458
Item*
1397
1459
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1398
1460
{
1399
 
  const plugin::Function *udf= plugin::Function::get(name.str, name.length);
 
1461
  Function_builder *udf= find_udf(name.str, name.length);
1400
1462
  assert(udf);
1401
1463
  return create(session, udf, item_list);
1402
1464
}
1403
1465
 
1404
1466
 
1405
1467
Item*
1406
 
Create_udf_func::create(Session *session, const plugin::Function *udf,
 
1468
Create_udf_func::create(Session *session, Function_builder *udf,
1407
1469
                        List<Item> *item_list)
1408
1470
{
1409
1471
  Item_func *func= NULL;
1416
1478
 
1417
1479
  if(!func->check_argument_count(arg_count))
1418
1480
  {
1419
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
 
1481
    my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), func->func_name());
1420
1482
    return NULL;
1421
1483
  }
1422
1484
 
1450
1512
 
1451
1513
  if (arg_count != 0)
1452
1514
  {
1453
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1515
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1454
1516
    return NULL;
1455
1517
  }
1456
1518
 
1468
1530
 
1469
1531
  if (arg_count != 1)
1470
1532
  {
1471
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1533
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1472
1534
    return NULL;
1473
1535
  }
1474
1536
 
1494
1556
 
1495
1557
  if (arg_count != 2)
1496
1558
  {
1497
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1559
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1498
1560
    return NULL;
1499
1561
  }
1500
1562
 
1522
1584
 
1523
1585
  if (arg_count != 3)
1524
1586
  {
1525
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1587
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1526
1588
    return NULL;
1527
1589
  }
1528
1590
 
1596
1658
  }
1597
1659
  default:
1598
1660
  {
1599
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1661
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1600
1662
    break;
1601
1663
  }
1602
1664
  }
1646
1708
 
1647
1709
  if (arg_count < 1)
1648
1710
  {
1649
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1711
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1650
1712
    return NULL;
1651
1713
  }
1652
1714
 
1668
1730
  /* "WS" stands for "With Separator": this function takes 2+ arguments */
1669
1731
  if (arg_count < 2)
1670
1732
  {
1671
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1733
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1672
1734
    return NULL;
1673
1735
  }
1674
1736
 
1784
1846
 
1785
1847
  if (arg_count < 2)
1786
1848
  {
1787
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1849
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1788
1850
    return NULL;
1789
1851
  }
1790
1852
 
1845
1907
  }
1846
1908
  default:
1847
1909
  {
1848
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1910
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1849
1911
    break;
1850
1912
  }
1851
1913
  }
1867
1929
 
1868
1930
  if (arg_count < 2)
1869
1931
  {
1870
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
1932
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1871
1933
    return NULL;
1872
1934
  }
1873
1935
 
1949
2011
  }
1950
2012
  default:
1951
2013
  {
1952
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2014
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1953
2015
    break;
1954
2016
  }
1955
2017
  }
1971
2033
 
1972
2034
  if (arg_count < 2)
1973
2035
  {
1974
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2036
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1975
2037
    return NULL;
1976
2038
  }
1977
2039
 
1978
2040
  return new (session->mem_root) Item_func_max(*item_list);
1979
2041
}
1980
2042
 
 
2043
 
 
2044
Create_func_hex Create_func_hex::s_singleton;
 
2045
 
 
2046
Item*
 
2047
Create_func_hex::create(Session *session, Item *arg1)
 
2048
{
 
2049
  return new (session->mem_root) Item_func_hex(arg1);
 
2050
}
 
2051
 
 
2052
 
1981
2053
Create_func_ifnull Create_func_ifnull::s_singleton;
1982
2054
 
1983
2055
Item*
2040
2112
  }
2041
2113
  default:
2042
2114
  {
2043
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2115
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2044
2116
    break;
2045
2117
  }
2046
2118
  }
2071
2143
 
2072
2144
  if (arg_count < 2)
2073
2145
  {
2074
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2146
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2075
2147
    return NULL;
2076
2148
  }
2077
2149
 
2129
2201
  }
2130
2202
  default:
2131
2203
  {
2132
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2204
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2133
2205
    break;
2134
2206
  }
2135
2207
  }
2166
2238
  }
2167
2239
  default:
2168
2240
  {
2169
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2241
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2170
2242
    break;
2171
2243
  }
2172
2244
  }
2233
2305
 
2234
2306
  if (arg_count < 2)
2235
2307
  {
2236
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2308
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2237
2309
    return NULL;
2238
2310
  }
2239
2311
 
2361
2433
  }
2362
2434
  default:
2363
2435
  {
2364
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2436
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2365
2437
    break;
2366
2438
  }
2367
2439
  }
2399
2471
  }
2400
2472
  default:
2401
2473
  {
2402
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2474
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2403
2475
    break;
2404
2476
  }
2405
2477
  }
2499
2571
}
2500
2572
 
2501
2573
 
 
2574
Create_func_substr_index Create_func_substr_index::s_singleton;
 
2575
 
 
2576
Item*
 
2577
Create_func_substr_index::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
 
2578
{
 
2579
  return new (session->mem_root) Item_func_substr_index(arg1, arg2, arg3);
 
2580
}
 
2581
 
2502
2582
Create_func_tan Create_func_tan::s_singleton;
2503
2583
 
2504
2584
Item*
2533
2613
  return new (session->mem_root) Item_func_ucase(arg1);
2534
2614
}
2535
2615
 
 
2616
 
 
2617
Create_func_unhex Create_func_unhex::s_singleton;
 
2618
 
 
2619
Item*
 
2620
Create_func_unhex::create(Session *session, Item *arg1)
 
2621
{
 
2622
  return new (session->mem_root) Item_func_unhex(arg1);
 
2623
}
 
2624
 
 
2625
 
2536
2626
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2537
2627
 
2538
2628
Item*
2559
2649
  }
2560
2650
  default:
2561
2651
  {
2562
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
 
2652
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2563
2653
    break;
2564
2654
  }
2565
2655
  }
2568
2658
}
2569
2659
 
2570
2660
 
 
2661
Create_func_uuid Create_func_uuid::s_singleton;
 
2662
 
 
2663
Item*
 
2664
Create_func_uuid::create(Session *session)
 
2665
{
 
2666
  return new (session->mem_root) Item_func_uuid();
 
2667
}
 
2668
 
 
2669
 
2571
2670
Create_func_weekday Create_func_weekday::s_singleton;
2572
2671
 
2573
2672
Item*
2625
2724
  { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
2626
2725
  { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
2627
2726
  { { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
 
2727
  { { C_STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
2628
2728
  { { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
2629
2729
  { { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
2630
2730
  { { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
2664
2764
  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
2665
2765
  { { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
2666
2766
  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
 
2767
  { { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
2667
2768
  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
2668
2769
  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
2669
2770
  { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
2670
2771
  { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
 
2772
  { { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
2671
2773
  { { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
2672
2774
  { { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
 
2775
  { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
2673
2776
  { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
2674
2777
 
2675
2778
  { {0, 0}, NULL}
2743
2846
  case ITEM_CAST_BINARY:
2744
2847
    res= new (session->mem_root) Item_func_binary(a);
2745
2848
    break;
 
2849
  case ITEM_CAST_SIGNED_INT:
 
2850
    res= new (session->mem_root) Item_func_signed(a);
 
2851
    break;
 
2852
  case ITEM_CAST_UNSIGNED_INT:
 
2853
    res= new (session->mem_root) Item_func_unsigned(a);
 
2854
    break;
2746
2855
  case ITEM_CAST_DATE:
2747
2856
    res= new (session->mem_root) Item_date_typecast(a);
2748
2857
    break;
2789
2898
  }
2790
2899
  return res;
2791
2900
}
2792
 
 
2793
 
} /* namespace drizzled */