~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.h

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
15
19
 
16
20
/* Functions to create an item. Used by sql/sql_yacc.yy */
17
21
 
18
 
#ifndef DRIZZLE_SERVER_ITEM_CREATE_H
19
 
#define DRIZZLE_SERVER_ITEM_CREATE_H
 
22
#ifndef DRIZZLED_ITEM_CREATE_H
 
23
#define DRIZZLED_ITEM_CREATE_H
 
24
 
 
25
#include <drizzled/item/func.h>
 
26
#include <drizzled/plugin/function.h>
20
27
 
21
28
/**
22
29
  Public function builder interface.
37
44
    Given the function name and list or arguments, this method creates
38
45
    an <code>Item</code> that represents the function call.
39
46
    In case or errors, a NULL item is returned, and an error is reported.
40
 
    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.
41
48
    In particular, the following members/methods can be set/called,
42
49
    depending on the function called and the function possible side effects.
43
50
    <ul>
44
 
      <li><code>thd->lex->binlog_row_based_if_mixed</code></li>
45
 
      <li><code>thd->lex->current_context()</code></li>
46
 
      <li><code>thd->lex->safe_to_cache_query</code></li>
47
 
      <li><code>thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
48
 
      <li><code>thd->lex->uncacheable(UNCACHEABLE_RAND)</code></li>
49
 
      <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>
50
57
    </ul>
51
 
    @param thd The current thread
 
58
    @param session The current thread
52
59
    @param name The function name
53
60
    @param item_list The list of arguments to the function, can be NULL
54
61
    @return An item representing the parsed function call, or NULL
55
62
  */
56
 
  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;
57
64
 
58
65
protected:
59
66
  /** Constructor */
74
81
  /**
75
82
    The builder create method, for unqualified functions.
76
83
    This builder will use the current database for the database name.
77
 
    @param thd The current thread
 
84
    @param session The current thread
78
85
    @param name The function name
79
86
    @param item_list The list of arguments to the function, can be NULL
80
87
    @return An item representing the parsed function call
81
88
  */
82
 
  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);
83
90
 
84
91
  /**
85
92
    The builder create method, for qualified functions.
86
 
    @param thd The current thread
 
93
    @param session The current thread
87
94
    @param db The database name
88
95
    @param name The function name
89
96
    @param use_explicit_name Should the function be represented as 'db.name'?
90
97
    @param item_list The list of arguments to the function, can be NULL
91
98
    @return An item representing the parsed function call
92
99
  */
93
 
  virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name,
 
100
  virtual Item* create(Session *session, LEX_STRING db, LEX_STRING name,
94
101
                       bool use_explicit_name, List<Item> *item_list) = 0;
95
102
 
96
103
protected:
103
110
 
104
111
/**
105
112
  Find the native function builder associated with a given function name.
106
 
  @param thd The current thread
107
113
  @param name The native function name
108
114
  @return The native function builder associated with the name, or NULL
109
115
*/
110
 
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
 
116
extern Create_func * find_native_function_builder(LEX_STRING name);
111
117
 
112
118
 
113
119
/**
114
120
  Find the function builder for qualified functions.
115
 
  @param thd The current thread
 
121
  @param session The current thread
116
122
  @return A function builder for qualified functions
117
123
*/
118
 
extern Create_qfunc * find_qualified_function_builder(THD *thd);
 
124
extern Create_qfunc * find_qualified_function_builder(Session *session);
119
125
 
120
126
 
121
127
/**
125
131
class Create_udf_func : public Create_func
126
132
{
127
133
public:
128
 
  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);
129
135
 
130
136
  /**
131
137
    The builder create method, for User Defined Functions.
132
 
    @param thd The current thread
 
138
    @param session The current thread
133
139
    @param fct The User Defined Function metadata
134
140
    @param item_list The list of arguments to the function, can be NULL
135
141
    @return An item representing the parsed function call
136
142
  */
137
 
  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);
138
146
 
139
147
  /** Singleton. */
140
148
  static Create_udf_func s_singleton;
147
155
};
148
156
 
149
157
Item*
150
 
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);
151
159
 
152
160
/**
153
161
  Builder for cast expressions.
154
 
  @param thd The current thread
 
162
  @param session The current thread
155
163
  @param a The item to cast
156
164
  @param cast_type the type casted into
157
165
  @param len TODO
159
167
  @param cs The character set
160
168
*/
161
169
Item *
162
 
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
 
170
create_func_cast(Session *session, Item *a, Cast_target cast_type,
163
171
                 const char *len, const char *dec,
164
172
                 const CHARSET_INFO * const cs);
165
173
 
166
174
int item_create_init();
167
175
void item_create_cleanup();
168
176
 
169
 
#endif /* DRIZZLE_SERVER_ITEM_CREATE_H */
 
177
#endif /* DRIZZLED_ITEM_CREATE_H */