~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/item_create.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

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