~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.h

  • Committer: Brian Aker
  • Date: 2010-12-28 04:57:17 UTC
  • mfrom: (2035.2.2 bool)
  • Revision ID: brian@tangent.org-20101228045717-6ax27qw6122h50sf
Merge in boolean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "drizzled/session.h"
35
35
#include "drizzled/common.h"
36
36
#include "drizzled/qsort_cmp.h"
 
37
#include "drizzled/item/function/boolean.h"
37
38
 
38
39
namespace drizzled
39
40
{
125
126
  friend class Item_func;
126
127
};
127
128
 
128
 
class Item_bool_func :public Item_int_func
129
 
{
130
 
public:
131
 
  Item_bool_func() :Item_int_func() {}
132
 
  Item_bool_func(Item *a) :Item_int_func(a) {}
133
 
  Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
134
 
  Item_bool_func(Session *session, Item_bool_func *item) :Item_int_func(session, item) {}
135
 
  bool is_bool_func() { return 1; }
136
 
  void fix_length_and_dec() { decimals=0; max_length=1; }
137
 
  uint32_t decimal_precision() const { return 1; }
138
 
};
139
 
 
140
129
 
141
130
/**
142
131
  Abstract Item class, to represent <code>X IS [NOT] (TRUE | FALSE)</code>
143
132
  boolean predicates.
144
133
*/
145
134
 
146
 
class Item_func_truth : public Item_bool_func
 
135
class Item_func_truth : public item::function::Boolean
147
136
{
148
137
public:
149
138
  virtual bool val_bool();
153
142
 
154
143
protected:
155
144
  Item_func_truth(Item *a, bool a_value, bool a_affirmative)
156
 
  : Item_bool_func(a), value(a_value), affirmative(a_affirmative)
 
145
  : item::function::Boolean(a), value(a_value), affirmative(a_affirmative)
157
146
  {}
158
147
 
159
148
  ~Item_func_truth()
242
231
    placed into a separate class called 'Item_in_optimizer'.
243
232
*/
244
233
 
245
 
class Item_in_optimizer: public Item_bool_func
 
234
class Item_in_optimizer: public item::function::Boolean
246
235
{
247
236
protected:
248
237
  Item_cache *cache;
256
245
  bool result_for_null_param;
257
246
public:
258
247
  Item_in_optimizer(Item *a, Item_in_subselect *b):
259
 
    Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
 
248
    item::function::Boolean(a, reinterpret_cast<Item *>(b)), cache(0),
260
249
    save_cache(0), result_for_null_param(UNKNOWN)
261
250
  { with_subselect= true; }
262
251
  bool fix_fields(Session *, Item **);
388
377
  { return true; }
389
378
};
390
379
 
391
 
class Item_func_not :public Item_bool_func
 
380
class Item_func_not :public item::function::Boolean
392
381
{
393
382
public:
394
 
  Item_func_not(Item *a) :Item_bool_func(a) {}
 
383
  Item_func_not(Item *a) :item::function::Boolean(a) {}
395
384
  int64_t val_int();
396
385
  enum Functype functype() const { return NOT_FUNC; }
397
386
  const char *func_name() const { return "not"; }
430
419
   - To wrap condition that is pushed down into subquery
431
420
*/
432
421
 
433
 
class Item_func_trig_cond: public Item_bool_func
 
422
class Item_func_trig_cond: public item::function::Boolean
434
423
{
435
424
  bool *trig_var;
436
425
public:
437
 
  Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; }
 
426
  Item_func_trig_cond(Item *a, bool *f) : item::function::Boolean(a) { trig_var= f; }
438
427
  int64_t val_int() { return *trig_var ? args[0]->val_int() : 1; }
439
428
  enum Functype functype() const { return TRIG_COND_FUNC; };
440
429
  const char *func_name() const { return "trigcond"; };
1286
1275
 
1287
1276
/* Functions used by where clause */
1288
1277
 
1289
 
class Item_func_isnull :public Item_bool_func
 
1278
class Item_func_isnull :public item::function::Boolean
1290
1279
{
1291
1280
protected:
1292
1281
  int64_t cached_value;
1293
1282
public:
1294
 
  Item_func_isnull(Item *a) :Item_bool_func(a) {}
 
1283
  Item_func_isnull(Item *a) :item::function::Boolean(a) {}
1295
1284
  int64_t val_int();
1296
1285
  enum Functype functype() const { return ISNULL_FUNC; }
1297
1286
  void fix_length_and_dec()
1353
1342
};
1354
1343
 
1355
1344
 
1356
 
class Item_func_isnotnull :public Item_bool_func
 
1345
class Item_func_isnotnull :public item::function::Boolean
1357
1346
{
1358
1347
  bool abort_on_null;
1359
1348
public:
1360
 
  Item_func_isnotnull(Item *a) :Item_bool_func(a), abort_on_null(0) {}
 
1349
  Item_func_isnotnull(Item *a) :item::function::Boolean(a), abort_on_null(0) {}
1361
1350
  int64_t val_int();
1362
1351
  enum Functype functype() const { return ISNOTNULL_FUNC; }
1363
1352
  void fix_length_and_dec()
1417
1406
 
1418
1407
typedef class Item COND;
1419
1408
 
1420
 
class Item_cond :public Item_bool_func
 
1409
class Item_cond :public item::function::Boolean
1421
1410
{
1422
1411
protected:
1423
1412
  List<Item> list;
1429
1418
  using Item::split_sum_func;
1430
1419
 
1431
1420
  /* Item_cond() is only used to create top level items */
1432
 
  Item_cond(): Item_bool_func(), abort_on_null(1)
 
1421
  Item_cond(): item::function::Boolean(), abort_on_null(1)
1433
1422
  { const_item_cache=0; }
1434
1423
  Item_cond(Item *i1,Item *i2)
1435
 
    :Item_bool_func(), abort_on_null(0)
 
1424
    :item::function::Boolean(), abort_on_null(0)
1436
1425
  {
1437
1426
    list.push_back(i1);
1438
1427
    list.push_back(i2);
1439
1428
  }
1440
1429
  Item_cond(Session *session, Item_cond *item);
1441
1430
  Item_cond(List<Item> &nlist)
1442
 
    :Item_bool_func(), list(nlist), abort_on_null(0) {}
 
1431
    :item::function::Boolean(), list(nlist), abort_on_null(0) {}
1443
1432
  bool add(Item *item) { return list.push_back(item); }
1444
1433
  bool add_at_head(Item *item) { return list.push_front(item); }
1445
1434
  void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
1543
1532
  object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
1544
1533
*/
1545
1534
 
1546
 
class Item_equal: public Item_bool_func
 
1535
class Item_equal: public item::function::Boolean
1547
1536
{
1548
1537
  List<Item_field> fields; /* list of equal field items                    */
1549
1538
  Item *const_item;        /* optional constant item equal to fields items */
1550
1539
  cmp_item *eval_item;
1551
1540
  bool cond_false;
 
1541
 
1552
1542
public:
1553
 
  inline Item_equal()
1554
 
    : Item_bool_func(), const_item(0), eval_item(0), cond_false(0)
1555
 
  { const_item_cache=0 ;}
 
1543
  inline Item_equal() :
 
1544
    item::function::Boolean(),
 
1545
    const_item(0),
 
1546
    eval_item(0),
 
1547
    cond_false(0)
 
1548
  {
 
1549
    const_item_cache=0;
 
1550
  }
 
1551
 
1556
1552
  Item_equal(Item_field *f1, Item_field *f2);
1557
1553
  Item_equal(Item *c, Item_field *f);
1558
1554
  Item_equal(Item_equal *item_equal);