1
by brian
clean slate |
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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
||
17 |
/* A lexical scanner on a temporary buffer with a yacc interface */
|
|
18 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
19 |
#include <config.h> |
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
20 |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
21 |
#define DRIZZLE_LEX 1
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/sql_reserved_words.h> |
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
24 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
25 |
#include <drizzled/configmake.h> |
26 |
#include <drizzled/item/num.h> |
|
27 |
#include <drizzled/error.h> |
|
28 |
#include <drizzled/session.h> |
|
29 |
#include <drizzled/sql_base.h> |
|
30 |
#include <drizzled/lookup_symbol.h> |
|
31 |
#include <drizzled/index_hint.h> |
|
2154.2.24
by Brian Aker
Merge in all changes for current_session, etc. |
32 |
#include <drizzled/select_result.h> |
2198.1.2
by Olaf van der Spek
Refactor includes |
33 |
#include <drizzled/item/subselect.h> |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
34 |
#include <drizzled/statement.h> |
2234.1.4
by Olaf van der Spek
Refactor includes |
35 |
#include <drizzled/sql_lex.h> |
2239.1.6
by Olaf van der Spek
Refactor includes |
36 |
#include <drizzled/plugin.h> |
2318.8.7
by Olaf van der Spek
Add const |
37 |
#include <drizzled/lex_input_stream.h> |
779.4.5
by Monty Taylor
Replaced gen_lex_hash with gperf. Yay for no more building tools to build source!!! |
38 |
|
1502.3.1
by iwamatsu at nigauri
Add cstdio include to files needing it. Fixes the build on some debian |
39 |
#include <cstdio> |
908.1.15
by Monty Taylor
Updated comment version indicators to handle drizzle versions. |
40 |
#include <ctype.h> |
41 |
||
2200.2.11
by Stewart Smith
move the message::AlterTable header include into sql_lex.cc so we can just have a forward declaration in sql_lex.h - greatly speeding compile time |
42 |
#include <drizzled/message/alter_table.pb.h> |
43 |
||
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
44 |
union ParserType; |
45 |
||
908.1.15
by Monty Taylor
Updated comment version indicators to handle drizzle versions. |
46 |
using namespace std; |
779.4.5
by Monty Taylor
Replaced gen_lex_hash with gperf. Yay for no more building tools to build source!!! |
47 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
48 |
/* Stay outside of the namespace because otherwise bison goes nuts */
|
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
49 |
int base_sql_lex(ParserType *arg, drizzled::Session *yysession); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
50 |
|
2318.6.57
by Olaf van der Spek
Refactor |
51 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
52 |
|
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
53 |
static int lex_one_token(ParserType *arg, drizzled::Session *yysession); |
1
by brian
clean slate |
54 |
|
1109.1.5
by Brian Aker
More extraction from sql_base |
55 |
/**
|
56 |
save order by and tables in own lists.
|
|
57 |
*/
|
|
2318.6.30
by Olaf van der Spek
Refactor |
58 |
static void add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc) |
1109.1.5
by Brian Aker
More extraction from sql_base |
59 |
{
|
2318.6.57
by Olaf van der Spek
Refactor |
60 |
Order* order = new (session->mem) Order; |
1109.1.5
by Brian Aker
More extraction from sql_base |
61 |
order->item_ptr= item; |
62 |
order->item= &order->item_ptr; |
|
63 |
order->asc = asc; |
|
64 |
order->free_me=0; |
|
65 |
order->used=0; |
|
66 |
order->counter_used= 0; |
|
2073.1.2
by Brian Aker
Basic DDL for catalog. |
67 |
list.link_in_list((unsigned char*) order, (unsigned char**) &order->next); |
1109.1.5
by Brian Aker
More extraction from sql_base |
68 |
}
|
69 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
70 |
Lex_input_stream::Lex_input_stream(Session *session, |
1
by brian
clean slate |
71 |
const char* buffer, |
2073.1.2
by Brian Aker
Basic DDL for catalog. |
72 |
unsigned int length) : |
73 |
m_session(session), |
|
1
by brian
clean slate |
74 |
yylineno(1), |
75 |
yytoklen(0), |
|
76 |
yylval(NULL), |
|
77 |
lookahead_token(END_OF_INPUT), |
|
78 |
lookahead_yylval(NULL), |
|
79 |
m_ptr(buffer), |
|
80 |
m_tok_start(NULL), |
|
81 |
m_tok_end(NULL), |
|
82 |
m_end_of_query(buffer + length), |
|
83 |
m_tok_start_prev(NULL), |
|
84 |
m_buf(buffer), |
|
85 |
m_buf_length(length), |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
86 |
m_echo(true), |
1
by brian
clean slate |
87 |
m_cpp_tok_start(NULL), |
88 |
m_cpp_tok_start_prev(NULL), |
|
89 |
m_cpp_tok_end(NULL), |
|
90 |
m_body_utf8(NULL), |
|
91 |
m_cpp_utf8_processed_ptr(NULL), |
|
92 |
next_state(MY_LEX_START), |
|
93 |
ignore_space(1), |
|
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
94 |
in_comment(NO_COMMENT) |
1
by brian
clean slate |
95 |
{
|
2318.6.30
by Olaf van der Spek
Refactor |
96 |
m_cpp_buf= (char*) session->mem.alloc(length + 1); |
1
by brian
clean slate |
97 |
m_cpp_ptr= m_cpp_buf; |
98 |
}
|
|
99 |
||
100 |
/**
|
|
101 |
@brief The operation appends unprocessed part of pre-processed buffer till
|
|
102 |
the given pointer (ptr) and sets m_cpp_utf8_processed_ptr to end_ptr.
|
|
103 |
||
104 |
The idea is that some tokens in the pre-processed buffer (like character
|
|
105 |
set introducers) should be skipped.
|
|
106 |
||
107 |
Example:
|
|
108 |
CPP buffer: SELECT 'str1', _latin1 'str2';
|
|
109 |
m_cpp_utf8_processed_ptr -- points at the "SELECT ...";
|
|
110 |
In order to skip "_latin1", the following call should be made:
|
|
111 |
body_utf8_append(<pointer to "_latin1 ...">, <pointer to " 'str2'...">)
|
|
112 |
||
113 |
@param ptr Pointer in the pre-processed buffer, which specifies the
|
|
114 |
end of the chunk, which should be appended to the utf8
|
|
115 |
body.
|
|
116 |
@param end_ptr Pointer in the pre-processed buffer, to which
|
|
117 |
m_cpp_utf8_processed_ptr will be set in the end of the
|
|
118 |
operation.
|
|
119 |
*/
|
|
120 |
void Lex_input_stream::body_utf8_append(const char *ptr, |
|
121 |
const char *end_ptr) |
|
122 |
{
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
123 |
assert(m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length); |
124 |
assert(m_cpp_buf <= end_ptr && end_ptr <= m_cpp_buf + m_buf_length); |
|
1
by brian
clean slate |
125 |
|
126 |
if (!m_body_utf8) |
|
127 |
return; |
|
128 |
||
129 |
if (m_cpp_utf8_processed_ptr >= ptr) |
|
130 |
return; |
|
131 |
||
132 |
int bytes_to_copy= ptr - m_cpp_utf8_processed_ptr; |
|
133 |
||
134 |
memcpy(m_body_utf8_ptr, m_cpp_utf8_processed_ptr, bytes_to_copy); |
|
135 |
m_body_utf8_ptr += bytes_to_copy; |
|
136 |
*m_body_utf8_ptr= 0; |
|
137 |
||
138 |
m_cpp_utf8_processed_ptr= end_ptr; |
|
139 |
}
|
|
140 |
||
141 |
/**
|
|
142 |
The operation appends unprocessed part of the pre-processed buffer till
|
|
143 |
the given pointer (ptr) and sets m_cpp_utf8_processed_ptr to ptr.
|
|
144 |
||
145 |
@param ptr Pointer in the pre-processed buffer, which specifies the end
|
|
146 |
of the chunk, which should be appended to the utf8 body.
|
|
147 |
*/
|
|
148 |
void Lex_input_stream::body_utf8_append(const char *ptr) |
|
149 |
{
|
|
150 |
body_utf8_append(ptr, ptr); |
|
151 |
}
|
|
152 |
||
153 |
/**
|
|
154 |
The operation converts the specified text literal to the utf8 and appends
|
|
155 |
the result to the utf8-body.
|
|
156 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
157 |
@param session Thread context.
|
1
by brian
clean slate |
158 |
@param txt Text literal.
|
159 |
@param txt_cs Character set of the text literal.
|
|
160 |
@param end_ptr Pointer in the pre-processed buffer, to which
|
|
161 |
m_cpp_utf8_processed_ptr will be set in the end of the
|
|
162 |
operation.
|
|
163 |
*/
|
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
164 |
void Lex_input_stream::body_utf8_append_literal(const lex_string_t *txt, |
1
by brian
clean slate |
165 |
const char *end_ptr) |
166 |
{
|
|
167 |
if (!m_cpp_utf8_processed_ptr) |
|
168 |
return; |
|
169 |
||
170 |
/* NOTE: utf_txt.length is in bytes, not in symbols. */
|
|
171 |
||
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
172 |
memcpy(m_body_utf8_ptr, txt->str, txt->length); |
173 |
m_body_utf8_ptr += txt->length; |
|
1
by brian
clean slate |
174 |
*m_body_utf8_ptr= 0; |
175 |
||
176 |
m_cpp_utf8_processed_ptr= end_ptr; |
|
177 |
}
|
|
178 |
||
179 |
/*
|
|
180 |
This is called before every query that is to be parsed.
|
|
181 |
Because of this, it's critical to not do too much things here.
|
|
182 |
(We already do too much here)
|
|
183 |
*/
|
|
1897.1.7
by Brian Aker
Partial encapsulation of lex_start. |
184 |
void LEX::start(Session *arg) |
185 |
{
|
|
186 |
lex_start(arg); |
|
187 |
}
|
|
188 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
189 |
void lex_start(Session *session) |
1
by brian
clean slate |
190 |
{
|
2227.4.10
by Olaf van der Spek
Session::lex() |
191 |
LEX *lex= &session->lex(); |
1
by brian
clean slate |
192 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
193 |
lex->session= lex->unit.session= session; |
1
by brian
clean slate |
194 |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
195 |
lex->context_stack.clear(); |
1
by brian
clean slate |
196 |
lex->unit.init_query(); |
197 |
lex->unit.init_select(); |
|
198 |
/* 'parent_lex' is used in init_query() so it must be before it. */
|
|
199 |
lex->select_lex.parent_lex= lex; |
|
200 |
lex->select_lex.init_query(); |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
201 |
lex->value_list.clear(); |
202 |
lex->update_list.clear(); |
|
203 |
lex->auxiliary_table_list.clear(); |
|
1
by brian
clean slate |
204 |
lex->unit.next= lex->unit.master= |
205 |
lex->unit.link_next= lex->unit.return_to= 0; |
|
206 |
lex->unit.prev= lex->unit.link_prev= 0; |
|
207 |
lex->unit.slave= lex->unit.global_parameters= lex->current_select= |
|
208 |
lex->all_selects_list= &lex->select_lex; |
|
209 |
lex->select_lex.master= &lex->unit; |
|
210 |
lex->select_lex.prev= &lex->unit.slave; |
|
211 |
lex->select_lex.link_next= lex->select_lex.slave= lex->select_lex.next= 0; |
|
847
by Brian Aker
More typdef class removal. |
212 |
lex->select_lex.link_prev= (Select_Lex_Node**)&(lex->all_selects_list); |
1
by brian
clean slate |
213 |
lex->select_lex.options= 0; |
214 |
lex->select_lex.init_order(); |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
215 |
lex->select_lex.group_list.clear(); |
1
by brian
clean slate |
216 |
lex->describe= 0; |
217 |
lex->derived_tables= 0; |
|
218 |
lex->lock_option= TL_READ; |
|
219 |
lex->leaf_tables_insert= 0; |
|
2040.6.5
by Monty Taylor
Reset the vector in LEX. Stupid class reuse. |
220 |
lex->var_list.clear(); |
1
by brian
clean slate |
221 |
lex->select_lex.select_number= 1; |
222 |
lex->length=0; |
|
223 |
lex->select_lex.in_sum_expr=0; |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
224 |
lex->select_lex.group_list.clear(); |
225 |
lex->select_lex.order_list.clear(); |
|
1
by brian
clean slate |
226 |
lex->sql_command= SQLCOM_END; |
227 |
lex->duplicates= DUP_ERROR; |
|
228 |
lex->ignore= 0; |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
229 |
lex->escape_used= false; |
1
by brian
clean slate |
230 |
lex->query_tables= 0; |
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
231 |
lex->reset_query_tables_list(false); |
232 |
lex->expr_allows_subselect= true; |
|
233 |
lex->use_only_table_context= false; |
|
1
by brian
clean slate |
234 |
|
235 |
lex->name.str= 0; |
|
236 |
lex->name.length= 0; |
|
237 |
lex->nest_level=0 ; |
|
238 |
lex->allow_sum_func= 0; |
|
239 |
lex->in_sum_func= NULL; |
|
2029.1.28
by Brian Aker
Remove a couple of dead keywords. |
240 |
lex->type= 0; |
1
by brian
clean slate |
241 |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
242 |
lex->is_lex_started= true; |
1100.3.30
by Padraig O'Sullivan
Renamed the Command class to be Statement. Renamed the command directory to |
243 |
lex->statement= NULL; |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
244 |
|
1637.1.3
by Brian Aker
This fixes the parser to no longer do the bad syntax around the cross join |
245 |
lex->is_cross= false; |
1751.3.1
by Brian Aker
This add a couple of utility table functions to be used with testing. |
246 |
lex->reset(); |
1
by brian
clean slate |
247 |
}
|
248 |
||
1897.1.5
by Brian Aker
Move lex_end to be class member. |
249 |
void LEX::end() |
1
by brian
clean slate |
250 |
{
|
1897.1.5
by Brian Aker
Move lex_end to be class member. |
251 |
if (yacc_yyss) |
1
by brian
clean slate |
252 |
{
|
1897.1.5
by Brian Aker
Move lex_end to be class member. |
253 |
free(yacc_yyss); |
254 |
free(yacc_yyvs); |
|
255 |
yacc_yyss= 0; |
|
256 |
yacc_yyvs= 0; |
|
1
by brian
clean slate |
257 |
}
|
258 |
||
2172.3.22
by Brian Aker
This patch adds safe_delete(). All of these locations in the code should be |
259 |
safe_delete(result); |
260 |
safe_delete(_create_table); |
|
2200.2.5
by Stewart Smith
properly reset alter_table in Lex |
261 |
safe_delete(_alter_table); |
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
262 |
_create_table= NULL; |
2200.2.5
by Stewart Smith
properly reset alter_table in Lex |
263 |
_alter_table= NULL; |
2029.1.20
by Brian Aker
Make use of lex for its pointer for field creation. |
264 |
_create_field= NULL; |
1897.1.5
by Brian Aker
Move lex_end to be class member. |
265 |
|
266 |
result= 0; |
|
267 |
setCacheable(true); |
|
268 |
||
2172.3.22
by Brian Aker
This patch adds safe_delete(). All of these locations in the code should be |
269 |
safe_delete(statement); |
1
by brian
clean slate |
270 |
}
|
271 |
||
482
by Brian Aker
Remove uint. |
272 |
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function) |
1
by brian
clean slate |
273 |
{
|
779.4.5
by Monty Taylor
Replaced gen_lex_hash with gperf. Yay for no more building tools to build source!!! |
274 |
/* Plenty of memory for the largest lex symbol we have */
|
275 |
char tok_upper[64]; |
|
1
by brian
clean slate |
276 |
const char *tok= lip->get_tok_start(); |
779.4.5
by Monty Taylor
Replaced gen_lex_hash with gperf. Yay for no more building tools to build source!!! |
277 |
uint32_t tok_pos= 0; |
278 |
for (;tok_pos<len && tok_pos<63;tok_pos++) |
|
279 |
tok_upper[tok_pos]=my_toupper(system_charset_info, tok[tok_pos]); |
|
280 |
tok_upper[tok_pos]=0; |
|
1
by brian
clean slate |
281 |
|
873.2.23
by Monty Taylor
Fixed a failure during gperf failure. |
282 |
const SYMBOL *symbol= lookup_symbol(tok_upper, len, function); |
1
by brian
clean slate |
283 |
if (symbol) |
284 |
{
|
|
285 |
lip->yylval->symbol.symbol=symbol; |
|
286 |
lip->yylval->symbol.str= (char*) tok; |
|
287 |
lip->yylval->symbol.length=len; |
|
288 |
||
289 |
return symbol->tok; |
|
290 |
}
|
|
686
by Brian Aker
Remove vector from lex for plugins. |
291 |
|
1
by brian
clean slate |
292 |
return 0; |
293 |
}
|
|
294 |
||
295 |
/* make a copy of token before ptr and set yytoklen */
|
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
296 |
static lex_string_t get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length) |
1
by brian
clean slate |
297 |
{
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
298 |
lex_string_t tmp; |
1
by brian
clean slate |
299 |
lip->yyUnget(); // ptr points now after last token char |
300 |
tmp.length=lip->yytoklen=length; |
|
2318.9.10
by Olaf van der Spek
Rename strmake to strdup (standard name) |
301 |
tmp.str= lip->m_session->mem.strdup(lip->get_tok_start() + skip, tmp.length); |
1
by brian
clean slate |
302 |
|
303 |
lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip; |
|
304 |
lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.length; |
|
305 |
||
306 |
return tmp; |
|
307 |
}
|
|
308 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
309 |
/*
|
310 |
todo:
|
|
311 |
There are no dangerous charsets in mysql for function
|
|
312 |
get_quoted_token yet. But it should be fixed in the
|
|
1
by brian
clean slate |
313 |
future to operate multichar strings (like ucs2)
|
314 |
*/
|
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
315 |
static lex_string_t get_quoted_token(Lex_input_stream *lip, |
482
by Brian Aker
Remove uint. |
316 |
uint32_t skip, |
317 |
uint32_t length, char quote) |
|
1
by brian
clean slate |
318 |
{
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
319 |
lex_string_t tmp; |
1
by brian
clean slate |
320 |
lip->yyUnget(); // ptr points now after last token char |
321 |
tmp.length= lip->yytoklen=length; |
|
2318.6.30
by Olaf van der Spek
Refactor |
322 |
tmp.str=(char*) lip->m_session->mem.alloc(tmp.length+1); |
2318.8.6
by Olaf van der Spek
Add const |
323 |
const char* from= lip->get_tok_start() + skip; |
324 |
char* to= (char*)tmp.str; |
|
325 |
const char* end= to+length; |
|
1
by brian
clean slate |
326 |
|
327 |
lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip; |
|
328 |
lip->m_cpp_text_end= lip->m_cpp_text_start + length; |
|
329 |
||
330 |
for ( ; to != end; ) |
|
331 |
{
|
|
332 |
if ((*to++= *from++) == quote) |
|
333 |
{
|
|
334 |
from++; // Skip double quotes |
|
335 |
lip->m_cpp_text_start++; |
|
336 |
}
|
|
337 |
}
|
|
338 |
*to= 0; // End null for safety |
|
339 |
return tmp; |
|
340 |
}
|
|
341 |
||
342 |
||
343 |
/*
|
|
344 |
Return an unescaped text literal without quotes
|
|
345 |
Fix sometimes to do only one scan of the string
|
|
346 |
*/
|
|
347 |
static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip) |
|
348 |
{
|
|
2170.5.2
by Olaf van der Spek
more |
349 |
unsigned char c,sep; |
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
350 |
bool found_escape= false; |
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
351 |
const charset_info_st * const cs= lip->m_session->charset(); |
1
by brian
clean slate |
352 |
|
353 |
lip->tok_bitmap= 0; |
|
354 |
sep= lip->yyGetLast(); // String should end with this |
|
355 |
while (! lip->eof()) |
|
356 |
{
|
|
357 |
c= lip->yyGet(); |
|
358 |
lip->tok_bitmap|= c; |
|
359 |
{
|
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
360 |
if (use_mb(cs)) |
361 |
{
|
|
362 |
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query()); |
|
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
363 |
if (l != 0) |
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
364 |
{
|
365 |
lip->skip_binary(l-1); |
|
366 |
continue; |
|
367 |
}
|
|
1
by brian
clean slate |
368 |
}
|
369 |
}
|
|
370 |
if (c == '\\') |
|
371 |
{ // Escaped character |
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
372 |
found_escape= true; |
1
by brian
clean slate |
373 |
if (lip->eof()) |
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
374 |
return 0; |
1
by brian
clean slate |
375 |
lip->yySkip(); |
376 |
}
|
|
377 |
else if (c == sep) |
|
378 |
{
|
|
379 |
if (c == lip->yyGet()) // Check if two separators in a row |
|
380 |
{
|
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
381 |
found_escape= true; // duplicate. Remember for delete |
382 |
continue; |
|
1
by brian
clean slate |
383 |
}
|
384 |
else
|
|
385 |
lip->yyUnget(); |
|
386 |
||
387 |
/* Found end. Unescape and return string */
|
|
2318.6.30
by Olaf van der Spek
Refactor |
388 |
const char* str= lip->get_tok_start(); |
389 |
const char* end= lip->get_ptr(); |
|
1
by brian
clean slate |
390 |
/* Extract the text from the token */
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
391 |
str+= pre_skip; |
392 |
end-= post_skip; |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
393 |
assert(end >= str); |
1
by brian
clean slate |
394 |
|
2318.6.30
by Olaf van der Spek
Refactor |
395 |
char* start= (char*) lip->m_session->mem.alloc((uint32_t) (end-str)+1); |
1
by brian
clean slate |
396 |
|
397 |
lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip; |
|
398 |
lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip; |
|
399 |
||
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
400 |
if (! found_escape) |
1
by brian
clean slate |
401 |
{
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
402 |
lip->yytoklen= (uint32_t) (end-str); |
403 |
memcpy(start, str, lip->yytoklen); |
|
404 |
start[lip->yytoklen]= 0; |
|
1
by brian
clean slate |
405 |
}
|
406 |
else
|
|
407 |
{
|
|
408 |
char *to; |
|
409 |
||
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
410 |
for (to= start; str != end; str++) |
411 |
{
|
|
412 |
if (use_mb(cs)) |
|
413 |
{
|
|
414 |
int l= my_ismbchar(cs, str, end); |
|
415 |
if (l != 0) |
|
416 |
{
|
|
417 |
while (l--) |
|
418 |
*to++= *str++; |
|
419 |
str--; |
|
420 |
continue; |
|
421 |
}
|
|
422 |
}
|
|
423 |
if (*str == '\\' && (str + 1) != end) |
|
424 |
{
|
|
425 |
switch (*++str) { |
|
426 |
case 'n': |
|
427 |
*to++= '\n'; |
|
428 |
break; |
|
429 |
case 't': |
|
430 |
*to++= '\t'; |
|
431 |
break; |
|
432 |
case 'r': |
|
433 |
*to++= '\r'; |
|
434 |
break; |
|
435 |
case 'b': |
|
436 |
*to++= '\b'; |
|
437 |
break; |
|
438 |
case '0': |
|
439 |
*to++= 0; // Ascii null |
|
440 |
break; |
|
441 |
case 'Z': // ^Z must be escaped on Win32 |
|
442 |
*to++= '\032'; |
|
443 |
break; |
|
444 |
case '_': |
|
445 |
case '%': |
|
446 |
*to++= '\\'; // remember prefix for wildcard |
|
447 |
/* Fall through */
|
|
448 |
default: |
|
1
by brian
clean slate |
449 |
*to++= *str; |
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
450 |
break; |
451 |
}
|
|
452 |
}
|
|
453 |
else if (*str == sep) |
|
454 |
*to++= *str++; // Two ' or " |
|
455 |
else
|
|
456 |
*to++ = *str; |
|
457 |
}
|
|
458 |
*to= 0; |
|
459 |
lip->yytoklen= (uint32_t) (to - start); |
|
1
by brian
clean slate |
460 |
}
|
461 |
return start; |
|
462 |
}
|
|
463 |
}
|
|
464 |
return 0; // unexpected end of query |
|
465 |
}
|
|
466 |
||
467 |
||
468 |
/*
|
|
152
by Brian Aker
longlong replacement |
469 |
** Calc type of integer; long integer, int64_t integer or real.
|
1
by brian
clean slate |
470 |
** Returns smallest type that match the string.
|
481.1.2
by Monty Taylor
Replaced all unsigned long long with uint64_t. |
471 |
** When using uint64_t values the result is converted to a real
|
1
by brian
clean slate |
472 |
** because else they will be unexpected sign changes because all calculation
|
152
by Brian Aker
longlong replacement |
473 |
** is done with int64_t or double.
|
1
by brian
clean slate |
474 |
*/
|
475 |
||
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
476 |
static const char *long_str= "2147483647"; |
477 |
static const uint32_t long_len= 10; |
|
478 |
static const char *signed_long_str= "-2147483648"; |
|
479 |
static const char *int64_t_str= "9223372036854775807"; |
|
480 |
static const uint32_t int64_t_len= 19; |
|
481 |
static const char *signed_int64_t_str= "-9223372036854775808"; |
|
482 |
static const uint32_t signed_int64_t_len= 19; |
|
483 |
static const char *unsigned_int64_t_str= "18446744073709551615"; |
|
484 |
static const uint32_t unsigned_int64_t_len= 20; |
|
1
by brian
clean slate |
485 |
|
482
by Brian Aker
Remove uint. |
486 |
static inline uint32_t int_token(const char *str,uint32_t length) |
1
by brian
clean slate |
487 |
{
|
488 |
if (length < long_len) // quick normal case |
|
489 |
return NUM; |
|
490 |
bool neg=0; |
|
491 |
||
492 |
if (*str == '+') // Remove sign and pre-zeros |
|
493 |
{
|
|
494 |
str++; length--; |
|
495 |
}
|
|
496 |
else if (*str == '-') |
|
497 |
{
|
|
498 |
str++; length--; |
|
499 |
neg=1; |
|
500 |
}
|
|
501 |
while (*str == '0' && length) |
|
502 |
{
|
|
503 |
str++; length --; |
|
504 |
}
|
|
505 |
if (length < long_len) |
|
506 |
return NUM; |
|
507 |
||
482
by Brian Aker
Remove uint. |
508 |
uint32_t smaller,bigger; |
1
by brian
clean slate |
509 |
const char *cmp; |
510 |
if (neg) |
|
511 |
{
|
|
512 |
if (length == long_len) |
|
513 |
{
|
|
514 |
cmp= signed_long_str+1; |
|
515 |
smaller=NUM; // If <= signed_long_str |
|
516 |
bigger=LONG_NUM; // If >= signed_long_str |
|
517 |
}
|
|
152
by Brian Aker
longlong replacement |
518 |
else if (length < signed_int64_t_len) |
1
by brian
clean slate |
519 |
return LONG_NUM; |
152
by Brian Aker
longlong replacement |
520 |
else if (length > signed_int64_t_len) |
1
by brian
clean slate |
521 |
return DECIMAL_NUM; |
522 |
else
|
|
523 |
{
|
|
152
by Brian Aker
longlong replacement |
524 |
cmp=signed_int64_t_str+1; |
525 |
smaller=LONG_NUM; // If <= signed_int64_t_str |
|
1
by brian
clean slate |
526 |
bigger=DECIMAL_NUM; |
527 |
}
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
if (length == long_len) |
|
532 |
{
|
|
533 |
cmp= long_str; |
|
534 |
smaller=NUM; |
|
535 |
bigger=LONG_NUM; |
|
536 |
}
|
|
152
by Brian Aker
longlong replacement |
537 |
else if (length < int64_t_len) |
1
by brian
clean slate |
538 |
return LONG_NUM; |
152
by Brian Aker
longlong replacement |
539 |
else if (length > int64_t_len) |
1
by brian
clean slate |
540 |
{
|
152
by Brian Aker
longlong replacement |
541 |
if (length > unsigned_int64_t_len) |
1
by brian
clean slate |
542 |
return DECIMAL_NUM; |
152
by Brian Aker
longlong replacement |
543 |
cmp=unsigned_int64_t_str; |
1
by brian
clean slate |
544 |
smaller=ULONGLONG_NUM; |
545 |
bigger=DECIMAL_NUM; |
|
546 |
}
|
|
547 |
else
|
|
548 |
{
|
|
152
by Brian Aker
longlong replacement |
549 |
cmp=int64_t_str; |
1
by brian
clean slate |
550 |
smaller=LONG_NUM; |
551 |
bigger= ULONGLONG_NUM; |
|
552 |
}
|
|
553 |
}
|
|
554 |
while (*cmp && *cmp++ == *str++) ; |
|
481
by Brian Aker
Remove all of uchar. |
555 |
return ((unsigned char) str[-1] <= (unsigned char) cmp[-1]) ? smaller : bigger; |
1
by brian
clean slate |
556 |
}
|
557 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
558 |
} /* namespace drizzled */ |
1
by brian
clean slate |
559 |
/*
|
2172.3.6
by Brian Aker
Namespace the parser just a bit, and update our call for the type of parser |
560 |
base_sql_lex remember the following states from the following sql_baselex()
|
1
by brian
clean slate |
561 |
|
562 |
- MY_LEX_EOQ Found end of query
|
|
563 |
- MY_LEX_OPERATOR_OR_IDENT Last state was an ident, text or number
|
|
564 |
(which can't be followed by a signed number)
|
|
565 |
*/
|
|
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
566 |
int base_sql_lex(union ParserType *yylval, drizzled::Session *session) |
1
by brian
clean slate |
567 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
568 |
drizzled::Lex_input_stream *lip= session->m_lip; |
1
by brian
clean slate |
569 |
int token; |
570 |
||
571 |
if (lip->lookahead_token != END_OF_INPUT) |
|
572 |
{
|
|
573 |
/*
|
|
574 |
The next token was already parsed in advance,
|
|
575 |
return it.
|
|
576 |
*/
|
|
577 |
token= lip->lookahead_token; |
|
578 |
lip->lookahead_token= END_OF_INPUT; |
|
579 |
*yylval= *(lip->lookahead_yylval); |
|
580 |
lip->lookahead_yylval= NULL; |
|
581 |
return token; |
|
582 |
}
|
|
583 |
||
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
584 |
token= drizzled::lex_one_token(yylval, session); |
1
by brian
clean slate |
585 |
|
586 |
switch(token) { |
|
587 |
case WITH: |
|
588 |
/*
|
|
436
by Brian Aker
Removed non-existent CUBE operator. |
589 |
Parsing 'WITH' 'ROLLUP' requires 2 look ups,
|
1
by brian
clean slate |
590 |
which makes the grammar LALR(2).
|
591 |
Replace by a single 'WITH_ROLLUP' or 'WITH_CUBE' token,
|
|
592 |
to transform the grammar into a LALR(1) grammar,
|
|
593 |
which sql_yacc.yy can process.
|
|
594 |
*/
|
|
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
595 |
token= drizzled::lex_one_token(yylval, session); |
436
by Brian Aker
Removed non-existent CUBE operator. |
596 |
if (token == ROLLUP_SYM) |
597 |
{
|
|
1
by brian
clean slate |
598 |
return WITH_ROLLUP_SYM; |
436
by Brian Aker
Removed non-existent CUBE operator. |
599 |
}
|
600 |
else
|
|
601 |
{
|
|
1
by brian
clean slate |
602 |
/*
|
603 |
Save the token following 'WITH'
|
|
604 |
*/
|
|
605 |
lip->lookahead_yylval= lip->yylval; |
|
606 |
lip->yylval= NULL; |
|
607 |
lip->lookahead_token= token; |
|
608 |
return WITH; |
|
609 |
}
|
|
610 |
default: |
|
611 |
break; |
|
612 |
}
|
|
613 |
||
614 |
return token; |
|
615 |
}
|
|
616 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
617 |
namespace drizzled |
618 |
{
|
|
619 |
||
2172.3.10
by Brian Aker
Fix parser type to not be a void. |
620 |
int lex_one_token(ParserType *yylval, drizzled::Session *session) |
1
by brian
clean slate |
621 |
{
|
2170.5.2
by Olaf van der Spek
more |
622 |
unsigned char c= 0; /* Just set to shutup GCC */ |
1
by brian
clean slate |
623 |
bool comment_closed; |
624 |
int tokval, result_state; |
|
625 |
unsigned int length; |
|
626 |
enum my_lex_states state; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
627 |
Lex_input_stream *lip= session->m_lip; |
2227.4.10
by Olaf van der Spek
Session::lex() |
628 |
LEX *lex= &session->lex(); |
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
629 |
const charset_info_st * const cs= session->charset(); |
481
by Brian Aker
Remove all of uchar. |
630 |
unsigned char *state_map= cs->state_map; |
631 |
unsigned char *ident_map= cs->ident_map; |
|
1
by brian
clean slate |
632 |
|
633 |
lip->yylval=yylval; // The global state |
|
634 |
||
635 |
lip->start_token(); |
|
636 |
state=lip->next_state; |
|
637 |
lip->next_state=MY_LEX_OPERATOR_OR_IDENT; |
|
638 |
for (;;) |
|
639 |
{
|
|
640 |
switch (state) { |
|
641 |
case MY_LEX_OPERATOR_OR_IDENT: // Next is operator or keyword |
|
642 |
case MY_LEX_START: // Start of token |
|
643 |
// Skip starting whitespace
|
|
644 |
while(state_map[c= lip->yyPeek()] == MY_LEX_SKIP) |
|
645 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
646 |
if (c == '\n') |
647 |
lip->yylineno++; |
|
1
by brian
clean slate |
648 |
|
649 |
lip->yySkip(); |
|
650 |
}
|
|
651 |
||
652 |
/* Start of real token */
|
|
653 |
lip->restart_token(); |
|
654 |
c= lip->yyGet(); |
|
655 |
state= (enum my_lex_states) state_map[c]; |
|
656 |
break; |
|
657 |
case MY_LEX_ESCAPE: |
|
658 |
if (lip->yyGet() == 'N') |
|
659 |
{ // Allow \N as shortcut for NULL |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
660 |
yylval->lex_str.str=(char*) "\\N"; |
661 |
yylval->lex_str.length=2; |
|
662 |
return NULL_SYM; |
|
1
by brian
clean slate |
663 |
}
|
664 |
case MY_LEX_CHAR: // Unknown or single char token |
|
665 |
case MY_LEX_SKIP: // This should not happen |
|
666 |
if (c == '-' && lip->yyPeek() == '-' && |
|
667 |
(my_isspace(cs,lip->yyPeekn(1)) || |
|
668 |
my_iscntrl(cs,lip->yyPeekn(1)))) |
|
669 |
{
|
|
670 |
state=MY_LEX_COMMENT; |
|
671 |
break; |
|
672 |
}
|
|
673 |
||
674 |
if (c != ')') |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
675 |
lip->next_state= MY_LEX_START; // Allow signed numbers |
1
by brian
clean slate |
676 |
|
677 |
if (c == ',') |
|
678 |
{
|
|
679 |
/*
|
|
680 |
Warning:
|
|
681 |
This is a work around, to make the "remember_name" rule in
|
|
682 |
sql/sql_yacc.yy work properly.
|
|
683 |
The problem is that, when parsing "select expr1, expr2",
|
|
684 |
the code generated by bison executes the *pre* action
|
|
685 |
remember_name (see select_item) *before* actually parsing the
|
|
686 |
first token of expr2.
|
|
687 |
*/
|
|
688 |
lip->restart_token(); |
|
689 |
}
|
|
690 |
||
691 |
return((int) c); |
|
692 |
||
693 |
case MY_LEX_IDENT_OR_HEX: |
|
694 |
if (lip->yyPeek() == '\'') |
|
695 |
{ // Found x'hex-number' |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
696 |
state= MY_LEX_HEX_NUMBER; |
697 |
break; |
|
1
by brian
clean slate |
698 |
}
|
699 |
case MY_LEX_IDENT_OR_BIN: |
|
700 |
if (lip->yyPeek() == '\'') |
|
701 |
{ // Found b'bin-number' |
|
702 |
state= MY_LEX_BIN_NUMBER; |
|
703 |
break; |
|
704 |
}
|
|
705 |
case MY_LEX_IDENT: |
|
706 |
const char *start; |
|
707 |
if (use_mb(cs)) |
|
708 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
709 |
result_state= IDENT_QUOTED; |
1
by brian
clean slate |
710 |
if (my_mbcharlen(cs, lip->yyGetLast()) > 1) |
711 |
{
|
|
712 |
int l = my_ismbchar(cs, |
|
713 |
lip->get_ptr() -1, |
|
714 |
lip->get_end_of_query()); |
|
715 |
if (l == 0) { |
|
716 |
state = MY_LEX_CHAR; |
|
717 |
continue; |
|
718 |
}
|
|
719 |
lip->skip_binary(l - 1); |
|
720 |
}
|
|
721 |
while (ident_map[c=lip->yyGet()]) |
|
722 |
{
|
|
723 |
if (my_mbcharlen(cs, c) > 1) |
|
724 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
725 |
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query()); |
726 |
if (l == 0) |
|
1
by brian
clean slate |
727 |
break; |
728 |
lip->skip_binary(l-1); |
|
729 |
}
|
|
730 |
}
|
|
731 |
}
|
|
732 |
else
|
|
733 |
{
|
|
734 |
for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c) {}; |
|
735 |
/* If there were non-ASCII characters, mark that we must convert */
|
|
736 |
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; |
|
737 |
}
|
|
738 |
length= lip->yyLength(); |
|
739 |
start= lip->get_ptr(); |
|
740 |
if (lip->ignore_space) |
|
741 |
{
|
|
742 |
/*
|
|
743 |
If we find a space then this can't be an identifier. We notice this
|
|
744 |
below by checking start != lex->ptr.
|
|
745 |
*/
|
|
746 |
for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) {}; |
|
747 |
}
|
|
748 |
if (start == lip->get_ptr() && c == '.' && ident_map[(uint8_t)lip->yyPeek()]) |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
749 |
lip->next_state=MY_LEX_IDENT_SEP; |
1
by brian
clean slate |
750 |
else
|
751 |
{ // '(' must follow directly if function |
|
752 |
lip->yyUnget(); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
753 |
if ((tokval = find_keyword(lip, length, c == '('))) |
754 |
{
|
|
755 |
lip->next_state= MY_LEX_START; // Allow signed numbers |
|
756 |
return(tokval); // Was keyword |
|
757 |
}
|
|
1
by brian
clean slate |
758 |
lip->yySkip(); // next state does a unget |
759 |
}
|
|
760 |
yylval->lex_str=get_token(lip, 0, length); |
|
761 |
||
762 |
lip->body_utf8_append(lip->m_cpp_text_start); |
|
763 |
||
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
764 |
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end); |
1
by brian
clean slate |
765 |
|
766 |
return(result_state); // IDENT or IDENT_QUOTED |
|
767 |
||
768 |
case MY_LEX_IDENT_SEP: // Found ident and now '.' |
|
769 |
yylval->lex_str.str= (char*) lip->get_ptr(); |
|
770 |
yylval->lex_str.length= 1; |
|
771 |
c= lip->yyGet(); // should be '.' |
|
772 |
lip->next_state= MY_LEX_IDENT_START;// Next is an ident (not a keyword) |
|
773 |
if (!ident_map[(uint8_t)lip->yyPeek()]) // Probably ` or " |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
774 |
lip->next_state= MY_LEX_START; |
1
by brian
clean slate |
775 |
return((int) c); |
776 |
||
777 |
case MY_LEX_NUMBER_IDENT: // number or ident which num-start |
|
778 |
if (lip->yyGetLast() == '0') |
|
779 |
{
|
|
780 |
c= lip->yyGet(); |
|
781 |
if (c == 'x') |
|
782 |
{
|
|
783 |
while (my_isxdigit(cs,(c = lip->yyGet()))) ; |
|
784 |
if ((lip->yyLength() >= 3) && !ident_map[c]) |
|
785 |
{
|
|
786 |
/* skip '0x' */
|
|
787 |
yylval->lex_str=get_token(lip, 2, lip->yyLength()-2); |
|
788 |
return (HEX_NUM); |
|
789 |
}
|
|
790 |
lip->yyUnget(); |
|
791 |
state= MY_LEX_IDENT_START; |
|
792 |
break; |
|
793 |
}
|
|
794 |
else if (c == 'b') |
|
795 |
{
|
|
796 |
while ((c= lip->yyGet()) == '0' || c == '1') {}; |
|
797 |
if ((lip->yyLength() >= 3) && !ident_map[c]) |
|
798 |
{
|
|
799 |
/* Skip '0b' */
|
|
800 |
yylval->lex_str= get_token(lip, 2, lip->yyLength()-2); |
|
801 |
return (BIN_NUM); |
|
802 |
}
|
|
803 |
lip->yyUnget(); |
|
804 |
state= MY_LEX_IDENT_START; |
|
805 |
break; |
|
806 |
}
|
|
807 |
lip->yyUnget(); |
|
808 |
}
|
|
809 |
||
810 |
while (my_isdigit(cs, (c = lip->yyGet()))) ; |
|
811 |
if (!ident_map[c]) |
|
812 |
{ // Can't be identifier |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
813 |
state=MY_LEX_INT_OR_REAL; |
814 |
break; |
|
1
by brian
clean slate |
815 |
}
|
816 |
if (c == 'e' || c == 'E') |
|
817 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
818 |
// The following test is written this way to allow numbers of type 1e1
|
1
by brian
clean slate |
819 |
if (my_isdigit(cs,lip->yyPeek()) || |
820 |
(c=(lip->yyGet())) == '+' || c == '-') |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
821 |
{ // Allow 1E+10 |
1
by brian
clean slate |
822 |
if (my_isdigit(cs,lip->yyPeek())) // Number must have digit after sign |
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
823 |
{
|
1
by brian
clean slate |
824 |
lip->yySkip(); |
825 |
while (my_isdigit(cs,lip->yyGet())) ; |
|
826 |
yylval->lex_str=get_token(lip, 0, lip->yyLength()); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
827 |
return(FLOAT_NUM); |
828 |
}
|
|
829 |
}
|
|
1
by brian
clean slate |
830 |
lip->yyUnget(); |
831 |
}
|
|
832 |
// fall through
|
|
833 |
case MY_LEX_IDENT_START: // We come here after '.' |
|
834 |
result_state= IDENT; |
|
835 |
if (use_mb(cs)) |
|
836 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
837 |
result_state= IDENT_QUOTED; |
1
by brian
clean slate |
838 |
while (ident_map[c=lip->yyGet()]) |
839 |
{
|
|
840 |
if (my_mbcharlen(cs, c) > 1) |
|
841 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
842 |
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query()); |
843 |
if (l == 0) |
|
1
by brian
clean slate |
844 |
break; |
845 |
lip->skip_binary(l-1); |
|
846 |
}
|
|
847 |
}
|
|
848 |
}
|
|
849 |
else
|
|
850 |
{
|
|
851 |
for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) {}; |
|
852 |
/* If there were non-ASCII characters, mark that we must convert */
|
|
853 |
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; |
|
854 |
}
|
|
855 |
if (c == '.' && ident_map[(uint8_t)lip->yyPeek()]) |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
856 |
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.' |
1
by brian
clean slate |
857 |
|
858 |
yylval->lex_str= get_token(lip, 0, lip->yyLength()); |
|
859 |
||
860 |
lip->body_utf8_append(lip->m_cpp_text_start); |
|
861 |
||
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
862 |
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end); |
1
by brian
clean slate |
863 |
|
864 |
return(result_state); |
|
865 |
||
866 |
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char |
|
867 |
{
|
|
482
by Brian Aker
Remove uint. |
868 |
uint32_t double_quotes= 0; |
1
by brian
clean slate |
869 |
char quote_char= c; // Used char |
870 |
while ((c=lip->yyGet())) |
|
871 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
872 |
int var_length; |
873 |
if ((var_length= my_mbcharlen(cs, c)) == 1) |
|
874 |
{
|
|
875 |
if (c == quote_char) |
|
876 |
{
|
|
877 |
if (lip->yyPeek() != quote_char) |
|
878 |
break; |
|
879 |
c=lip->yyGet(); |
|
880 |
double_quotes++; |
|
881 |
continue; |
|
882 |
}
|
|
883 |
}
|
|
884 |
else if (var_length < 1) |
|
885 |
break; // Error |
|
1
by brian
clean slate |
886 |
lip->skip_binary(var_length-1); |
887 |
}
|
|
888 |
if (double_quotes) |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
889 |
yylval->lex_str=get_quoted_token(lip, 1, lip->yyLength() - double_quotes -1, quote_char); |
1
by brian
clean slate |
890 |
else
|
891 |
yylval->lex_str=get_token(lip, 1, lip->yyLength() -1); |
|
892 |
if (c == quote_char) |
|
893 |
lip->yySkip(); // Skip end ` |
|
894 |
lip->next_state= MY_LEX_START; |
|
895 |
lip->body_utf8_append(lip->m_cpp_text_start); |
|
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
896 |
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end); |
1
by brian
clean slate |
897 |
return(IDENT_QUOTED); |
898 |
}
|
|
899 |
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real |
|
900 |
if (c != '.') |
|
901 |
{ // Found complete integer number. |
|
902 |
yylval->lex_str=get_token(lip, 0, lip->yyLength()); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
903 |
return int_token(yylval->lex_str.str,yylval->lex_str.length); |
1
by brian
clean slate |
904 |
}
|
905 |
// fall through
|
|
906 |
case MY_LEX_REAL: // Incomplete real number |
|
907 |
while (my_isdigit(cs,c = lip->yyGet())) ; |
|
908 |
||
909 |
if (c == 'e' || c == 'E') |
|
910 |
{
|
|
911 |
c = lip->yyGet(); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
912 |
if (c == '-' || c == '+') |
913 |
c = lip->yyGet(); // Skip sign |
|
914 |
if (!my_isdigit(cs,c)) |
|
915 |
{ // No digit after sign |
|
916 |
state= MY_LEX_CHAR; |
|
917 |
break; |
|
918 |
}
|
|
1
by brian
clean slate |
919 |
while (my_isdigit(cs,lip->yyGet())) ; |
920 |
yylval->lex_str=get_token(lip, 0, lip->yyLength()); |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
921 |
return(FLOAT_NUM); |
1
by brian
clean slate |
922 |
}
|
923 |
yylval->lex_str=get_token(lip, 0, lip->yyLength()); |
|
924 |
return(DECIMAL_NUM); |
|
925 |
||
926 |
case MY_LEX_HEX_NUMBER: // Found x'hexstring' |
|
927 |
lip->yySkip(); // Accept opening ' |
|
928 |
while (my_isxdigit(cs, (c= lip->yyGet()))) ; |
|
929 |
if (c != '\'') |
|
930 |
return(ABORT_SYM); // Illegal hex constant |
|
931 |
lip->yySkip(); // Accept closing ' |
|
932 |
length= lip->yyLength(); // Length of hexnum+3 |
|
933 |
if ((length % 2) == 0) |
|
934 |
return(ABORT_SYM); // odd number of hex digits |
|
935 |
yylval->lex_str=get_token(lip, |
|
936 |
2, // skip x' |
|
937 |
length-3); // don't count x' and last ' |
|
938 |
return (HEX_NUM); |
|
939 |
||
940 |
case MY_LEX_BIN_NUMBER: // Found b'bin-string' |
|
941 |
lip->yySkip(); // Accept opening ' |
|
942 |
while ((c= lip->yyGet()) == '0' || c == '1') {}; |
|
943 |
if (c != '\'') |
|
944 |
return(ABORT_SYM); // Illegal hex constant |
|
945 |
lip->yySkip(); // Accept closing ' |
|
946 |
length= lip->yyLength(); // Length of bin-num + 3 |
|
947 |
yylval->lex_str= get_token(lip, |
|
948 |
2, // skip b' |
|
949 |
length-3); // don't count b' and last ' |
|
950 |
return (BIN_NUM); |
|
951 |
||
952 |
case MY_LEX_CMP_OP: // Incomplete comparison operator |
|
953 |
if (state_map[(uint8_t)lip->yyPeek()] == MY_LEX_CMP_OP || |
|
954 |
state_map[(uint8_t)lip->yyPeek()] == MY_LEX_LONG_CMP_OP) |
|
955 |
lip->yySkip(); |
|
956 |
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0))) |
|
957 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
958 |
lip->next_state= MY_LEX_START; // Allow signed numbers |
959 |
return(tokval); |
|
1
by brian
clean slate |
960 |
}
|
961 |
state = MY_LEX_CHAR; // Something fishy found |
|
962 |
break; |
|
963 |
||
964 |
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator |
|
965 |
if (state_map[(uint8_t)lip->yyPeek()] == MY_LEX_CMP_OP || |
|
966 |
state_map[(uint8_t)lip->yyPeek()] == MY_LEX_LONG_CMP_OP) |
|
967 |
{
|
|
968 |
lip->yySkip(); |
|
969 |
if (state_map[(uint8_t)lip->yyPeek()] == MY_LEX_CMP_OP) |
|
970 |
lip->yySkip(); |
|
971 |
}
|
|
972 |
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0))) |
|
973 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
974 |
lip->next_state= MY_LEX_START; // Found long op |
975 |
return(tokval); |
|
1
by brian
clean slate |
976 |
}
|
977 |
state = MY_LEX_CHAR; // Something fishy found |
|
978 |
break; |
|
979 |
||
980 |
case MY_LEX_BOOL: |
|
981 |
if (c != lip->yyPeek()) |
|
982 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
983 |
state=MY_LEX_CHAR; |
984 |
break; |
|
1
by brian
clean slate |
985 |
}
|
986 |
lip->yySkip(); |
|
987 |
tokval = find_keyword(lip,2,0); // Is a bool operator |
|
988 |
lip->next_state= MY_LEX_START; // Allow signed numbers |
|
989 |
return(tokval); |
|
990 |
||
991 |
case MY_LEX_STRING_OR_DELIMITER: |
|
992 |
if (0) |
|
993 |
{
|
|
994 |
state= MY_LEX_USER_VARIABLE_DELIMITER; |
|
995 |
break; |
|
996 |
}
|
|
997 |
/* " used for strings */
|
|
2318.8.15
by Olaf van der Spek
Fix MY_LEX_STRING |
998 |
case MY_LEX_STRING: // Incomplete text string |
1
by brian
clean slate |
999 |
if (!(yylval->lex_str.str = get_text(lip, 1, 1))) |
1000 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1001 |
state= MY_LEX_CHAR; // Read char by char |
1002 |
break; |
|
1
by brian
clean slate |
1003 |
}
|
1004 |
yylval->lex_str.length=lip->yytoklen; |
|
1005 |
||
1006 |
lip->body_utf8_append(lip->m_cpp_text_start); |
|
1007 |
||
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
1008 |
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end); |
1
by brian
clean slate |
1009 |
|
1010 |
lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1; |
|
1011 |
return(TEXT_STRING); |
|
1012 |
||
1013 |
case MY_LEX_COMMENT: // Comment |
|
1014 |
lex->select_lex.options|= OPTION_FOUND_COMMENT; |
|
1015 |
while ((c = lip->yyGet()) != '\n' && c) ; |
|
1016 |
lip->yyUnget(); // Safety against eof |
|
1017 |
state = MY_LEX_START; // Try again |
|
1018 |
break; |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1019 |
|
1
by brian
clean slate |
1020 |
case MY_LEX_LONG_COMMENT: /* Long C comment? */ |
1021 |
if (lip->yyPeek() != '*') |
|
1022 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1023 |
state=MY_LEX_CHAR; // Probable division |
1024 |
break; |
|
1
by brian
clean slate |
1025 |
}
|
1026 |
lex->select_lex.options|= OPTION_FOUND_COMMENT; |
|
1027 |
/* Reject '/' '*', since we might need to turn off the echo */
|
|
1028 |
lip->yyUnget(); |
|
1029 |
||
1030 |
if (lip->yyPeekn(2) == '!') |
|
1031 |
{
|
|
1032 |
lip->in_comment= DISCARD_COMMENT; |
|
1033 |
/* Accept '/' '*' '!', but do not keep this marker. */
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1034 |
lip->set_echo(false); |
1
by brian
clean slate |
1035 |
lip->yySkip(); |
1036 |
lip->yySkip(); |
|
1037 |
lip->yySkip(); |
|
1038 |
||
1039 |
/*
|
|
1040 |
The special comment format is very strict:
|
|
908.1.15
by Monty Taylor
Updated comment version indicators to handle drizzle versions. |
1041 |
'/' '*' '!', followed by digits ended by a non-digit.
|
1042 |
There must be at least 5 digits for it to count
|
|
1
by brian
clean slate |
1043 |
*/
|
908.1.15
by Monty Taylor
Updated comment version indicators to handle drizzle versions. |
1044 |
const int MAX_VERSION_SIZE= 16; |
1045 |
char version_str[MAX_VERSION_SIZE]; |
|
1046 |
||
1047 |
int pos= 0; |
|
1048 |
do
|
|
1049 |
{
|
|
1050 |
version_str[pos]= lip->yyPeekn(pos); |
|
1051 |
pos++; |
|
1052 |
} while ((pos < MAX_VERSION_SIZE-1) && isdigit(version_str[pos-1])); |
|
1053 |
version_str[pos]= 0; |
|
1054 |
||
1055 |
/* To keep some semblance of compatibility, we impose a 5 digit floor */
|
|
1056 |
if (pos > 4) |
|
1057 |
{
|
|
1058 |
uint64_t version; |
|
1059 |
version=strtoll(version_str, NULL, 10); |
|
1
by brian
clean slate |
1060 |
|
1061 |
/* Accept 'M' 'm' 'm' 'd' 'd' */
|
|
908.1.15
by Monty Taylor
Updated comment version indicators to handle drizzle versions. |
1062 |
lip->yySkipn(pos-1); |
1
by brian
clean slate |
1063 |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1064 |
if (version <= DRIZZLE_VERSION_ID) |
1
by brian
clean slate |
1065 |
{
|
1066 |
/* Expand the content of the special comment as real code */
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1067 |
lip->set_echo(true); |
1
by brian
clean slate |
1068 |
state=MY_LEX_START; |
1069 |
break; |
|
1070 |
}
|
|
1071 |
}
|
|
1072 |
else
|
|
1073 |
{
|
|
1074 |
state=MY_LEX_START; |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1075 |
lip->set_echo(true); |
1
by brian
clean slate |
1076 |
break; |
1077 |
}
|
|
1078 |
}
|
|
1079 |
else
|
|
1080 |
{
|
|
1081 |
lip->in_comment= PRESERVE_COMMENT; |
|
1082 |
lip->yySkip(); // Accept / |
|
1083 |
lip->yySkip(); // Accept * |
|
1084 |
}
|
|
1085 |
/*
|
|
1086 |
Discard:
|
|
1087 |
- regular '/' '*' comments,
|
|
1088 |
- special comments '/' '*' '!' for a future version,
|
|
1089 |
by scanning until we find a closing '*' '/' marker.
|
|
1090 |
Note: There is no such thing as nesting comments,
|
|
1091 |
the first '*' '/' sequence seen will mark the end.
|
|
1092 |
*/
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1093 |
comment_closed= false; |
1
by brian
clean slate |
1094 |
while (! lip->eof()) |
1095 |
{
|
|
1096 |
c= lip->yyGet(); |
|
1097 |
if (c == '*') |
|
1098 |
{
|
|
1099 |
if (lip->yyPeek() == '/') |
|
1100 |
{
|
|
1101 |
lip->yySkip(); |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1102 |
comment_closed= true; |
1
by brian
clean slate |
1103 |
state = MY_LEX_START; |
1104 |
break; |
|
1105 |
}
|
|
1106 |
}
|
|
1107 |
else if (c == '\n') |
|
1108 |
lip->yylineno++; |
|
1109 |
}
|
|
1110 |
/* Unbalanced comments with a missing '*' '/' are a syntax error */
|
|
1111 |
if (! comment_closed) |
|
1112 |
return (ABORT_SYM); |
|
1113 |
state = MY_LEX_START; // Try again |
|
1114 |
lip->in_comment= NO_COMMENT; |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1115 |
lip->set_echo(true); |
1
by brian
clean slate |
1116 |
break; |
2198.6.14
by Brian Aker
Fix white space in lexer. |
1117 |
|
1
by brian
clean slate |
1118 |
case MY_LEX_END_LONG_COMMENT: |
1119 |
if ((lip->in_comment != NO_COMMENT) && lip->yyPeek() == '/') |
|
1120 |
{
|
|
1121 |
/* Reject '*' '/' */
|
|
1122 |
lip->yyUnget(); |
|
1123 |
/* Accept '*' '/', with the proper echo */
|
|
1124 |
lip->set_echo(lip->in_comment == PRESERVE_COMMENT); |
|
1125 |
lip->yySkipn(2); |
|
1126 |
/* And start recording the tokens again */
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1127 |
lip->set_echo(true); |
1
by brian
clean slate |
1128 |
lip->in_comment=NO_COMMENT; |
1129 |
state=MY_LEX_START; |
|
1130 |
}
|
|
1131 |
else
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1132 |
state=MY_LEX_CHAR; // Return '*' |
1
by brian
clean slate |
1133 |
break; |
2198.6.14
by Brian Aker
Fix white space in lexer. |
1134 |
|
1
by brian
clean slate |
1135 |
case MY_LEX_SET_VAR: // Check if ':=' |
1136 |
if (lip->yyPeek() != '=') |
|
1137 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1138 |
state=MY_LEX_CHAR; // Return ':' |
1139 |
break; |
|
1
by brian
clean slate |
1140 |
}
|
1141 |
lip->yySkip(); |
|
1142 |
return (SET_VAR); |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1143 |
|
1
by brian
clean slate |
1144 |
case MY_LEX_SEMICOLON: // optional line terminator |
1145 |
if (lip->yyPeek()) |
|
1146 |
{
|
|
1147 |
state= MY_LEX_CHAR; // Return ';' |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1148 |
break; |
1
by brian
clean slate |
1149 |
}
|
1150 |
lip->next_state=MY_LEX_END; // Mark for next loop |
|
1151 |
return(END_OF_INPUT); |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1152 |
|
1
by brian
clean slate |
1153 |
case MY_LEX_EOL: |
1154 |
if (lip->eof()) |
|
1155 |
{
|
|
1156 |
lip->yyUnget(); // Reject the last '\0' |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1157 |
lip->set_echo(false); |
1
by brian
clean slate |
1158 |
lip->yySkip(); |
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1159 |
lip->set_echo(true); |
1
by brian
clean slate |
1160 |
/* Unbalanced comments with a missing '*' '/' are a syntax error */
|
1161 |
if (lip->in_comment != NO_COMMENT) |
|
1162 |
return (ABORT_SYM); |
|
1163 |
lip->next_state=MY_LEX_END; // Mark for next loop |
|
1164 |
return(END_OF_INPUT); |
|
1165 |
}
|
|
1166 |
state=MY_LEX_CHAR; |
|
1167 |
break; |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1168 |
|
1
by brian
clean slate |
1169 |
case MY_LEX_END: |
1170 |
lip->next_state=MY_LEX_END; |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1171 |
return false; // We found end of input last time |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1172 |
|
1
by brian
clean slate |
1173 |
/* Actually real shouldn't start with . but allow them anyhow */
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1174 |
|
1
by brian
clean slate |
1175 |
case MY_LEX_REAL_OR_POINT: |
1176 |
if (my_isdigit(cs,lip->yyPeek())) |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1177 |
state= MY_LEX_REAL; // Real |
1
by brian
clean slate |
1178 |
else
|
1179 |
{
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1180 |
state= MY_LEX_IDENT_SEP; // return '.' |
1
by brian
clean slate |
1181 |
lip->yyUnget(); // Put back '.' |
1182 |
}
|
|
1183 |
break; |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1184 |
|
1
by brian
clean slate |
1185 |
case MY_LEX_USER_END: // end '@' of user@hostname |
1186 |
switch (state_map[(uint8_t)lip->yyPeek()]) { |
|
2318.8.15
by Olaf van der Spek
Fix MY_LEX_STRING |
1187 |
case MY_LEX_STRING: |
1
by brian
clean slate |
1188 |
case MY_LEX_USER_VARIABLE_DELIMITER: |
1189 |
case MY_LEX_STRING_OR_DELIMITER: |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1190 |
break; |
1
by brian
clean slate |
1191 |
case MY_LEX_USER_END: |
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1192 |
lip->next_state=MY_LEX_SYSTEM_VAR; |
1193 |
break; |
|
1
by brian
clean slate |
1194 |
default: |
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1195 |
lip->next_state=MY_LEX_HOSTNAME; |
1196 |
break; |
|
1
by brian
clean slate |
1197 |
}
|
1198 |
yylval->lex_str.str=(char*) lip->get_ptr(); |
|
1199 |
yylval->lex_str.length=1; |
|
1200 |
return((int) '@'); |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1201 |
|
1
by brian
clean slate |
1202 |
case MY_LEX_HOSTNAME: // end '@' of user@hostname |
1203 |
for (c=lip->yyGet() ; |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1204 |
my_isalnum(cs,c) || c == '.' || c == '_' || c == '$'; |
1
by brian
clean slate |
1205 |
c= lip->yyGet()) ; |
1206 |
yylval->lex_str=get_token(lip, 0, lip->yyLength()); |
|
1207 |
return(LEX_HOSTNAME); |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1208 |
|
1
by brian
clean slate |
1209 |
case MY_LEX_SYSTEM_VAR: |
1210 |
yylval->lex_str.str=(char*) lip->get_ptr(); |
|
1211 |
yylval->lex_str.length=1; |
|
1212 |
lip->yySkip(); // Skip '@' |
|
1213 |
lip->next_state= (state_map[(uint8_t)lip->yyPeek()] == |
|
1214 |
MY_LEX_USER_VARIABLE_DELIMITER ? |
|
1215 |
MY_LEX_OPERATOR_OR_IDENT : |
|
1216 |
MY_LEX_IDENT_OR_KEYWORD); |
|
1217 |
return((int) '@'); |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1218 |
|
1
by brian
clean slate |
1219 |
case MY_LEX_IDENT_OR_KEYWORD: |
1220 |
/*
|
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1221 |
We come here when we have found two '@' in a row.
|
1222 |
We should now be able to handle:
|
|
1223 |
[(global | local | session) .]variable_name
|
|
1
by brian
clean slate |
1224 |
*/
|
1225 |
||
1226 |
for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) {}; |
|
1227 |
/* If there were non-ASCII characters, mark that we must convert */
|
|
1228 |
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; |
|
1229 |
||
1230 |
if (c == '.') |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1231 |
lip->next_state=MY_LEX_IDENT_SEP; |
2198.6.14
by Brian Aker
Fix white space in lexer. |
1232 |
|
1
by brian
clean slate |
1233 |
length= lip->yyLength(); |
1234 |
if (length == 0) |
|
1235 |
return(ABORT_SYM); // Names must be nonempty. |
|
2198.6.14
by Brian Aker
Fix white space in lexer. |
1236 |
|
1
by brian
clean slate |
1237 |
if ((tokval= find_keyword(lip, length,0))) |
1238 |
{
|
|
1239 |
lip->yyUnget(); // Put back 'c' |
|
1014.4.9
by Jay Pipes
Code style cleanup and removal of dead LEX_SERVER_OPTIONS struct |
1240 |
return(tokval); // Was keyword |
1
by brian
clean slate |
1241 |
}
|
1242 |
yylval->lex_str=get_token(lip, 0, length); |
|
1243 |
||
1244 |
lip->body_utf8_append(lip->m_cpp_text_start); |
|
1245 |
||
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
1246 |
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end); |
1
by brian
clean slate |
1247 |
|
1248 |
return(result_state); |
|
1249 |
}
|
|
1250 |
}
|
|
1251 |
}
|
|
1252 |
||
1253 |
/*
|
|
846
by Brian Aker
Removing on typedeffed class. |
1254 |
Select_Lex structures initialisations
|
1
by brian
clean slate |
1255 |
*/
|
847
by Brian Aker
More typdef class removal. |
1256 |
void Select_Lex_Node::init_query() |
1
by brian
clean slate |
1257 |
{
|
1258 |
options= 0; |
|
1259 |
linkage= UNSPECIFIED_TYPE; |
|
1260 |
no_error= no_table_names_allowed= 0; |
|
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
1261 |
uncacheable.reset(); |
1
by brian
clean slate |
1262 |
}
|
1263 |
||
847
by Brian Aker
More typdef class removal. |
1264 |
void Select_Lex_Node::init_select() |
1
by brian
clean slate |
1265 |
{
|
1266 |
}
|
|
1267 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1268 |
void Select_Lex_Unit::init_query() |
1
by brian
clean slate |
1269 |
{
|
847
by Brian Aker
More typdef class removal. |
1270 |
Select_Lex_Node::init_query(); |
1
by brian
clean slate |
1271 |
linkage= GLOBAL_OPTIONS_TYPE; |
1272 |
global_parameters= first_select(); |
|
1273 |
select_limit_cnt= HA_POS_ERROR; |
|
1274 |
offset_limit_cnt= 0; |
|
1275 |
union_distinct= 0; |
|
1276 |
prepared= optimized= executed= 0; |
|
1277 |
item= 0; |
|
1278 |
union_result= 0; |
|
1279 |
table= 0; |
|
1280 |
fake_select_lex= 0; |
|
1281 |
cleaned= 0; |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1282 |
item_list.clear(); |
1
by brian
clean slate |
1283 |
describe= 0; |
1284 |
found_rows_for_union= 0; |
|
1285 |
}
|
|
1286 |
||
846
by Brian Aker
Removing on typedeffed class. |
1287 |
void Select_Lex::init_query() |
1
by brian
clean slate |
1288 |
{
|
847
by Brian Aker
More typdef class removal. |
1289 |
Select_Lex_Node::init_query(); |
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1290 |
table_list.clear(); |
1291 |
top_join_list.clear(); |
|
1
by brian
clean slate |
1292 |
join_list= &top_join_list; |
1293 |
embedding= leaf_tables= 0; |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1294 |
item_list.clear(); |
1
by brian
clean slate |
1295 |
join= 0; |
177.1.1
by brian
Removed dead code around prep. |
1296 |
having= where= 0; |
1
by brian
clean slate |
1297 |
olap= UNSPECIFIED_OLAP_TYPE; |
1298 |
having_fix_field= 0; |
|
1299 |
context.select_lex= this; |
|
1300 |
context.init(); |
|
1301 |
/*
|
|
1302 |
Add the name resolution context of the current (sub)query to the
|
|
1303 |
stack of contexts for the whole query.
|
|
1304 |
TODO:
|
|
1305 |
push_context may return an error if there is no memory for a new
|
|
1306 |
element in the stack, however this method has no return value,
|
|
1307 |
thus push_context should be moved to a place where query
|
|
1308 |
initialization is checked for failure.
|
|
1309 |
*/
|
|
1310 |
parent_lex->push_context(&context); |
|
1311 |
cond_count= between_count= with_wild= 0; |
|
1312 |
max_equal_elems= 0; |
|
1313 |
ref_pointer_array= 0; |
|
1314 |
select_n_where_fields= 0; |
|
1315 |
select_n_having_items= 0; |
|
1316 |
subquery_in_having= explicit_limit= 0; |
|
1317 |
is_item_list_lookup= 0; |
|
1318 |
parsing_place= NO_MATTER; |
|
177.1.2
by brian
Removed dead variable, sorted authors file. |
1319 |
exclude_from_table_unique_test= false; |
1
by brian
clean slate |
1320 |
nest_level= 0; |
1321 |
link_next= 0; |
|
1322 |
}
|
|
1323 |
||
846
by Brian Aker
Removing on typedeffed class. |
1324 |
void Select_Lex::init_select() |
1
by brian
clean slate |
1325 |
{
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1326 |
sj_nests.clear(); |
1327 |
group_list.clear(); |
|
1240.7.3
by Padraig O'Sullivan
Used std::string for the type in Select_Lex instead of char *. |
1328 |
db= 0; |
1
by brian
clean slate |
1329 |
having= 0; |
1330 |
in_sum_expr= with_wild= 0; |
|
1331 |
options= 0; |
|
1332 |
braces= 0; |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1333 |
interval_list.clear(); |
1
by brian
clean slate |
1334 |
inner_sum_func_list= 0; |
1335 |
linkage= UNSPECIFIED_TYPE; |
|
1336 |
order_list.elements= 0; |
|
1337 |
order_list.first= 0; |
|
481
by Brian Aker
Remove all of uchar. |
1338 |
order_list.next= (unsigned char**) &order_list.first; |
1
by brian
clean slate |
1339 |
/* Set limit and offset to default values */
|
1340 |
select_limit= 0; /* denotes the default limit = HA_POS_ERROR */ |
|
1341 |
offset_limit= 0; /* denotes the default offset = 0 */ |
|
1342 |
with_sum_func= 0; |
|
2141.4.2
by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error. |
1343 |
is_cross= false; |
1
by brian
clean slate |
1344 |
is_correlated= 0; |
1345 |
cur_pos_in_select_list= UNDEF_POS; |
|
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1346 |
non_agg_fields.clear(); |
1
by brian
clean slate |
1347 |
cond_value= having_value= Item::COND_UNDEF; |
2179.2.1
by Olaf van der Spek
Rename List::empty to clear (std::list uses clear) |
1348 |
inner_refs_list.clear(); |
1089.6.3
by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a |
1349 |
full_group_by_flag.reset(); |
1
by brian
clean slate |
1350 |
}
|
1351 |
||
1352 |
/*
|
|
846
by Brian Aker
Removing on typedeffed class. |
1353 |
Select_Lex structures linking
|
1
by brian
clean slate |
1354 |
*/
|
1355 |
||
1356 |
/* include on level down */
|
|
847
by Brian Aker
More typdef class removal. |
1357 |
void Select_Lex_Node::include_down(Select_Lex_Node *upper) |
1
by brian
clean slate |
1358 |
{
|
1359 |
if ((next= upper->slave)) |
|
1360 |
next->prev= &next; |
|
1361 |
prev= &upper->slave; |
|
1362 |
upper->slave= this; |
|
1363 |
master= upper; |
|
1364 |
slave= 0; |
|
1365 |
}
|
|
1366 |
||
1367 |
/*
|
|
1368 |
include on level down (but do not link)
|
|
1369 |
||
1370 |
SYNOPSYS
|
|
847
by Brian Aker
More typdef class removal. |
1371 |
Select_Lex_Node::include_standalone()
|
1
by brian
clean slate |
1372 |
upper - reference on node underr which this node should be included
|
1373 |
ref - references on reference on this node
|
|
1374 |
*/
|
|
847
by Brian Aker
More typdef class removal. |
1375 |
void Select_Lex_Node::include_standalone(Select_Lex_Node *upper, |
1376 |
Select_Lex_Node **ref) |
|
1
by brian
clean slate |
1377 |
{
|
1378 |
next= 0; |
|
1379 |
prev= ref; |
|
1380 |
master= upper; |
|
1381 |
slave= 0; |
|
1382 |
}
|
|
1383 |
||
1384 |
/* include neighbour (on same level) */
|
|
847
by Brian Aker
More typdef class removal. |
1385 |
void Select_Lex_Node::include_neighbour(Select_Lex_Node *before) |
1
by brian
clean slate |
1386 |
{
|
1387 |
if ((next= before->next)) |
|
1388 |
next->prev= &next; |
|
1389 |
prev= &before->next; |
|
1390 |
before->next= this; |
|
1391 |
master= before->master; |
|
1392 |
slave= 0; |
|
1393 |
}
|
|
1394 |
||
846
by Brian Aker
Removing on typedeffed class. |
1395 |
/* including in global Select_Lex list */
|
847
by Brian Aker
More typdef class removal. |
1396 |
void Select_Lex_Node::include_global(Select_Lex_Node **plink) |
1
by brian
clean slate |
1397 |
{
|
1398 |
if ((link_next= *plink)) |
|
1399 |
link_next->link_prev= &link_next; |
|
1400 |
link_prev= plink; |
|
1401 |
*plink= this; |
|
1402 |
}
|
|
1403 |
||
1404 |
//excluding from global list (internal function)
|
|
847
by Brian Aker
More typdef class removal. |
1405 |
void Select_Lex_Node::fast_exclude() |
1
by brian
clean slate |
1406 |
{
|
1407 |
if (link_prev) |
|
1408 |
{
|
|
1409 |
if ((*link_prev= link_next)) |
|
1410 |
link_next->link_prev= link_prev; |
|
1411 |
}
|
|
1412 |
// Remove slave structure
|
|
1413 |
for (; slave; slave= slave->next) |
|
1414 |
slave->fast_exclude(); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1415 |
|
1
by brian
clean slate |
1416 |
}
|
1417 |
||
1418 |
/*
|
|
1419 |
excluding select_lex structure (except first (first select can't be
|
|
1420 |
deleted, because it is most upper select))
|
|
1421 |
*/
|
|
847
by Brian Aker
More typdef class removal. |
1422 |
void Select_Lex_Node::exclude() |
1
by brian
clean slate |
1423 |
{
|
1424 |
//exclude from global list
|
|
1425 |
fast_exclude(); |
|
1426 |
//exclude from other structures
|
|
1427 |
if ((*prev= next)) |
|
1428 |
next->prev= prev; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1429 |
/*
|
1430 |
We do not need following statements, because prev pointer of first
|
|
1
by brian
clean slate |
1431 |
list element point to master->slave
|
1432 |
if (master->slave == this)
|
|
1433 |
master->slave= next;
|
|
1434 |
*/
|
|
1435 |
}
|
|
1436 |
||
1437 |
||
1438 |
/*
|
|
1439 |
Exclude level of current unit from tree of SELECTs
|
|
1440 |
||
1441 |
SYNOPSYS
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1442 |
Select_Lex_Unit::exclude_level()
|
1
by brian
clean slate |
1443 |
|
1444 |
NOTE: units which belong to current will be brought up on level of
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1445 |
currernt unit
|
1
by brian
clean slate |
1446 |
*/
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1447 |
void Select_Lex_Unit::exclude_level() |
1
by brian
clean slate |
1448 |
{
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1449 |
Select_Lex_Unit *units= 0, **units_last= &units; |
846
by Brian Aker
Removing on typedeffed class. |
1450 |
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select()) |
1
by brian
clean slate |
1451 |
{
|
1452 |
// unlink current level from global SELECTs list
|
|
1453 |
if (sl->link_prev && (*sl->link_prev= sl->link_next)) |
|
1454 |
sl->link_next->link_prev= sl->link_prev; |
|
1455 |
||
1456 |
// bring up underlay levels
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1457 |
Select_Lex_Unit **last= 0; |
1458 |
for (Select_Lex_Unit *u= sl->first_inner_unit(); u; u= u->next_unit()) |
|
1
by brian
clean slate |
1459 |
{
|
1460 |
u->master= master; |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1461 |
last= (Select_Lex_Unit**)&(u->next); |
1
by brian
clean slate |
1462 |
}
|
1463 |
if (last) |
|
1464 |
{
|
|
1465 |
(*units_last)= sl->first_inner_unit(); |
|
1466 |
units_last= last; |
|
1467 |
}
|
|
1468 |
}
|
|
1469 |
if (units) |
|
1470 |
{
|
|
1471 |
// include brought up levels in place of current
|
|
1472 |
(*prev)= units; |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1473 |
(*units_last)= (Select_Lex_Unit*)next; |
1
by brian
clean slate |
1474 |
if (next) |
847
by Brian Aker
More typdef class removal. |
1475 |
next->prev= (Select_Lex_Node**)units_last; |
1
by brian
clean slate |
1476 |
units->prev= prev; |
1477 |
}
|
|
1478 |
else
|
|
1479 |
{
|
|
1480 |
// exclude currect unit from list of nodes
|
|
1481 |
(*prev)= next; |
|
1482 |
if (next) |
|
1483 |
next->prev= prev; |
|
1484 |
}
|
|
1485 |
}
|
|
1486 |
||
1487 |
/*
|
|
1488 |
Exclude subtree of current unit from tree of SELECTs
|
|
1489 |
*/
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1490 |
void Select_Lex_Unit::exclude_tree() |
1
by brian
clean slate |
1491 |
{
|
846
by Brian Aker
Removing on typedeffed class. |
1492 |
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select()) |
1
by brian
clean slate |
1493 |
{
|
1494 |
// unlink current level from global SELECTs list
|
|
1495 |
if (sl->link_prev && (*sl->link_prev= sl->link_next)) |
|
1496 |
sl->link_next->link_prev= sl->link_prev; |
|
1497 |
||
1498 |
// unlink underlay levels
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1499 |
for (Select_Lex_Unit *u= sl->first_inner_unit(); u; u= u->next_unit()) |
1
by brian
clean slate |
1500 |
{
|
1501 |
u->exclude_level(); |
|
1502 |
}
|
|
1503 |
}
|
|
1504 |
// exclude currect unit from list of nodes
|
|
1505 |
(*prev)= next; |
|
1506 |
if (next) |
|
1507 |
next->prev= prev; |
|
1508 |
}
|
|
1509 |
||
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
1510 |
/**
|
1511 |
* Mark all Select_Lex struct from this to 'last' as dependent
|
|
1512 |
*
|
|
1513 |
* @param Pointer to last Select_Lex struct, before wich all
|
|
1514 |
* Select_Lex have to be marked as dependent
|
|
1515 |
* @note 'last' should be reachable from this Select_Lex_Node
|
|
1516 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
1517 |
void Select_Lex::mark_as_dependent(Select_Lex *last) |
1
by brian
clean slate |
1518 |
{
|
1519 |
/*
|
|
1520 |
Mark all selects from resolved to 1 before select where was
|
|
1521 |
found table as depended (of select where was found table)
|
|
1522 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
1523 |
for (Select_Lex *s= this; |
1
by brian
clean slate |
1524 |
s && s != last; |
1525 |
s= s->outer_select()) |
|
1526 |
{
|
|
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
1527 |
if (! (s->uncacheable.test(UNCACHEABLE_DEPENDENT))) |
1
by brian
clean slate |
1528 |
{
|
1529 |
// Select is dependent of outer select
|
|
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
1530 |
s->uncacheable.set(UNCACHEABLE_DEPENDENT); |
1531 |
s->uncacheable.set(UNCACHEABLE_UNITED); |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1532 |
Select_Lex_Unit *munit= s->master_unit(); |
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
1533 |
munit->uncacheable.set(UNCACHEABLE_UNITED); |
1534 |
munit->uncacheable.set(UNCACHEABLE_DEPENDENT); |
|
846
by Brian Aker
Removing on typedeffed class. |
1535 |
for (Select_Lex *sl= munit->first_select(); sl ; sl= sl->next_select()) |
1
by brian
clean slate |
1536 |
{
|
1537 |
if (sl != s && |
|
1858.1.1
by Padraig O'Sullivan
Replaced a uint8_t member with a standard bitset since it was being used as a bitset.... |
1538 |
! (sl->uncacheable.test(UNCACHEABLE_DEPENDENT) && sl->uncacheable.test(UNCACHEABLE_UNITED))) |
1539 |
sl->uncacheable.set(UNCACHEABLE_UNITED); |
|
1
by brian
clean slate |
1540 |
}
|
1541 |
}
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1542 |
s->is_correlated= true; |
1
by brian
clean slate |
1543 |
Item_subselect *subquery_predicate= s->master_unit()->item; |
1544 |
if (subquery_predicate) |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1545 |
subquery_predicate->is_correlated= true; |
1
by brian
clean slate |
1546 |
}
|
1547 |
}
|
|
1548 |
||
847
by Brian Aker
More typdef class removal. |
1549 |
bool Select_Lex_Node::set_braces(bool) |
1019.1.6
by Brian Aker
A number of random cleanups. |
1550 |
{ return true; } |
1551 |
||
1552 |
bool Select_Lex_Node::inc_in_sum_expr() |
|
1553 |
{ return true; } |
|
1554 |
||
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1555 |
uint32_t Select_Lex_Node::get_in_sum_expr() |
1019.1.6
by Brian Aker
A number of random cleanups. |
1556 |
{ return 0; } |
1557 |
||
1558 |
TableList* Select_Lex_Node::get_table_list() |
|
1559 |
{ return NULL; } |
|
1560 |
||
1561 |
List<Item>* Select_Lex_Node::get_item_list() |
|
1562 |
{ return NULL; } |
|
1563 |
||
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1564 |
TableList *Select_Lex_Node::add_table_to_list(Session *, |
1565 |
Table_ident *, |
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
1566 |
lex_string_t *, |
1858.1.2
by Padraig O'Sullivan
Converted another uint8_t type to be a bitset. |
1567 |
const bitset<NUM_OF_TABLE_OPTIONS>&, |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1568 |
thr_lock_type, |
1569 |
List<Index_hint> *, |
|
2371.1.2
by Brian Aker
Remove the typedef on lexkey |
1570 |
lex_string_t *) |
1
by brian
clean slate |
1571 |
{
|
1572 |
return 0; |
|
1573 |
}
|
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1574 |
|
1
by brian
clean slate |
1575 |
|
1576 |
/*
|
|
1577 |
prohibit using LIMIT clause
|
|
1578 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
1579 |
bool Select_Lex::test_limit() |
1
by brian
clean slate |
1580 |
{
|
1581 |
if (select_limit != 0) |
|
1582 |
{
|
|
1583 |
my_error(ER_NOT_SUPPORTED_YET, MYF(0), |
|
1584 |
"LIMIT & IN/ALL/ANY/SOME subquery"); |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1585 |
return true; |
1
by brian
clean slate |
1586 |
}
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1587 |
return false; |
1
by brian
clean slate |
1588 |
}
|
1589 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1590 |
Select_Lex_Unit* Select_Lex_Unit::master_unit() |
1
by brian
clean slate |
1591 |
{
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
1592 |
return this; |
1
by brian
clean slate |
1593 |
}
|
1594 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1595 |
Select_Lex* Select_Lex_Unit::outer_select() |
1
by brian
clean slate |
1596 |
{
|
846
by Brian Aker
Removing on typedeffed class. |
1597 |
return (Select_Lex*) master; |
1
by brian
clean slate |
1598 |
}
|
1599 |
||
2318.6.30
by Olaf van der Spek
Refactor |
1600 |
void Select_Lex::add_order_to_list(Session *session, Item *item, bool asc) |
1
by brian
clean slate |
1601 |
{
|
2318.6.30
by Olaf van der Spek
Refactor |
1602 |
add_to_list(session, order_list, item, asc); |
1
by brian
clean slate |
1603 |
}
|
1604 |
||
2318.6.31
by Olaf van der Spek
Refactor |
1605 |
void Select_Lex::add_item_to_list(Session *, Item *item) |
1
by brian
clean slate |
1606 |
{
|
2241.2.11
by Olaf van der Spek
Refactor |
1607 |
item_list.push_back(item); |
1
by brian
clean slate |
1608 |
}
|
1609 |
||
2318.6.31
by Olaf van der Spek
Refactor |
1610 |
void Select_Lex::add_group_to_list(Session *session, Item *item, bool asc) |
1
by brian
clean slate |
1611 |
{
|
2318.6.30
by Olaf van der Spek
Refactor |
1612 |
add_to_list(session, group_list, item, asc); |
1
by brian
clean slate |
1613 |
}
|
1614 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1615 |
Select_Lex_Unit* Select_Lex::master_unit() |
846
by Brian Aker
Removing on typedeffed class. |
1616 |
{
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1617 |
return (Select_Lex_Unit*) master; |
846
by Brian Aker
Removing on typedeffed class. |
1618 |
}
|
1619 |
||
1620 |
Select_Lex* Select_Lex::outer_select() |
|
1621 |
{
|
|
1622 |
return (Select_Lex*) master->get_master(); |
|
1623 |
}
|
|
1624 |
||
1625 |
bool Select_Lex::set_braces(bool value) |
|
1
by brian
clean slate |
1626 |
{
|
1627 |
braces= value; |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1628 |
return false; |
1
by brian
clean slate |
1629 |
}
|
1630 |
||
846
by Brian Aker
Removing on typedeffed class. |
1631 |
bool Select_Lex::inc_in_sum_expr() |
1
by brian
clean slate |
1632 |
{
|
1633 |
in_sum_expr++; |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
1634 |
return false; |
1
by brian
clean slate |
1635 |
}
|
1636 |
||
846
by Brian Aker
Removing on typedeffed class. |
1637 |
uint32_t Select_Lex::get_in_sum_expr() |
1
by brian
clean slate |
1638 |
{
|
1639 |
return in_sum_expr; |
|
1640 |
}
|
|
1641 |
||
846
by Brian Aker
Removing on typedeffed class. |
1642 |
TableList* Select_Lex::get_table_list() |
1
by brian
clean slate |
1643 |
{
|
327.2.4
by Brian Aker
Refactoring table.h |
1644 |
return (TableList*) table_list.first; |
1
by brian
clean slate |
1645 |
}
|
1646 |
||
846
by Brian Aker
Removing on typedeffed class. |
1647 |
List<Item>* Select_Lex::get_item_list() |
1
by brian
clean slate |
1648 |
{
|
1649 |
return &item_list; |
|
1650 |
}
|
|
1651 |
||
2318.6.31
by Olaf van der Spek
Refactor |
1652 |
void Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num) |
1
by brian
clean slate |
1653 |
{
|
2318.6.31
by Olaf van der Spek
Refactor |
1654 |
if (not ref_pointer_array) |
2318.6.67
by Olaf van der Spek
Refactor |
1655 |
ref_pointer_array= new (session->mem) Item*[5 * (n_child_sum_items + item_list.size() + select_n_having_items + select_n_where_fields + order_group_num)]; |
1
by brian
clean slate |
1656 |
}
|
1657 |
||
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1658 |
void Select_Lex_Unit::print(String *str) |
1
by brian
clean slate |
1659 |
{
|
1660 |
bool union_all= !union_distinct; |
|
846
by Brian Aker
Removing on typedeffed class. |
1661 |
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select()) |
1
by brian
clean slate |
1662 |
{
|
1663 |
if (sl != first_select()) |
|
1664 |
{
|
|
1665 |
str->append(STRING_WITH_LEN(" union ")); |
|
1666 |
if (union_all) |
|
1667 |
str->append(STRING_WITH_LEN("all ")); |
|
1668 |
else if (union_distinct == sl) |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1669 |
union_all= true; |
1
by brian
clean slate |
1670 |
}
|
1671 |
if (sl->braces) |
|
1672 |
str->append('('); |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1673 |
sl->print(session, str); |
1
by brian
clean slate |
1674 |
if (sl->braces) |
1675 |
str->append(')'); |
|
1676 |
}
|
|
1677 |
if (fake_select_lex == global_parameters) |
|
1678 |
{
|
|
1679 |
if (fake_select_lex->order_list.elements) |
|
1680 |
{
|
|
1681 |
str->append(STRING_WITH_LEN(" order by ")); |
|
1682 |
fake_select_lex->print_order( |
|
1683 |
str, |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1684 |
(Order *) fake_select_lex->order_list.first); |
1
by brian
clean slate |
1685 |
}
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1686 |
fake_select_lex->print_limit(session, str); |
1
by brian
clean slate |
1687 |
}
|
1688 |
}
|
|
1689 |
||
846
by Brian Aker
Removing on typedeffed class. |
1690 |
void Select_Lex::print_order(String *str, |
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1691 |
Order *order) |
1
by brian
clean slate |
1692 |
{
|
1693 |
for (; order; order= order->next) |
|
1694 |
{
|
|
1695 |
if (order->counter_used) |
|
1696 |
{
|
|
1697 |
char buffer[20]; |
|
482
by Brian Aker
Remove uint. |
1698 |
uint32_t length= snprintf(buffer, 20, "%d", order->counter); |
1
by brian
clean slate |
1699 |
str->append(buffer, length); |
1700 |
}
|
|
1701 |
else
|
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1702 |
(*order->item)->print(str); |
1
by brian
clean slate |
1703 |
if (!order->asc) |
1704 |
str->append(STRING_WITH_LEN(" desc")); |
|
1705 |
if (order->next) |
|
1706 |
str->append(','); |
|
1707 |
}
|
|
1708 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1709 |
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1710 |
void Select_Lex::print_limit(Session *, String *str) |
1
by brian
clean slate |
1711 |
{
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1712 |
Select_Lex_Unit *unit= master_unit(); |
1
by brian
clean slate |
1713 |
Item_subselect *item= unit->item; |
1714 |
||
1715 |
if (item && unit->global_parameters == this) |
|
1716 |
{
|
|
1717 |
Item_subselect::subs_type subs_type= item->substype(); |
|
1718 |
if (subs_type == Item_subselect::EXISTS_SUBS || |
|
1719 |
subs_type == Item_subselect::IN_SUBS || |
|
1720 |
subs_type == Item_subselect::ALL_SUBS) |
|
1721 |
{
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1722 |
assert(!item->fixed || |
1
by brian
clean slate |
1723 |
/*
|
1724 |
If not using materialization both:
|
|
1725 |
select_limit == 1, and there should be no offset_limit.
|
|
1726 |
*/
|
|
1727 |
(((subs_type == Item_subselect::IN_SUBS) && |
|
1728 |
((Item_in_subselect*)item)->exec_method == |
|
1729 |
Item_in_subselect::MATERIALIZATION) ? |
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1730 |
true : |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1731 |
(select_limit->val_int() == 1L) && |
1
by brian
clean slate |
1732 |
offset_limit == 0)); |
1733 |
return; |
|
1734 |
}
|
|
1735 |
}
|
|
1736 |
if (explicit_limit) |
|
1737 |
{
|
|
1738 |
str->append(STRING_WITH_LEN(" limit ")); |
|
1739 |
if (offset_limit) |
|
1740 |
{
|
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1741 |
offset_limit->print(str); |
1
by brian
clean slate |
1742 |
str->append(','); |
1743 |
}
|
|
2215.2.1
by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing. |
1744 |
select_limit->print(str); |
1
by brian
clean slate |
1745 |
}
|
1746 |
}
|
|
1747 |
||
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
1748 |
LEX::~LEX() |
1749 |
{
|
|
1750 |
delete _create_table; |
|
2200.2.5
by Stewart Smith
properly reset alter_table in Lex |
1751 |
delete _alter_table; |
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
1752 |
}
|
1753 |
||
1
by brian
clean slate |
1754 |
/*
|
1755 |
Initialize (or reset) Query_tables_list object.
|
|
1756 |
||
1757 |
SYNOPSIS
|
|
1758 |
reset_query_tables_list()
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1759 |
init true - we should perform full initialization of object with
|
1
by brian
clean slate |
1760 |
allocating needed memory
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1761 |
false - object is already initialized so we should only reset
|
1
by brian
clean slate |
1762 |
its state so it can be used for parsing/processing
|
1763 |
of new statement
|
|
1764 |
||
1765 |
DESCRIPTION
|
|
1766 |
This method initializes Query_tables_list so it can be used as part
|
|
1767 |
of LEX object for parsing/processing of statement. One can also use
|
|
1768 |
this method to reset state of already initialized Query_tables_list
|
|
1769 |
so it can be used for processing of new statement.
|
|
1770 |
*/
|
|
1771 |
void Query_tables_list::reset_query_tables_list(bool init) |
|
1772 |
{
|
|
1773 |
if (!init && query_tables) |
|
1774 |
{
|
|
327.2.4
by Brian Aker
Refactoring table.h |
1775 |
TableList *table= query_tables; |
1
by brian
clean slate |
1776 |
for (;;) |
1777 |
{
|
|
1778 |
if (query_tables_last == &table->next_global || |
|
1779 |
!(table= table->next_global)) |
|
1780 |
break; |
|
1781 |
}
|
|
1782 |
}
|
|
1783 |
query_tables= 0; |
|
1784 |
query_tables_last= &query_tables; |
|
1785 |
query_tables_own_last= 0; |
|
1786 |
}
|
|
1787 |
||
1788 |
/*
|
|
1789 |
Initialize LEX object.
|
|
1790 |
||
1791 |
SYNOPSIS
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1792 |
LEX::LEX()
|
1
by brian
clean slate |
1793 |
|
1794 |
NOTE
|
|
1795 |
LEX object initialized with this constructor can be used as part of
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1796 |
Session object for which one can safely call open_tables(), lock_tables()
|
1
by brian
clean slate |
1797 |
and close_thread_tables() functions. But it is not yet ready for
|
1798 |
statement parsing. On should use lex_start() function to prepare LEX
|
|
1799 |
for this.
|
|
1800 |
*/
|
|
2029.1.5
by Brian Aker
Move exists into LEX. |
1801 |
LEX::LEX() : |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1802 |
result(0), |
1803 |
yacc_yyss(0), |
|
1668.1.1
by Padraig O'Sullivan
Initialize charset member of the LEX class correctly in the constructor. |
1804 |
yacc_yyvs(0), |
2029.1.5
by Brian Aker
Move exists into LEX. |
1805 |
session(NULL), |
1668.1.1
by Padraig O'Sullivan
Initialize charset member of the LEX class correctly in the constructor. |
1806 |
charset(NULL), |
2040.6.5
by Monty Taylor
Reset the vector in LEX. Stupid class reuse. |
1807 |
var_list(), |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1808 |
sql_command(SQLCOM_END), |
2029.1.5
by Brian Aker
Move exists into LEX. |
1809 |
statement(NULL), |
2227.4.3
by Olaf van der Spek
Remove unnecessary statement.h include |
1810 |
option_type(OPT_DEFAULT), |
1643.6.13
by Djellel E. Difallah
adding tests |
1811 |
is_lex_started(0), |
1751.3.1
by Brian Aker
This add a couple of utility table functions to be used with testing. |
1812 |
cacheable(true), |
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
1813 |
sum_expr_used(false), |
2029.1.5
by Brian Aker
Move exists into LEX. |
1814 |
_create_table(NULL), |
2200.2.5
by Stewart Smith
properly reset alter_table in Lex |
1815 |
_alter_table(NULL), |
2029.1.20
by Brian Aker
Make use of lex for its pointer for field creation. |
1816 |
_create_field(NULL), |
2029.1.5
by Brian Aker
Move exists into LEX. |
1817 |
_exists(false) |
1
by brian
clean slate |
1818 |
{
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1819 |
reset_query_tables_list(true); |
1
by brian
clean slate |
1820 |
}
|
1821 |
||
1822 |
/*
|
|
1823 |
initialize limit counters
|
|
1824 |
||
1825 |
SYNOPSIS
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1826 |
Select_Lex_Unit::set_limit()
|
846
by Brian Aker
Removing on typedeffed class. |
1827 |
values - Select_Lex with initial values for counters
|
1
by brian
clean slate |
1828 |
*/
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1829 |
void Select_Lex_Unit::set_limit(Select_Lex *sl) |
1
by brian
clean slate |
1830 |
{
|
1831 |
ha_rows select_limit_val; |
|
151
by Brian Aker
Ulonglong to uint64_t |
1832 |
uint64_t val; |
1
by brian
clean slate |
1833 |
|
1834 |
val= sl->select_limit ? sl->select_limit->val_uint() : HA_POS_ERROR; |
|
1835 |
select_limit_val= (ha_rows)val; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1836 |
/*
|
151
by Brian Aker
Ulonglong to uint64_t |
1837 |
Check for overflow : ha_rows can be smaller then uint64_t if
|
1
by brian
clean slate |
1838 |
BIG_TABLES is off.
|
1839 |
*/
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1840 |
if (val != (uint64_t)select_limit_val) |
1
by brian
clean slate |
1841 |
select_limit_val= HA_POS_ERROR; |
1842 |
offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() : |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1843 |
0UL); |
1
by brian
clean slate |
1844 |
select_limit_cnt= select_limit_val + offset_limit_cnt; |
1845 |
if (select_limit_cnt < select_limit_val) |
|
1846 |
select_limit_cnt= HA_POS_ERROR; // no limit |
|
1847 |
}
|
|
1848 |
||
1849 |
/*
|
|
1850 |
Unlink the first table from the global table list and the first table from
|
|
1851 |
outer select (lex->select_lex) local list
|
|
1852 |
||
1853 |
SYNOPSIS
|
|
1854 |
unlink_first_table()
|
|
1855 |
link_to_local Set to 1 if caller should link this table to local list
|
|
1856 |
||
1857 |
NOTES
|
|
1858 |
We assume that first tables in both lists is the same table or the local
|
|
1859 |
list is empty.
|
|
1860 |
||
1861 |
RETURN
|
|
1862 |
0 If 'query_tables' == 0
|
|
1863 |
unlinked table
|
|
1864 |
In this case link_to_local is set.
|
|
1865 |
||
1866 |
*/
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1867 |
TableList *LEX::unlink_first_table(bool *link_to_local) |
1
by brian
clean slate |
1868 |
{
|
327.2.4
by Brian Aker
Refactoring table.h |
1869 |
TableList *first; |
1
by brian
clean slate |
1870 |
if ((first= query_tables)) |
1871 |
{
|
|
1872 |
/*
|
|
1873 |
Exclude from global table list
|
|
1874 |
*/
|
|
1875 |
if ((query_tables= query_tables->next_global)) |
|
1876 |
query_tables->prev_global= &query_tables; |
|
1877 |
else
|
|
1878 |
query_tables_last= &query_tables; |
|
1879 |
first->next_global= 0; |
|
1880 |
||
1881 |
/*
|
|
1882 |
and from local list if it is not empty
|
|
1883 |
*/
|
|
1884 |
if ((*link_to_local= test(select_lex.table_list.first))) |
|
1885 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1886 |
select_lex.context.table_list= |
1
by brian
clean slate |
1887 |
select_lex.context.first_name_resolution_table= first->next_local; |
481
by Brian Aker
Remove all of uchar. |
1888 |
select_lex.table_list.first= (unsigned char*) (first->next_local); |
1
by brian
clean slate |
1889 |
select_lex.table_list.elements--; //safety |
1890 |
first->next_local= 0; |
|
1891 |
/*
|
|
1892 |
Ensure that the global list has the same first table as the local
|
|
1893 |
list.
|
|
1894 |
*/
|
|
1895 |
first_lists_tables_same(); |
|
1896 |
}
|
|
1897 |
}
|
|
1898 |
return first; |
|
1899 |
}
|
|
1900 |
||
1901 |
/*
|
|
1902 |
Bring first local table of first most outer select to first place in global
|
|
1903 |
table list
|
|
1904 |
||
1905 |
SYNOPSYS
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1906 |
LEX::first_lists_tables_same()
|
1
by brian
clean slate |
1907 |
|
1908 |
NOTES
|
|
1909 |
In many cases (for example, usual INSERT/DELETE/...) the first table of
|
|
846
by Brian Aker
Removing on typedeffed class. |
1910 |
main Select_Lex have special meaning => check that it is the first table
|
1
by brian
clean slate |
1911 |
in global list and re-link to be first in the global list if it is
|
1912 |
necessary. We need such re-linking only for queries with sub-queries in
|
|
1913 |
the select list, as only in this case tables of sub-queries will go to
|
|
1914 |
the global list first.
|
|
1915 |
*/
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1916 |
void LEX::first_lists_tables_same() |
1
by brian
clean slate |
1917 |
{
|
327.2.4
by Brian Aker
Refactoring table.h |
1918 |
TableList *first_table= (TableList*) select_lex.table_list.first; |
1
by brian
clean slate |
1919 |
if (query_tables != first_table && first_table != 0) |
1920 |
{
|
|
327.2.4
by Brian Aker
Refactoring table.h |
1921 |
TableList *next; |
1
by brian
clean slate |
1922 |
if (query_tables_last == &first_table->next_global) |
1923 |
query_tables_last= first_table->prev_global; |
|
1924 |
||
1925 |
if ((next= *first_table->prev_global= first_table->next_global)) |
|
1926 |
next->prev_global= first_table->prev_global; |
|
1927 |
/* include in new place */
|
|
1928 |
first_table->next_global= query_tables; |
|
1929 |
/*
|
|
1930 |
We are sure that query_tables is not 0, because first_table was not
|
|
1931 |
first table in the global list => we can use
|
|
1932 |
query_tables->prev_global without check of query_tables
|
|
1933 |
*/
|
|
1934 |
query_tables->prev_global= &first_table->next_global; |
|
1935 |
first_table->prev_global= &query_tables; |
|
1936 |
query_tables= first_table; |
|
1937 |
}
|
|
1938 |
}
|
|
1939 |
||
1940 |
/*
|
|
1941 |
Link table back that was unlinked with unlink_first_table()
|
|
1942 |
||
1943 |
SYNOPSIS
|
|
1944 |
link_first_table_back()
|
|
1945 |
link_to_local do we need link this table to local
|
|
1946 |
||
1947 |
RETURN
|
|
1948 |
global list
|
|
1949 |
*/
|
|
1014.4.10
by Jay Pipes
Code style cleanups and removal of st_parsing_options. |
1950 |
void LEX::link_first_table_back(TableList *first, bool link_to_local) |
1
by brian
clean slate |
1951 |
{
|
1952 |
if (first) |
|
1953 |
{
|
|
1954 |
if ((first->next_global= query_tables)) |
|
1955 |
query_tables->prev_global= &first->next_global; |
|
1956 |
else
|
|
1957 |
query_tables_last= &first->next_global; |
|
1958 |
query_tables= first; |
|
1959 |
||
1960 |
if (link_to_local) |
|
1961 |
{
|
|
327.2.4
by Brian Aker
Refactoring table.h |
1962 |
first->next_local= (TableList*) select_lex.table_list.first; |
1
by brian
clean slate |
1963 |
select_lex.context.table_list= first; |
481
by Brian Aker
Remove all of uchar. |
1964 |
select_lex.table_list.first= (unsigned char*) first; |
1
by brian
clean slate |
1965 |
select_lex.table_list.elements++; //safety |
1966 |
}
|
|
1967 |
}
|
|
1968 |
}
|
|
1969 |
||
1970 |
/*
|
|
1971 |
cleanup lex for case when we open table by table for processing
|
|
1972 |
||
1973 |
SYNOPSIS
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1974 |
LEX::cleanup_after_one_table_open()
|
1
by brian
clean slate |
1975 |
|
1976 |
NOTE
|
|
1977 |
This method is mostly responsible for cleaning up of selects lists and
|
|
1978 |
derived tables state. To rollback changes in Query_tables_list one has
|
|
51.1.52
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1979 |
to call Query_tables_list::reset_query_tables_list(false).
|
1
by brian
clean slate |
1980 |
*/
|
575.4.7
by Monty Taylor
More header cleanup. |
1981 |
void LEX::cleanup_after_one_table_open() |
1
by brian
clean slate |
1982 |
{
|
1983 |
/*
|
|
2227.4.8
by Olaf van der Spek
Session::lex() |
1984 |
session->lex().derived_tables & additional units may be set if we open
|
1985 |
a view. It is necessary to clear session->lex().derived_tables flag
|
|
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
1986 |
to prevent processing of derived tables during next openTablesLock
|
1
by brian
clean slate |
1987 |
if next table is a real table and cleanup & remove underlying units
|
2227.4.8
by Olaf van der Spek
Session::lex() |
1988 |
NOTE: all units will be connected to session->lex().select_lex, because we
|
1
by brian
clean slate |
1989 |
have not UNION on most upper level.
|
1990 |
*/
|
|
1991 |
if (all_selects_list != &select_lex) |
|
1992 |
{
|
|
1993 |
derived_tables= 0; |
|
1994 |
/* cleunup underlying units (units of VIEW) */
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1995 |
for (Select_Lex_Unit *un= select_lex.first_inner_unit(); |
1
by brian
clean slate |
1996 |
un; |
1997 |
un= un->next_unit()) |
|
1998 |
un->cleanup(); |
|
1999 |
/* reduce all selects list to default state */
|
|
2000 |
all_selects_list= &select_lex; |
|
2001 |
/* remove underlying units (units of VIEW) subtree */
|
|
2002 |
select_lex.cut_subtree(); |
|
2003 |
}
|
|
2004 |
}
|
|
2005 |
||
2006 |
/*
|
|
846
by Brian Aker
Removing on typedeffed class. |
2007 |
There are Select_Lex::add_table_to_list &
|
2008 |
Select_Lex::set_lock_for_tables are in sql_parse.cc
|
|
2009 |
||
2010 |
Select_Lex::print is in sql_select.cc
|
|
2011 |
||
848
by Brian Aker
typdef class removal (just... use the name of the class). |
2012 |
Select_Lex_Unit::prepare, Select_Lex_Unit::exec,
|
2013 |
Select_Lex_Unit::cleanup, Select_Lex_Unit::reinit_exec_mechanism,
|
|
2014 |
Select_Lex_Unit::change_result
|
|
1
by brian
clean slate |
2015 |
are in sql_union.cc
|
2016 |
*/
|
|
2017 |
||
2018 |
/*
|
|
2019 |
Sets the kind of hints to be added by the calls to add_index_hint().
|
|
2020 |
||
2021 |
SYNOPSIS
|
|
2022 |
set_index_hint_type()
|
|
2023 |
type_arg The kind of hints to be added from now on.
|
|
2024 |
clause The clause to use for hints to be added from now on.
|
|
2025 |
||
2026 |
DESCRIPTION
|
|
2027 |
Used in filling up the tagged hints list.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2028 |
This list is filled by first setting the kind of the hint as a
|
1
by brian
clean slate |
2029 |
context variable and then adding hints of the current kind.
|
2030 |
Then the context variable index_hint_type can be reset to the
|
|
2031 |
next hint type.
|
|
2032 |
*/
|
|
2385.3.20
by Olaf van der Spek
Refactor |
2033 |
void Select_Lex::set_index_hint_type(index_hint_type type_arg, index_clause_map clause) |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2034 |
{
|
1
by brian
clean slate |
2035 |
current_index_hint_type= type_arg; |
2036 |
current_index_hint_clause= clause; |
|
2037 |
}
|
|
2038 |
||
2039 |
/*
|
|
2040 |
Makes an array to store index usage hints (ADD/FORCE/IGNORE INDEX).
|
|
2041 |
||
2042 |
SYNOPSIS
|
|
2043 |
alloc_index_hints()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2044 |
session current thread.
|
1
by brian
clean slate |
2045 |
*/
|
846
by Brian Aker
Removing on typedeffed class. |
2046 |
void Select_Lex::alloc_index_hints (Session *session) |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2047 |
{
|
2048 |
index_hints= new (session->mem_root) List<Index_hint>(); |
|
1
by brian
clean slate |
2049 |
}
|
2050 |
||
2051 |
/*
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2052 |
adds an element to the array storing index usage hints
|
1
by brian
clean slate |
2053 |
(ADD/FORCE/IGNORE INDEX).
|
2054 |
||
2055 |
SYNOPSIS
|
|
2056 |
add_index_hint()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2057 |
session current thread.
|
1
by brian
clean slate |
2058 |
str name of the index.
|
2059 |
length number of characters in str.
|
|
2060 |
||
2061 |
RETURN VALUE
|
|
2062 |
0 on success, non-zero otherwise
|
|
2063 |
*/
|
|
2385.3.21
by Olaf van der Spek
Refactor |
2064 |
void Select_Lex::add_index_hint(Session *session, const char *str) |
1
by brian
clean slate |
2065 |
{
|
2385.3.21
by Olaf van der Spek
Refactor |
2066 |
index_hints->push_front(new (session->mem_root) Index_hint(current_index_hint_type, current_index_hint_clause, str)); |
1
by brian
clean slate |
2067 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2068 |
|
2200.2.11
by Stewart Smith
move the message::AlterTable header include into sql_lex.cc so we can just have a forward declaration in sql_lex.h - greatly speeding compile time |
2069 |
message::AlterTable *LEX::alter_table() |
2070 |
{
|
|
2071 |
if (not _alter_table) |
|
2072 |
_alter_table= new message::AlterTable; |
|
2073 |
||
2074 |
return _alter_table; |
|
2075 |
}
|
|
2029.1.26
by Brian Aker
Merge in work for reserved words in SQL standard. |
2076 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2077 |
} /* namespace drizzled */ |