~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.h

MergedĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#ifndef DRIZZLE_SERVER_ITEM_CREATE_H
23
23
#define DRIZZLE_SERVER_ITEM_CREATE_H
24
24
 
 
25
#include <drizzled/item/func.h>
 
26
#include <drizzled/plugin/function.h>
 
27
 
25
28
/**
26
29
  Public function builder interface.
27
30
  The parser (sql/sql_yacc.yy) uses a factory / builder pattern to
41
44
    Given the function name and list or arguments, this method creates
42
45
    an <code>Item</code> that represents the function call.
43
46
    In case or errors, a NULL item is returned, and an error is reported.
44
 
    Note that the <code>thd</code> object may be modified by the builder.
 
47
    Note that the <code>session</code> object may be modified by the builder.
45
48
    In particular, the following members/methods can be set/called,
46
49
    depending on the function called and the function possible side effects.
47
50
    <ul>
48
 
      <li><code>thd->lex->binlog_row_based_if_mixed</code></li>
49
 
      <li><code>thd->lex->current_context()</code></li>
50
 
      <li><code>thd->lex->safe_to_cache_query</code></li>
51
 
      <li><code>thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
52
 
      <li><code>thd->lex->uncacheable(UNCACHEABLE_RAND)</code></li>
53
 
      <li><code>thd->lex->add_time_zone_tables_to_query_tables(thd)</code></li>
 
51
      <li><code>session->lex->binlog_row_based_if_mixed</code></li>
 
52
      <li><code>session->lex->current_context()</code></li>
 
53
      <li><code>session->lex->safe_to_cache_query</code></li>
 
54
      <li><code>session->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
 
55
      <li><code>session->lex->uncacheable(UNCACHEABLE_RAND)</code></li>
 
56
      <li><code>session->lex->add_time_zone_tables_to_query_tables(session)</code></li>
54
57
    </ul>
55
 
    @param thd The current thread
 
58
    @param session The current thread
56
59
    @param name The function name
57
60
    @param item_list The list of arguments to the function, can be NULL
58
61
    @return An item representing the parsed function call, or NULL
59
62
  */
60
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list) = 0;
 
63
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list) = 0;
61
64
 
62
65
protected:
63
66
  /** Constructor */
78
81
  /**
79
82
    The builder create method, for unqualified functions.
80
83
    This builder will use the current database for the database name.
81
 
    @param thd The current thread
 
84
    @param session The current thread
82
85
    @param name The function name
83
86
    @param item_list The list of arguments to the function, can be NULL
84
87
    @return An item representing the parsed function call
85
88
  */
86
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
89
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
87
90
 
88
91
  /**
89
92
    The builder create method, for qualified functions.
90
 
    @param thd The current thread
 
93
    @param session The current thread
91
94
    @param db The database name
92
95
    @param name The function name
93
96
    @param use_explicit_name Should the function be represented as 'db.name'?
94
97
    @param item_list The list of arguments to the function, can be NULL
95
98
    @return An item representing the parsed function call
96
99
  */
97
 
  virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name,
 
100
  virtual Item* create(Session *session, LEX_STRING db, LEX_STRING name,
98
101
                       bool use_explicit_name, List<Item> *item_list) = 0;
99
102
 
100
103
protected:
107
110
 
108
111
/**
109
112
  Find the native function builder associated with a given function name.
110
 
  @param thd The current thread
111
113
  @param name The native function name
112
114
  @return The native function builder associated with the name, or NULL
113
115
*/
114
 
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
 
116
extern Create_func * find_native_function_builder(LEX_STRING name);
115
117
 
116
118
 
117
119
/**
118
120
  Find the function builder for qualified functions.
119
 
  @param thd The current thread
 
121
  @param session The current thread
120
122
  @return A function builder for qualified functions
121
123
*/
122
 
extern Create_qfunc * find_qualified_function_builder(THD *thd);
 
124
extern Create_qfunc * find_qualified_function_builder(Session *session);
123
125
 
124
126
 
125
127
/**
129
131
class Create_udf_func : public Create_func
130
132
{
131
133
public:
132
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
134
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
133
135
 
134
136
  /**
135
137
    The builder create method, for User Defined Functions.
136
 
    @param thd The current thread
 
138
    @param session The current thread
137
139
    @param fct The User Defined Function metadata
138
140
    @param item_list The list of arguments to the function, can be NULL
139
141
    @return An item representing the parsed function call
140
142
  */
141
 
  Item *create(THD *thd, udf_func *fct, List<Item> *item_list);
 
143
  Item *create(Session *session,
 
144
               const drizzled::plugin::Function *fct,
 
145
               List<Item> *item_list);
142
146
 
143
147
  /** Singleton. */
144
148
  static Create_udf_func s_singleton;
151
155
};
152
156
 
153
157
Item*
154
 
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs);
 
158
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs);
155
159
 
156
160
/**
157
161
  Builder for cast expressions.
158
 
  @param thd The current thread
 
162
  @param session The current thread
159
163
  @param a The item to cast
160
164
  @param cast_type the type casted into
161
165
  @param len TODO
163
167
  @param cs The character set
164
168
*/
165
169
Item *
166
 
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
 
170
create_func_cast(Session *session, Item *a, Cast_target cast_type,
167
171
                 const char *len, const char *dec,
168
172
                 const CHARSET_INFO * const cs);
169
173