~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
 
21
 
 
22
20
#ifndef DRIZZLED_FUNCTION_FUNC_H
23
21
#define DRIZZLED_FUNCTION_FUNC_H
24
22
 
25
23
/// TODO: Rename this file - func.h is stupid.
26
24
 
27
 
#include <drizzled/charset_info.h>
28
25
#include <drizzled/item.h>
 
26
#include <drizzled/sql_list.h>
29
27
#include <drizzled/item/bin_string.h>
30
 
#include <drizzled/lex_string.h>
31
 
#include <drizzled/sql_list.h>
32
 
#include <drizzled/type/decimal.h>
33
 
 
34
 
#include <drizzled/visibility.h>
35
28
 
36
29
namespace drizzled
37
30
{
38
31
 
39
 
class DRIZZLED_API Item_func :
40
 
  public Item_result_field
 
32
class Item_func :public Item_result_field
41
33
{
42
 
  Session &_session;
43
 
 
44
34
protected:
45
35
  Item **args, *tmp_arg[2];
46
36
  /*
48
38
    0 means get this number from first argument
49
39
  */
50
40
  uint32_t allowed_arg_cols;
51
 
 
52
41
public:
53
42
 
54
43
  using Item::split_sum_func;
72
61
  enum Type type() const { return FUNC_ITEM; }
73
62
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
74
63
  virtual ~Item_func() {}
75
 
 
76
 
  Item_func(void);
77
 
 
78
 
  Item_func(Item *a);
79
 
  
80
 
  Item_func(Item *a,Item *b);
81
 
  
82
 
  Item_func(Item *a,Item *b,Item *c);
83
 
  
84
 
  Item_func(Item *a,Item *b,Item *c,Item *d);
85
 
  
86
 
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
87
 
  
 
64
  Item_func(void):
 
65
    allowed_arg_cols(1), arg_count(0)
 
66
  {
 
67
    with_sum_func= 0;
 
68
  }
 
69
  Item_func(Item *a):
 
70
    allowed_arg_cols(1), arg_count(1)
 
71
  {
 
72
    args= tmp_arg;
 
73
    args[0]= a;
 
74
    with_sum_func= a->with_sum_func;
 
75
  }
 
76
  Item_func(Item *a,Item *b):
 
77
    allowed_arg_cols(1), arg_count(2)
 
78
  {
 
79
    args= tmp_arg;
 
80
    args[0]= a; args[1]= b;
 
81
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
82
  }
 
83
  Item_func(Item *a,Item *b,Item *c):
 
84
    allowed_arg_cols(1)
 
85
  {
 
86
    arg_count= 0;
 
87
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
88
    {
 
89
      arg_count= 3;
 
90
      args[0]= a; args[1]= b; args[2]= c;
 
91
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
 
92
    }
 
93
  }
 
94
  Item_func(Item *a,Item *b,Item *c,Item *d):
 
95
    allowed_arg_cols(1)
 
96
  {
 
97
    arg_count= 0;
 
98
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
99
    {
 
100
      arg_count= 4;
 
101
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
 
102
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
103
        c->with_sum_func || d->with_sum_func;
 
104
    }
 
105
  }
 
106
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
 
107
    allowed_arg_cols(1)
 
108
  {
 
109
    arg_count= 5;
 
110
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
111
    {
 
112
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
 
113
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
114
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
 
115
    }
 
116
  }
88
117
  Item_func(List<Item> &list);
89
 
  
90
118
  // Constructor used for Item_cond_and/or (see Item comment)
91
119
  Item_func(Session *session, Item_func *item);
92
 
  
93
120
  bool fix_fields(Session *, Item **ref);
94
121
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
95
122
  table_map used_tables() const;
109
136
    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
110
137
    instead.
111
138
  */
112
 
  virtual const char *func_name() const { return NULL; }
 
139
  virtual const char *func_name() const { return NULL; };
113
140
  virtual bool const_item() const { return const_item_cache; }
114
141
  Item **arguments() const { return args; }
115
142
  void set_arguments(List<Item> &list);
132
159
  void count_real_length();
133
160
  void count_decimal_length();
134
161
 
135
 
  bool get_arg0_date(type::Time &ltime, uint32_t fuzzy_date);
136
 
  bool get_arg0_time(type::Time &ltime);
 
162
  bool get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
 
163
  bool get_arg0_time(DRIZZLE_TIME *ltime);
137
164
 
138
165
  bool is_null();
139
166
 
140
 
  virtual bool deterministic() const
141
 
  {
142
 
    return false;
143
 
  }
144
 
 
145
167
  void signal_divide_by_null();
146
168
 
147
169
  virtual Field *tmp_table_field() { return result_field; }
149
171
 
150
172
  Item *get_tmp_table_item(Session *session);
151
173
 
152
 
  type::Decimal *val_decimal(type::Decimal *);
 
174
  my_decimal *val_decimal(my_decimal *);
153
175
 
154
176
  bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
155
177
                          uint32_t flags);
166
188
                     void * arg, traverse_order order);
167
189
  double fix_result(double value);
168
190
 
169
 
  Session &getSession()
170
 
  {
171
 
    return _session;
172
 
  }
173
 
 
174
 
  Session *getSessionPtr()
175
 
  {
176
 
    return &_session;
177
 
  }
178
 
 
179
191
};
180
192
 
181
193
} /* namespace drizzled */