~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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 "config.h"
24
24
#include <drizzled/item/create.h>
25
25
#include <drizzled/item/func.h>
26
26
#include <drizzled/error.h>
27
 
#include <drizzled/system_variables.h>
28
27
 
29
 
#include <drizzled/function_container.h>
 
28
#include "drizzled/function_container.h"
30
29
 
31
30
#include <drizzled/function/str/binary.h>
32
31
#include <drizzled/function/str/concat.h>
84
83
#include <drizzled/function/math/tan.h>
85
84
#include <drizzled/function/units.h>
86
85
 
87
 
#include <drizzled/function/cast/boolean.h>
88
 
#include <drizzled/function/cast/signed.h>
89
 
#include <drizzled/function/cast/time.h>
90
 
#include <drizzled/function/cast/unsigned.h>
 
86
#include "drizzled/function/cast/boolean.h"
 
87
#include "drizzled/function/cast/signed.h"
 
88
#include "drizzled/function/cast/time.h"
 
89
#include "drizzled/function/cast/unsigned.h"
91
90
 
92
91
using namespace std;
93
92
 
94
 
namespace drizzled {
 
93
namespace drizzled
 
94
{
 
95
 
 
96
class Item;
 
97
 
95
98
 
96
99
/*
97
100
=============================================================================
1050
1053
  if (params)
1051
1054
  {
1052
1055
    Item *param;
1053
 
    List<Item>::iterator it(params->begin());
 
1056
    List_iterator<Item> it(*params);
1054
1057
    while ((param= it++))
1055
1058
    {
1056
1059
      if (! param->is_autogenerated_name)
1067
1070
Item*
1068
1071
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1069
1072
{
1070
 
  const plugin::Function *udf= plugin::Function::get(std::string(name.str, name.length));
 
1073
  const plugin::Function *udf= plugin::Function::get(name.str, name.length);
1071
1074
  assert(udf);
1072
1075
  return create(session, udf, item_list);
1073
1076
}
1081
1084
  int arg_count= 0;
1082
1085
 
1083
1086
  if (item_list != NULL)
1084
 
    arg_count= item_list->size();
 
1087
    arg_count= item_list->elements;
1085
1088
 
1086
1089
  func= (*udf)(session->mem_root);
1087
1090
 
1117
1120
  int arg_count= 0;
1118
1121
 
1119
1122
  if (item_list != NULL)
1120
 
    arg_count= item_list->size();
 
1123
    arg_count= item_list->elements;
1121
1124
 
1122
1125
  if (arg_count != 0)
1123
1126
  {
1135
1138
  int arg_count= 0;
1136
1139
 
1137
1140
  if (item_list)
1138
 
    arg_count= item_list->size();
 
1141
    arg_count= item_list->elements;
1139
1142
 
1140
1143
  if (arg_count != 1)
1141
1144
  {
1161
1164
  int arg_count= 0;
1162
1165
 
1163
1166
  if (item_list)
1164
 
    arg_count= item_list->size();
 
1167
    arg_count= item_list->elements;
1165
1168
 
1166
1169
  if (arg_count != 2)
1167
1170
  {
1189
1192
  int arg_count= 0;
1190
1193
 
1191
1194
  if (item_list)
1192
 
    arg_count= item_list->size();
 
1195
    arg_count= item_list->elements;
1193
1196
 
1194
1197
  if (arg_count != 3)
1195
1198
  {
1231
1234
  int arg_count= 0;
1232
1235
 
1233
1236
  if (item_list != NULL)
1234
 
    arg_count= item_list->size();
 
1237
    arg_count= item_list->elements;
1235
1238
 
1236
1239
  if (arg_count < 1)
1237
1240
  {
1252
1255
  int arg_count= 0;
1253
1256
 
1254
1257
  if (item_list != NULL)
1255
 
    arg_count= item_list->size();
 
1258
    arg_count= item_list->elements;
1256
1259
 
1257
1260
  /* "WS" stands for "With Separator": this function takes 2+ arguments */
1258
1261
  if (arg_count < 2)
1359
1362
  int arg_count= 0;
1360
1363
 
1361
1364
  if (item_list != NULL)
1362
 
    arg_count= item_list->size();
 
1365
    arg_count= item_list->elements;
1363
1366
 
1364
1367
  switch (arg_count) {
1365
1368
  case 3:
1411
1414
  int arg_count= 0;
1412
1415
 
1413
1416
  if (item_list != NULL)
1414
 
    arg_count= item_list->size();
 
1417
    arg_count= item_list->elements;
1415
1418
 
1416
1419
  if (arg_count < 2)
1417
1420
  {
1459
1462
  int arg_count= 0;
1460
1463
 
1461
1464
  if (item_list != NULL)
1462
 
    arg_count= item_list->size();
 
1465
    arg_count= item_list->elements;
1463
1466
 
1464
1467
  switch (arg_count) {
1465
1468
  case 1:
1496
1499
  int arg_count= 0;
1497
1500
 
1498
1501
  if (item_list != NULL)
1499
 
    arg_count= item_list->size();
 
1502
    arg_count= item_list->elements;
1500
1503
 
1501
1504
  if (arg_count < 2)
1502
1505
  {
1553
1556
  int arg_count= 0;
1554
1557
 
1555
1558
  if (item_list != NULL)
1556
 
    arg_count= item_list->size();
 
1559
    arg_count= item_list->elements;
1557
1560
 
1558
1561
  switch (arg_count) {
1559
1562
  case 0:
1596
1599
  int arg_count= 0;
1597
1600
 
1598
1601
  if (item_list != NULL)
1599
 
    arg_count= item_list->size();
 
1602
    arg_count= item_list->elements;
1600
1603
 
1601
1604
  if (arg_count < 2)
1602
1605
  {
1626
1629
  int arg_count= 0;
1627
1630
 
1628
1631
  if (item_list != NULL)
1629
 
    arg_count= item_list->size();
 
1632
    arg_count= item_list->elements;
1630
1633
 
1631
1634
  switch (arg_count) {
1632
1635
  case 2:
1692
1695
  int arg_count= 0;
1693
1696
 
1694
1697
  if (item_list != NULL)
1695
 
    arg_count= item_list->size();
 
1698
    arg_count= item_list->elements;
1696
1699
 
1697
1700
  if (arg_count < 2)
1698
1701
  {
1778
1781
  int arg_count= 0;
1779
1782
 
1780
1783
  if (item_list != NULL)
1781
 
    arg_count= item_list->size();
 
1784
    arg_count= item_list->elements;
1782
1785
 
1783
1786
  switch (arg_count) {
1784
1787
  case 1:
1851
1854
    The parsed item tree should not depend on
1852
1855
    <code>session->variables.collation_connection</code>.
1853
1856
  */
1854
 
  const charset_info_st * const cs= session->variables.getCollation();
 
1857
  const CHARSET_INFO * const cs= session->variables.getCollation();
1855
1858
  Item *sp;
1856
1859
 
1857
1860
  if (cs->mbminlen > 1)
1858
1861
  {
 
1862
    size_t dummy_errors;
1859
1863
    sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
1860
 
    sp->str_value.copy(" ", 1, cs);
 
1864
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
1861
1865
  }
1862
1866
  else
1863
1867
  {
1920
1924
  int arg_count= 0;
1921
1925
 
1922
1926
  if (item_list != NULL)
1923
 
    arg_count= item_list->size();
 
1927
    arg_count= item_list->elements;
1924
1928
 
1925
1929
  switch (arg_count) {
1926
1930
  case 0:
2070
2074
 
2071
2075
 
2072
2076
Item*
2073
 
create_func_char_cast(Session *session, Item *a, int len, const charset_info_st * const cs)
 
2077
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
2074
2078
{
2075
 
  const charset_info_st * const real_cs= (cs ? cs : session->variables.getCollation());
 
2079
  const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.getCollation());
2076
2080
  return new (session->mem_root) Item_char_typecast(a, len, real_cs);
2077
2081
}
2078
2082
 
2080
2084
Item *
2081
2085
create_func_cast(Session *session, Item *a, Cast_target cast_type,
2082
2086
                 const char *c_len, const char *c_dec,
2083
 
                 const charset_info_st * const cs)
 
2087
                 const CHARSET_INFO * const cs)
2084
2088
{
2085
2089
  Item *res= NULL;
2086
2090
  uint32_t len;