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