1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
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
20
20
/* Functions to create an item. Used by sql/sql_yacc.yy */
22
#ifndef DRIZZLED_ITEM_CREATE_H
23
#define DRIZZLED_ITEM_CREATE_H
25
#include <drizzled/item/func.h>
26
#include <drizzled/plugin/function.h>
22
#ifndef DRIZZLE_SERVER_ITEM_CREATE_H
23
#define DRIZZLE_SERVER_ITEM_CREATE_H
32
26
Public function builder interface.
47
41
Given the function name and list or arguments, this method creates
48
42
an <code>Item</code> that represents the function call.
49
43
In case or errors, a NULL item is returned, and an error is reported.
50
Note that the <code>session</code> object may be modified by the builder.
44
Note that the <code>thd</code> object may be modified by the builder.
51
45
In particular, the following members/methods can be set/called,
52
46
depending on the function called and the function possible side effects.
54
<li><code>session->lex->binlog_row_based_if_mixed</code></li>
55
<li><code>session->lex->current_context()</code></li>
56
<li><code>session->lex->safe_to_cache_query</code></li>
57
<li><code>session->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
58
<li><code>session->lex->uncacheable(UNCACHEABLE_RAND)</code></li>
59
<li><code>session->lex->add_time_zone_tables_to_query_tables(session)</code></li>
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>
61
@param session The current thread
55
@param thd The current thread
62
56
@param name The function name
63
57
@param item_list The list of arguments to the function, can be NULL
64
58
@return An item representing the parsed function call, or NULL
66
virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list) = 0;
60
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list) = 0;
85
79
The builder create method, for unqualified functions.
86
80
This builder will use the current database for the database name.
87
@param session The current thread
81
@param thd The current thread
88
82
@param name The function name
89
83
@param item_list The list of arguments to the function, can be NULL
90
84
@return An item representing the parsed function call
92
virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
86
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
95
89
The builder create method, for qualified functions.
96
@param session The current thread
90
@param thd The current thread
97
91
@param db The database name
98
92
@param name The function name
99
93
@param use_explicit_name Should the function be represented as 'db.name'?
100
94
@param item_list The list of arguments to the function, can be NULL
101
95
@return An item representing the parsed function call
103
virtual Item* create(Session *session, LEX_STRING db, LEX_STRING name,
97
virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name,
104
98
bool use_explicit_name, List<Item> *item_list) = 0;
115
109
Find the native function builder associated with a given function name.
110
@param thd The current thread
116
111
@param name The native function name
117
112
@return The native function builder associated with the name, or NULL
119
extern Create_func * find_native_function_builder(LEX_STRING name);
114
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
123
118
Find the function builder for qualified functions.
124
@param session The current thread
119
@param thd The current thread
125
120
@return A function builder for qualified functions
127
extern Create_qfunc * find_qualified_function_builder(Session *session);
122
extern Create_qfunc * find_qualified_function_builder(THD *thd);
134
129
class Create_udf_func : public Create_func
137
virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
132
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
140
135
The builder create method, for User Defined Functions.
141
@param session The current thread
136
@param thd The current thread
142
137
@param fct The User Defined Function metadata
143
138
@param item_list The list of arguments to the function, can be NULL
144
139
@return An item representing the parsed function call
146
Item *create(Session *session,
147
const plugin::Function *fct,
148
List<Item> *item_list);
141
Item *create(THD *thd, udf_func *fct, List<Item> *item_list);
150
143
/** Singleton. */
151
144
static Create_udf_func s_singleton;
161
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, const CHARSET_INFO * const cs);
164
157
Builder for cast expressions.
165
@param session The current thread
158
@param thd The current thread
166
159
@param a The item to cast
167
160
@param cast_type the type casted into
170
163
@param cs The character set
173
create_func_cast(Session *session, Item *a, Cast_target cast_type,
166
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
174
167
const char *len, const char *dec,
175
168
const CHARSET_INFO * const cs);
177
170
int item_create_init();
178
171
void item_create_cleanup();
180
} /* namespace drizzled */
182
#endif /* DRIZZLED_ITEM_CREATE_H */
173
#endif /* DRIZZLE_SERVER_ITEM_CREATE_H */