~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1580
1580
 
1581
1581
struct Native_func_registry
1582
1582
{
1583
 
  lex_string_t name;
 
1583
  const char* name;
1584
1584
  Create_func *builder;
1585
1585
};
1586
1586
 
1595
1595
 
1596
1596
static Native_func_registry func_array[] =
1597
1597
{
1598
 
  { { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
1599
 
  { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
1600
 
  { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
1601
 
  { { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
1602
 
  { { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
1603
 
  { { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
1604
 
  { { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
1605
 
  { { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
1606
 
  { { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
1607
 
  { { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
1608
 
  { { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
1609
 
  { { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
1610
 
  { { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
1611
 
  { { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
1612
 
  { { C_STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
1613
 
  { { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
1614
 
  { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
1615
 
  { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
1616
 
  { { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
1617
 
  { { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
1618
 
  { { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
1619
 
  { { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
1620
 
  { { C_STRING_WITH_LEN("LAST_DAY") }, BUILDER(Create_func_last_day)},
1621
 
  { { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
1622
 
  { { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
1623
 
  { { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
1624
 
  { { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
1625
 
  { { C_STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
1626
 
  { { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
1627
 
  { { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
1628
 
  { { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
1629
 
  { { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
1630
 
  { { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
1631
 
  { { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
1632
 
  { { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
1633
 
  { { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
1634
 
  { { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
1635
 
  { { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
1636
 
  { { C_STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
1637
 
  { { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
1638
 
  { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
1639
 
  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
1640
 
  { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
1641
 
  { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
1642
 
  { { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
1643
 
  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
1644
 
  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
1645
 
  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
1646
 
  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
1647
 
  { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
1648
 
  { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
1649
 
  { { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
1650
 
  { { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
1651
 
  { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
1652
 
 
1653
 
  { {0, 0}, NULL}
 
1598
  { "BIN", BUILDER(Create_func_bin)},
 
1599
  { "CONCAT", BUILDER(Create_func_concat)},
 
1600
  { "CONCAT_WS", BUILDER(Create_func_concat_ws)},
 
1601
  { "CONV", BUILDER(Create_func_conv)},
 
1602
  { "COT", BUILDER(Create_func_cot)},
 
1603
  { "DATEDIFF", BUILDER(Create_func_datediff)},
 
1604
  { "DATE_FORMAT", BUILDER(Create_func_date_format)},
 
1605
  { "DAYNAME", BUILDER(Create_func_dayname)},
 
1606
  { "DAYOFMONTH", BUILDER(Create_func_dayofmonth)},
 
1607
  { "DAYOFWEEK", BUILDER(Create_func_dayofweek)},
 
1608
  { "DAYOFYEAR", BUILDER(Create_func_dayofyear)},
 
1609
  { "DEGREES", BUILDER(Create_func_degrees)},
 
1610
  { "EXPORT_SET", BUILDER(Create_func_export_set)},
 
1611
  { "FIELD", BUILDER(Create_func_field)},
 
1612
  { "FIND_IN_SET", BUILDER(Create_func_find_in_set)},
 
1613
  { "FOUND_ROWS", BUILDER(Create_func_found_rows)},
 
1614
  { "FROM_DAYS", BUILDER(Create_func_from_days)},
 
1615
  { "FROM_UNIXTIME", BUILDER(Create_func_from_unixtime)},
 
1616
  { "GREATEST", BUILDER(Create_func_greatest)},
 
1617
  { "IFNULL", BUILDER(Create_func_ifnull)},
 
1618
  { "INSTR", BUILDER(Create_func_instr)},
 
1619
  { "ISNULL", BUILDER(Create_func_isnull)},
 
1620
  { "LAST_DAY", BUILDER(Create_func_last_day)},
 
1621
  { "LAST_INSERT_ID", BUILDER(Create_func_last_insert_id)},
 
1622
  { "LCASE", BUILDER(Create_func_lcase)},
 
1623
  { "LEAST", BUILDER(Create_func_least)},
 
1624
  { "LOAD_FILE", BUILDER(Create_func_load_file)},
 
1625
  { "LOCATE", BUILDER(Create_func_locate)},
 
1626
  { "LOWER", BUILDER(Create_func_lcase)},
 
1627
  { "LPAD", BUILDER(Create_func_lpad)},
 
1628
  { "LTRIM", BUILDER(Create_func_ltrim)},
 
1629
  { "MAKEDATE", BUILDER(Create_func_makedate)},
 
1630
  { "MAKE_SET", BUILDER(Create_func_make_set)},
 
1631
  { "MONTHNAME", BUILDER(Create_func_monthname)},
 
1632
  { "NULLIF", BUILDER(Create_func_nullif)},
 
1633
  { "OCT", BUILDER(Create_func_oct)},
 
1634
  { "PERIOD_ADD", BUILDER(Create_func_period_add)},
 
1635
  { "PERIOD_DIFF", BUILDER(Create_func_period_diff)},
 
1636
  { "PI", BUILDER(Create_func_pi)},
 
1637
  { "RADIANS", BUILDER(Create_func_radians)},
 
1638
  { "ROUND", BUILDER(Create_func_round)},
 
1639
  { "ROW_COUNT", BUILDER(Create_func_row_count)},
 
1640
  { "RPAD", BUILDER(Create_func_rpad)},
 
1641
  { "RTRIM", BUILDER(Create_func_rtrim)},
 
1642
  { "SIGN", BUILDER(Create_func_sign)},
 
1643
  { "SPACE", BUILDER(Create_func_space)},
 
1644
  { "STRCMP", BUILDER(Create_func_strcmp)},
 
1645
  { "TAN", BUILDER(Create_func_tan)},
 
1646
  { "TIME_FORMAT", BUILDER(Create_func_time_format)},
 
1647
  { "TO_DAYS", BUILDER(Create_func_to_days)},
 
1648
  { "UCASE", BUILDER(Create_func_ucase)},
 
1649
  { "UNIX_TIMESTAMP", BUILDER(Create_func_unix_timestamp)},
 
1650
  { "UPPER", BUILDER(Create_func_ucase)},
 
1651
  { "WEEKDAY", BUILDER(Create_func_weekday)},
 
1652
  { NULL, NULL}
1654
1653
};
1655
1654
 
1656
1655
/*
1662
1661
void item_create_init()
1663
1662
{
1664
1663
  for (Native_func_registry* func= func_array; func->builder; func++)
1665
 
    FunctionContainer::getMutableMap()[string(func->name.str, func->name.length)]= func->builder;
 
1664
    FunctionContainer::getMutableMap()[func->name]= func->builder;
1666
1665
}
1667
1666
 
1668
1667
Create_func* find_native_function_builder(lex_string_t name)
1669
1668
{
1670
 
  return find_ptr2(FunctionContainer::getMap(), string(name.str, name.length));
 
1669
  return find_ptr2(FunctionContainer::getMap(), name.str);
1671
1670
}
1672
1671
 
1673
 
Item* create_func_char_cast(Session *session, Item *a, int len, const charset_info_st * const cs)
 
1672
Item* create_func_char_cast(Session *session, Item *a, int len, const charset_info_st* cs)
1674
1673
{
1675
1674
  return new (session->mem) Item_char_typecast(a, len, cs ? cs : session->variables.getCollation());
1676
1675
}