~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_create.h

  • Committer: Jay Pipes
  • Date: 2008-08-01 03:28:12 UTC
  • mto: (264.1.6 codestyle)
  • mto: This revision was merged to the branch mainline in revision 247.
  • Revision ID: jay@mysql.com-20080801032812-8gl0ukak1qcgfyyt
removed view_store_options() function - wasn't used anywhere.

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 */
15
 
 
16
 
/* Functions to create an item. Used by sql/sql_yacc.yy */
17
 
 
18
 
#ifndef DRIZZLE_SERVER_ITEM_CREATE_H
19
 
#define DRIZZLE_SERVER_ITEM_CREATE_H
20
 
 
21
 
/**
22
 
  Public function builder interface.
23
 
  The parser (sql/sql_yacc.yy) uses a factory / builder pattern to
24
 
  construct an <code>Item</code> object for each function call.
25
 
  All the concrete function builders implements this interface,
26
 
  either directly or indirectly with some adapter helpers.
27
 
  Keeping the function creation separated from the bison grammar allows
28
 
  to simplify the parser, and avoid the need to introduce a new token
29
 
  for each function, which has undesirable side effects in the grammar.
30
 
*/
31
 
 
32
 
class Create_func
33
 
{
34
 
public:
35
 
  /**
36
 
    The builder create method.
37
 
    Given the function name and list or arguments, this method creates
38
 
    an <code>Item</code> that represents the function call.
39
 
    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.
41
 
    In particular, the following members/methods can be set/called,
42
 
    depending on the function called and the function possible side effects.
43
 
    <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>
50
 
    </ul>
51
 
    @param thd The current thread
52
 
    @param name The function name
53
 
    @param item_list The list of arguments to the function, can be NULL
54
 
    @return An item representing the parsed function call, or NULL
55
 
  */
56
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list) = 0;
57
 
 
58
 
protected:
59
 
  /** Constructor */
60
 
  Create_func() {}
61
 
  /** Destructor */
62
 
  virtual ~Create_func() {}
63
 
};
64
 
 
65
 
/**
66
 
  Function builder for qualified functions.
67
 
  This builder is used with functions call using a qualified function name
68
 
  syntax, as in <code>db.func(expr, expr, ...)</code>.
69
 
*/
70
 
 
71
 
class Create_qfunc : public Create_func
72
 
{
73
 
public:
74
 
  /**
75
 
    The builder create method, for unqualified functions.
76
 
    This builder will use the current database for the database name.
77
 
    @param thd The current thread
78
 
    @param name The function name
79
 
    @param item_list The list of arguments to the function, can be NULL
80
 
    @return An item representing the parsed function call
81
 
  */
82
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
83
 
 
84
 
  /**
85
 
    The builder create method, for qualified functions.
86
 
    @param thd The current thread
87
 
    @param db The database name
88
 
    @param name The function name
89
 
    @param use_explicit_name Should the function be represented as 'db.name'?
90
 
    @param item_list The list of arguments to the function, can be NULL
91
 
    @return An item representing the parsed function call
92
 
  */
93
 
  virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name,
94
 
                       bool use_explicit_name, List<Item> *item_list) = 0;
95
 
 
96
 
protected:
97
 
  /** Constructor. */
98
 
  Create_qfunc() {}
99
 
  /** Destructor. */
100
 
  virtual ~Create_qfunc() {}
101
 
};
102
 
 
103
 
 
104
 
/**
105
 
  Find the native function builder associated with a given function name.
106
 
  @param thd The current thread
107
 
  @param name The native function name
108
 
  @return The native function builder associated with the name, or NULL
109
 
*/
110
 
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
111
 
 
112
 
 
113
 
/**
114
 
  Find the function builder for qualified functions.
115
 
  @param thd The current thread
116
 
  @return A function builder for qualified functions
117
 
*/
118
 
extern Create_qfunc * find_qualified_function_builder(THD *thd);
119
 
 
120
 
 
121
 
/**
122
 
  Function builder for User Defined Functions.
123
 
*/
124
 
 
125
 
class Create_udf_func : public Create_func
126
 
{
127
 
public:
128
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
129
 
 
130
 
  /**
131
 
    The builder create method, for User Defined Functions.
132
 
    @param thd The current thread
133
 
    @param fct The User Defined Function metadata
134
 
    @param item_list The list of arguments to the function, can be NULL
135
 
    @return An item representing the parsed function call
136
 
  */
137
 
  Item *create(THD *thd, udf_func *fct, List<Item> *item_list);
138
 
 
139
 
  /** Singleton. */
140
 
  static Create_udf_func s_singleton;
141
 
 
142
 
protected:
143
 
  /** Constructor. */
144
 
  Create_udf_func() {}
145
 
  /** Destructor. */
146
 
  virtual ~Create_udf_func() {}
147
 
};
148
 
 
149
 
Item*
150
 
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs);
151
 
 
152
 
/**
153
 
  Builder for cast expressions.
154
 
  @param thd The current thread
155
 
  @param a The item to cast
156
 
  @param cast_type the type casted into
157
 
  @param len TODO
158
 
  @param dec TODO
159
 
  @param cs The character set
160
 
*/
161
 
Item *
162
 
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
163
 
                 const char *len, const char *dec,
164
 
                 const CHARSET_INFO * const cs);
165
 
 
166
 
int item_create_init();
167
 
void item_create_cleanup();
168
 
 
169
 
#endif /* DRIZZLE_SERVER_ITEM_CREATE_H */