~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_create.h

  • Committer: Monty Taylor
  • Date: 2008-09-16 00:00:48 UTC
  • mto: This revision was merged to the branch mainline in revision 391.
  • Revision ID: monty@inaugust.com-20080916000048-3rvrv3gv9l0ad3gs
Fixed copyright headers in drizzled/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
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
19
19
 
20
20
/* Functions to create an item. Used by sql/sql_yacc.yy */
21
21
 
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>
27
 
 
28
 
namespace drizzled
29
 
{
 
22
#ifndef DRIZZLE_SERVER_ITEM_CREATE_H
 
23
#define DRIZZLE_SERVER_ITEM_CREATE_H
30
24
 
31
25
/**
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.
53
47
    <ul>
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>
60
54
    </ul>
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
65
59
  */
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;
67
61
 
68
62
protected:
69
63
  /** Constructor */
84
78
  /**
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
91
85
  */
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);
93
87
 
94
88
  /**
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
102
96
  */
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;
105
99
 
106
100
protected:
113
107
 
114
108
/**
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
118
113
*/
119
 
extern Create_func * find_native_function_builder(LEX_STRING name);
 
114
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
120
115
 
121
116
 
122
117
/**
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
126
121
*/
127
 
extern Create_qfunc * find_qualified_function_builder(Session *session);
 
122
extern Create_qfunc * find_qualified_function_builder(THD *thd);
128
123
 
129
124
 
130
125
/**
134
129
class Create_udf_func : public Create_func
135
130
{
136
131
public:
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);
138
133
 
139
134
  /**
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
145
140
  */
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);
149
142
 
150
143
  /** Singleton. */
151
144
  static Create_udf_func s_singleton;
158
151
};
159
152
 
160
153
Item*
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);
162
155
 
163
156
/**
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
168
161
  @param len TODO
170
163
  @param cs The character set
171
164
*/
172
165
Item *
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);
176
169
 
177
170
int item_create_init();
178
171
void item_create_cleanup();
179
172
 
180
 
} /* namespace drizzled */
181
 
 
182
 
#endif /* DRIZZLED_ITEM_CREATE_H */
 
173
#endif /* DRIZZLE_SERVER_ITEM_CREATE_H */