~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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 by brian
clean slate
19
20
/* Functions to create an item. Used by sql/sql_yacc.yy */
21
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
22
#pragma once
1 by brian
clean slate
23
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
24
#include <drizzled/item/func.h>
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
25
#include <drizzled/plugin/function.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
29
1 by brian
clean slate
30
/**
31
  Public function builder interface.
32
  The parser (sql/sql_yacc.yy) uses a factory / builder pattern to
33
  construct an <code>Item</code> object for each function call.
34
  All the concrete function builders implements this interface,
35
  either directly or indirectly with some adapter helpers.
36
  Keeping the function creation separated from the bison grammar allows
37
  to simplify the parser, and avoid the need to introduce a new token
38
  for each function, which has undesirable side effects in the grammar.
39
*/
40
41
class Create_func
42
{
43
public:
44
  /**
45
    The builder create method.
46
    Given the function name and list or arguments, this method creates
47
    an <code>Item</code> that represents the function call.
48
    In case or errors, a NULL item is returned, and an error is reported.
520.1.22 by Brian Aker
Second pass of thd cleanup
49
    Note that the <code>session</code> object may be modified by the builder.
1 by brian
clean slate
50
    In particular, the following members/methods can be set/called,
51
    depending on the function called and the function possible side effects.
52
    <ul>
2227.4.8 by Olaf van der Spek
Session::lex()
53
      <li><code>session->lex().binlog_row_based_if_mixed</code></li>
54
      <li><code>session->lex().current_context()</code></li>
55
      <li><code>session->lex().safe_to_cache_query</code></li>
56
      <li><code>session->lex().uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
57
      <li><code>session->lex().uncacheable(UNCACHEABLE_RAND)</code></li>
58
      <li><code>session->lex().add_time_zone_tables_to_query_tables(session)</code></li>
1 by brian
clean slate
59
    </ul>
520.1.22 by Brian Aker
Second pass of thd cleanup
60
    @param session The current thread
1 by brian
clean slate
61
    @param name The function name
62
    @param item_list The list of arguments to the function, can be NULL
63
    @return An item representing the parsed function call, or NULL
64
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
65
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list) = 0;
1 by brian
clean slate
66
67
protected:
68
  /** Constructor */
69
  Create_func() {}
70
  /** Destructor */
71
  virtual ~Create_func() {}
72
};
73
74
/**
75
  Function builder for qualified functions.
76
  This builder is used with functions call using a qualified function name
77
  syntax, as in <code>db.func(expr, expr, ...)</code>.
78
*/
79
80
class Create_qfunc : public Create_func
81
{
82
public:
83
  /**
84
    The builder create method, for unqualified functions.
85
    This builder will use the current database for the database name.
520.1.22 by Brian Aker
Second pass of thd cleanup
86
    @param session The current thread
1 by brian
clean slate
87
    @param name The function name
88
    @param item_list The list of arguments to the function, can be NULL
89
    @return An item representing the parsed function call
90
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
91
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
92
93
  /**
94
    The builder create method, for qualified functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
95
    @param session The current thread
1 by brian
clean slate
96
    @param db The database name
97
    @param name The function name
98
    @param use_explicit_name Should the function be represented as 'db.name'?
99
    @param item_list The list of arguments to the function, can be NULL
100
    @return An item representing the parsed function call
101
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
102
  virtual Item* create(Session *session, LEX_STRING db, LEX_STRING name,
1 by brian
clean slate
103
                       bool use_explicit_name, List<Item> *item_list) = 0;
104
105
protected:
106
  /** Constructor. */
107
  Create_qfunc() {}
108
  /** Destructor. */
109
  virtual ~Create_qfunc() {}
110
};
111
112
113
/**
114
  Find the native function builder associated with a given function name.
115
  @param name The native function name
116
  @return The native function builder associated with the name, or NULL
117
*/
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
118
extern Create_func * find_native_function_builder(LEX_STRING name);
1 by brian
clean slate
119
120
121
/**
122
  Find the function builder for qualified functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
123
  @param session The current thread
1 by brian
clean slate
124
  @return A function builder for qualified functions
125
*/
520.1.22 by Brian Aker
Second pass of thd cleanup
126
extern Create_qfunc * find_qualified_function_builder(Session *session);
1 by brian
clean slate
127
128
129
/**
130
  Function builder for User Defined Functions.
131
*/
132
133
class Create_udf_func : public Create_func
134
{
135
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
136
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
137
138
  /**
139
    The builder create method, for User Defined Functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
140
    @param session The current thread
1 by brian
clean slate
141
    @param fct The User Defined Function metadata
142
    @param item_list The list of arguments to the function, can be NULL
143
    @return An item representing the parsed function call
144
  */
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
145
  Item *create(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
146
               const plugin::Function *fct,
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
147
               List<Item> *item_list);
1 by brian
clean slate
148
149
  /** Singleton. */
150
  static Create_udf_func s_singleton;
151
152
protected:
153
  /** Constructor. */
154
  Create_udf_func() {}
155
  /** Destructor. */
156
  virtual ~Create_udf_func() {}
157
};
158
159
Item*
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
160
create_func_char_cast(Session *session, Item *a, int len, const charset_info_st * const cs);
1 by brian
clean slate
161
162
/**
163
  Builder for cast expressions.
520.1.22 by Brian Aker
Second pass of thd cleanup
164
  @param session The current thread
1 by brian
clean slate
165
  @param a The item to cast
166
  @param cast_type the type casted into
167
  @param len TODO
168
  @param dec TODO
169
  @param cs The character set
170
*/
171
Item *
520.1.22 by Brian Aker
Second pass of thd cleanup
172
create_func_cast(Session *session, Item *a, Cast_target cast_type,
1 by brian
clean slate
173
                 const char *len, const char *dec,
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
174
                 const charset_info_st * const cs);
243.1.7 by Jay Pipes
* Moved the Item factory creation functions into the item_create.h header,
175
176
int item_create_init();
177
void item_create_cleanup();
178
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
179
} /* namespace drizzled */
180