~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Mark Atwood
  • Date: 2011-11-11 18:23:18 UTC
  • mfrom: (2456.1.5 rf)
  • Revision ID: me@mark.atwood.name-20111111182318-skgcp9ce65fd2goa
mergeĀ lp:~olafvdspek/drizzle/refactor11

Show diffs side-by-side

added added

removed removed

Lines of Context:
589
589
  static Create_func_locate s_singleton;
590
590
};
591
591
 
592
 
 
593
592
class Create_func_lpad : public Create_func_arg3
594
593
{
595
594
public:
944
943
Item* Create_udf_func::create(Session *session, const plugin::Function *udf, List<Item> *item_list)
945
944
{
946
945
  assert(udf);
947
 
  int arg_count= item_list ? item_list->size() : 0;
948
946
  Item_func* func= (*udf)(&session->mem);
949
 
  if (!func->check_argument_count(arg_count))
 
947
  if (!func->check_argument_count(item_list ? item_list->size() : 0))
950
948
  {
951
949
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
952
950
    return NULL;
1159
1157
Item* Create_func_last_insert_id::create_native(Session *session, str_ref name, List<Item> *item_list)
1160
1158
{
1161
1159
  int arg_count= item_list ? item_list->size() : 0;
1162
 
  switch (arg_count) {
 
1160
  switch (arg_count) 
 
1161
  {
1163
1162
  case 0:
1164
1163
    {
1165
1164
      return new (session->mem) Item_func_last_insert_id();
1169
1168
      Item *param_1= item_list->pop();
1170
1169
      return new (session->mem) Item_func_last_insert_id(param_1);
1171
1170
    }
1172
 
  default:
1173
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1174
1171
  }
 
1172
  my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1175
1173
  return NULL;
1176
1174
}
1177
1175
 
1178
 
 
1179
1176
Create_func_lcase Create_func_lcase::s_singleton;
1180
1177
Create_func_least Create_func_least::s_singleton;
1181
1178
 
1182
1179
Item* Create_func_least::create_native(Session *session, str_ref name, List<Item> *item_list)
1183
1180
{
1184
 
  int arg_count= item_list ? item_list->size() : 0;
1185
 
  if (arg_count < 2)
1186
 
  {
1187
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1188
 
    return NULL;
1189
 
  }
1190
 
 
1191
 
  return new (session->mem) Item_func_min(*item_list);
 
1181
  if (item_list && item_list->size() >= 2)
 
1182
    return new (session->mem) Item_func_min(*item_list);
 
1183
  my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
 
1184
  return NULL;
1192
1185
}
1193
1186
 
1194
1187
Create_func_load_file Create_func_load_file::s_singleton;
1195
1188
Create_func_locate Create_func_locate::s_singleton;
1196
1189
 
1197
 
Item*
1198
 
Create_func_locate::create_native(Session *session, str_ref name,
1199
 
                                  List<Item> *item_list)
 
1190
Item* Create_func_locate::create_native(Session *session, str_ref name, List<Item> *item_list)
1200
1191
{
1201
 
  int arg_count= item_list ? item_list->size() : 0;
1202
 
  switch (arg_count) 
 
1192
  switch (item_list ? item_list->size() : 0) 
1203
1193
  {
1204
1194
  case 2:
1205
1195
    {
1216
1206
      /* Yes, parameters in that order : 2, 1, 3 */
1217
1207
      return new (session->mem) Item_func_locate(param_2, param_1, param_3);
1218
1208
    }
1219
 
  default:
1220
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1221
1209
  }
 
1210
  my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1222
1211
  return NULL;
1223
1212
}
1224
1213
 
1225
1214
Create_func_make_set Create_func_make_set::s_singleton;
1226
1215
 
1227
 
Item*
1228
 
Create_func_make_set::create_native(Session *session_arg, str_ref name,
1229
 
                                    List<Item> *item_list)
 
1216
Item* Create_func_make_set::create_native(Session *session_arg, str_ref name, List<Item> *item_list)
1230
1217
{
1231
 
  int arg_count= item_list ? item_list->size() : 0;
1232
 
  if (arg_count < 2)
 
1218
  if (not item_list || item_list->size() < 2)
1233
1219
  {
1234
1220
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1235
1221
    return NULL;
1241
1227
 
1242
1228
Create_func_oct Create_func_oct::s_singleton;
1243
1229
 
1244
 
Item*
1245
 
Create_func_oct::create(Session *session, Item *arg1)
 
1230
Item* Create_func_oct::create(Session *session, Item *arg1)
1246
1231
{
1247
1232
  Item *i10= new (session->mem) Item_int((int32_t) 10,2);
1248
1233
  Item *i8= new (session->mem) Item_int((int32_t) 8,1);
1260
1245
  switch (item_list ? item_list->size() : 0) 
1261
1246
  {
1262
1247
  case 1:
1263
 
  {
1264
 
    Item *param_1= item_list->pop();
1265
 
    Item *i0 = new (session->mem) Item_int("0", 0, 1);
1266
 
    return new (session->mem) Item_func_round(param_1, i0, 0);
1267
 
  }
 
1248
    {
 
1249
      Item *param_1= item_list->pop();
 
1250
      Item *i0 = new (session->mem) Item_int("0", 0, 1);
 
1251
      return new (session->mem) Item_func_round(param_1, i0, 0);
 
1252
    }
1268
1253
  case 2:
1269
 
  {
1270
 
    Item *param_1= item_list->pop();
1271
 
    Item *param_2= item_list->pop();
1272
 
    return new (session->mem) Item_func_round(param_1, param_2, 0);
1273
 
  }
1274
 
  default:
1275
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1276
 
  }
 
1254
    {
 
1255
      Item *param_1= item_list->pop();
 
1256
      Item *param_2= item_list->pop();
 
1257
      return new (session->mem) Item_func_round(param_1, param_2, 0);
 
1258
    }
 
1259
  }
 
1260
  my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1277
1261
  return NULL;
1278
1262
}
1279
1263
 
1280
1264
Create_func_space Create_func_space::s_singleton;
1281
1265
 
1282
 
Item*
1283
 
Create_func_space::create(Session *session, Item *arg1)
 
1266
Item* Create_func_space::create(Session *session, Item *arg1)
1284
1267
{
1285
1268
  /**
1286
1269
    TODO: Fix Bug#23637
1313
1296
    return new (session->mem) Item_func_unix_timestamp();
1314
1297
  case 1:
1315
1298
    return new (session->mem) Item_func_unix_timestamp(item_list->pop());
1316
 
  default:
1317
 
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1318
1299
  }
 
1300
  my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1319
1301
  return NULL;
1320
1302
}
1321
1303