~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_create.cc

  • Committer: Brian Aker
  • Date: 2008-08-10 16:57:26 UTC
  • Revision ID: brian@tangent.org-20080810165726-mc1660l11a5vkv69
libdrizzle has ulong removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1461
1461
Item*
1462
1462
Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
1463
1463
{
1464
 
  Item_func *func= NULL;
 
1464
  Item *func= NULL;
1465
1465
  int arg_count= 0;
1466
1466
 
1467
1467
  if (item_list != NULL)
1469
1469
 
1470
1470
  thd->lex->set_stmt_unsafe();
1471
1471
 
1472
 
  func= udf->create_func(thd->mem_root);
1473
 
 
1474
 
  func->set_arguments(*item_list);
1475
 
 
 
1472
  assert(   (udf->type == UDFTYPE_FUNCTION)
 
1473
              || (udf->type == UDFTYPE_AGGREGATE));
 
1474
 
 
1475
  switch(udf->returns) {
 
1476
  case STRING_RESULT:
 
1477
  {
 
1478
    if (udf->type == UDFTYPE_FUNCTION)
 
1479
    {
 
1480
      if (arg_count)
 
1481
        func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
 
1482
      else
 
1483
        func= new (thd->mem_root) Item_func_udf_str(udf);
 
1484
    }
 
1485
    else
 
1486
    {
 
1487
      if (arg_count)
 
1488
        func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
 
1489
      else
 
1490
        func= new (thd->mem_root) Item_sum_udf_str(udf);
 
1491
    }
 
1492
    break;
 
1493
  }
 
1494
  case REAL_RESULT:
 
1495
  {
 
1496
    if (udf->type == UDFTYPE_FUNCTION)
 
1497
    {
 
1498
      if (arg_count)
 
1499
        func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
 
1500
      else
 
1501
        func= new (thd->mem_root) Item_func_udf_float(udf);
 
1502
    }
 
1503
    else
 
1504
    {
 
1505
      if (arg_count)
 
1506
        func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
 
1507
      else
 
1508
        func= new (thd->mem_root) Item_sum_udf_float(udf);
 
1509
    }
 
1510
    break;
 
1511
  }
 
1512
  case INT_RESULT:
 
1513
  {
 
1514
    if (udf->type == UDFTYPE_FUNCTION)
 
1515
    {
 
1516
      if (arg_count)
 
1517
        func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
 
1518
      else
 
1519
        func= new (thd->mem_root) Item_func_udf_int(udf);
 
1520
    }
 
1521
    else
 
1522
    {
 
1523
      if (arg_count)
 
1524
        func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
 
1525
      else
 
1526
        func= new (thd->mem_root) Item_sum_udf_int(udf);
 
1527
    }
 
1528
    break;
 
1529
  }
 
1530
  case DECIMAL_RESULT:
 
1531
  {
 
1532
    if (udf->type == UDFTYPE_FUNCTION)
 
1533
    {
 
1534
      if (arg_count)
 
1535
        func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
 
1536
      else
 
1537
        func= new (thd->mem_root) Item_func_udf_decimal(udf);
 
1538
    }
 
1539
    else
 
1540
    {
 
1541
      if (arg_count)
 
1542
        func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
 
1543
      else
 
1544
        func= new (thd->mem_root) Item_sum_udf_decimal(udf);
 
1545
    }
 
1546
    break;
 
1547
  }
 
1548
  default:
 
1549
  {
 
1550
    my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
 
1551
  }
 
1552
  }
1476
1553
  return func;
1477
1554
}
1478
1555
 
2653
2730
 
2654
2731
  if (cs->mbminlen > 1)
2655
2732
  {
2656
 
    uint32_t dummy_errors;
 
2733
    uint dummy_errors;
2657
2734
    sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2658
 
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
 
2735
    sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
2659
2736
  }
2660
2737
  else
2661
2738
  {
3013
3090
 
3014
3091
static HASH native_functions_hash;
3015
3092
 
3016
 
extern "C" unsigned char*
3017
 
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
 
3093
extern "C" uchar*
 
3094
get_native_fct_hash_key(const uchar *buff, size_t *length,
3018
3095
                        bool /* unused */)
3019
3096
{
3020
3097
  Native_func_registry *func= (Native_func_registry*) buff;
3021
3098
  *length= func->name.length;
3022
 
  return (unsigned char*) func->name.str;
 
3099
  return (uchar*) func->name.str;
3023
3100
}
3024
3101
 
3025
3102
/*
3044
3121
 
3045
3122
  for (func= func_array; func->builder != NULL; func++)
3046
3123
  {
3047
 
    if (my_hash_insert(& native_functions_hash, (unsigned char*) func))
 
3124
    if (my_hash_insert(& native_functions_hash, (uchar*) func))
3048
3125
      return(1);
3049
3126
  }
3050
3127
 
3072
3149
 
3073
3150
  /* Thread safe */
3074
3151
  func= (Native_func_registry*) hash_search(& native_functions_hash,
3075
 
                                            (unsigned char*) name.str,
 
3152
                                            (uchar*) name.str,
3076
3153
                                             name.length);
3077
3154
 
3078
3155
  if (func)
3099
3176
{
3100
3177
  Item *res;
3101
3178
  uint32_t len;
3102
 
  uint32_t dec;
 
3179
  uint dec;
3103
3180
 
3104
3181
  switch (cast_type) {
3105
3182
  case ITEM_CAST_BINARY: