813
@brief This class represents the character input stream consumed during
816
In addition to consuming the input stream, this class performs some
817
comment pre processing, by filtering out out of bound special text
818
from the query input stream.
819
Two buffers, with pointers inside each buffers, are maintained in
820
parallel. The 'raw' buffer is the original query text, which may
821
contain out-of-bound comments. The 'cpp' (for comments pre processor)
822
is the pre-processed buffer that contains only the query text that
823
should be seen once out-of-bound data is removed.
826
class Lex_input_stream
829
Lex_input_stream(Session *session, const char* buff, unsigned int length);
835
When echo is true, characters parsed from the raw input stream are
836
preserved. When false, characters parsed are silently ignored.
837
@param echo the echo mode.
839
void set_echo(bool echo)
845
Skip binary from the input stream.
846
@param n number of bytes to accept.
848
void skip_binary(int n)
852
memcpy(m_cpp_ptr, m_ptr, n);
859
Get a character, and advance in the stream.
860
@return the next character to parse.
871
Get the last character accepted.
872
@return the last character accepted.
880
Look at the next character to parse, but do not accept it.
888
Look ahead at some character to parse.
889
@param n offset of the character to look up
897
Cancel the effect of the last yyGet() or yySkip().
898
Note that the echo mode should not change between calls to yyGet / yySkip
899
and yyUnget. The caller is responsible for ensuring that.
909
Accept a character, by advancing the input stream.
914
*m_cpp_ptr++ = *m_ptr++;
920
Accept multiple characters at once.
921
@param n the number of characters to accept.
927
memcpy(m_cpp_ptr, m_ptr, n);
934
End of file indicator for the query text to parse.
935
@return true if there are no more characters to parse
939
return (m_ptr >= m_end_of_query);
943
End of file indicator for the query text to parse.
944
@param n number of characters expected
945
@return true if there are less than n characters to parse
949
return ((m_ptr + n) >= m_end_of_query);
952
/** Get the raw query buffer. */
953
const char *get_buf()
958
/** Get the pre-processed query buffer. */
959
const char *get_cpp_buf()
964
/** Get the end of the raw query buffer. */
965
const char *get_end_of_query()
967
return m_end_of_query;
970
/** Mark the stream position as the start of a new token. */
973
m_tok_start_prev= m_tok_start;
977
m_cpp_tok_start_prev= m_cpp_tok_start;
978
m_cpp_tok_start= m_cpp_ptr;
979
m_cpp_tok_end= m_cpp_ptr;
983
Adjust the starting position of the current token.
984
This is used to compensate for starting whitespace.
989
m_cpp_tok_start= m_cpp_ptr;
992
/** Get the token start position, in the raw buffer. */
993
const char *get_tok_start()
998
/** Get the token start position, in the pre-processed buffer. */
999
const char *get_cpp_tok_start()
1001
return m_cpp_tok_start;
1004
/** Get the token end position, in the raw buffer. */
1005
const char *get_tok_end()
1010
/** Get the token end position, in the pre-processed buffer. */
1011
const char *get_cpp_tok_end()
1013
return m_cpp_tok_end;
1016
/** Get the previous token start position, in the raw buffer. */
1017
const char *get_tok_start_prev()
1019
return m_tok_start_prev;
1022
/** Get the current stream pointer, in the raw buffer. */
1023
const char *get_ptr()
1028
/** Get the current stream pointer, in the pre-processed buffer. */
1029
const char *get_cpp_ptr()
1034
/** Get the length of the current token, in the raw buffer. */
1038
The assumption is that the lexical analyser is always 1 character ahead,
1039
which the -1 account for.
1041
assert(m_ptr > m_tok_start);
1042
return (uint32_t) ((m_ptr - m_tok_start) - 1);
1045
/** Get the utf8-body string. */
1046
const char *get_body_utf8_str()
1051
/** Get the utf8-body length. */
1052
uint32_t get_body_utf8_length()
1054
return m_body_utf8_ptr - m_body_utf8;
1057
void body_utf8_start(Session *session, const char *begin_ptr);
1058
void body_utf8_append(const char *ptr);
1059
void body_utf8_append(const char *ptr, const char *end_ptr);
1060
void body_utf8_append_literal(Session *session,
1061
const LEX_STRING *txt,
1062
const CHARSET_INFO * const txt_cs,
1063
const char *end_ptr);
1065
/** Current thread. */
1068
/** Current line number. */
1071
/** Length of the last token parsed. */
1074
/** Interface with bison, value of the last token parsed. */
1077
/** LALR(2) resolution, look ahead token.*/
1078
int lookahead_token;
1080
/** LALR(2) resolution, value of the look ahead token.*/
1081
LEX_YYSTYPE lookahead_yylval;
1084
/** Pointer to the current position in the raw input stream. */
1087
/** Starting position of the last token parsed, in the raw buffer. */
1088
const char *m_tok_start;
1090
/** Ending position of the previous token parsed, in the raw buffer. */
1091
const char *m_tok_end;
1093
/** End of the query text in the input stream, in the raw buffer. */
1094
const char *m_end_of_query;
1096
/** Starting position of the previous token parsed, in the raw buffer. */
1097
const char *m_tok_start_prev;
1099
/** Begining of the query text in the input stream, in the raw buffer. */
1102
/** Length of the raw buffer. */
1103
uint32_t m_buf_length;
1105
/** Echo the parsed stream to the pre-processed buffer. */
1108
/** Pre-processed buffer. */
1111
/** Pointer to the current position in the pre-processed input stream. */
1115
Starting position of the last token parsed,
1116
in the pre-processed buffer.
1118
const char *m_cpp_tok_start;
1121
Starting position of the previous token parsed,
1122
in the pre-procedded buffer.
1124
const char *m_cpp_tok_start_prev;
1127
Ending position of the previous token parsed,
1128
in the pre-processed buffer.
1130
const char *m_cpp_tok_end;
1132
/** UTF8-body buffer created during parsing. */
1135
/** Pointer to the current position in the UTF8-body buffer. */
1136
char *m_body_utf8_ptr;
1139
Position in the pre-processed buffer. The query from m_cpp_buf to
1140
m_cpp_utf_processed_ptr is converted to UTF8-body.
1142
const char *m_cpp_utf8_processed_ptr;
1146
/** Current state of the lexical analyser. */
1147
enum my_lex_states next_state;
1150
Position of ';' in the stream, to delimit multiple queries.
1151
This delimiter is in the raw buffer.
1153
const char *found_semicolon;
1155
/** Token character bitmaps, to detect 7bit strings. */
1156
unsigned char tok_bitmap;
1158
/** SQL_MODE = IGNORE_SPACE. */
1161
/** State of the lexical analyser for comments. */
1162
enum_comment_state in_comment;
1165
Starting position of the TEXT_STRING or IDENT in the pre-processed
1168
NOTE: this member must be used within DRIZZLElex() function only.
1170
const char *m_cpp_text_start;
1173
Ending position of the TEXT_STRING or IDENT in the pre-processed
1176
NOTE: this member must be used within DRIZZLElex() function only.
1178
const char *m_cpp_text_end;
1181
Character set specified by the character-set-introducer.
1183
NOTE: this member must be used within DRIZZLElex() function only.
1185
const CHARSET_INFO *m_underscore_cs;
807
#include "drizzled/lex_input_stream.h"
1189
809
/* The state of the lex parsing. This is saved in the Session struct */
1191
810
class LEX : public Query_tables_list
1198
817
/* list of all Select_Lex */
1199
818
Select_Lex *all_selects_list;
1201
char *length,*dec,*change;
820
/* This is the "scale" for DECIMAL (S,P) notation */
822
/* This is the decimal precision in DECIMAL(S,P) notation */
824
/* The text in a CHANGE COLUMN clause in ALTER TABLE */
828
* This is used kind of like the "ident" member variable below, as
829
* a place to store certain names of identifiers. Unfortunately, it
830
* is used differently depending on the Command (SELECT on a derived
1202
833
LEX_STRING name;
834
/* The string literal used in a LIKE expression */
1204
836
file_exchange *exchange;
1205
837
select_result *result;
1206
Item *default_value, *on_update_value;
1207
LEX_STRING comment, ident;
839
/* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
841
/* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
842
Item *on_update_value;
843
/* Not really sure what exactly goes in here... Comment text at beginning of statement? */
847
* This is current used to store the name of a named key cache
848
* or a named savepoint. It should probably be refactored out into
849
* the eventual Command class built for the Keycache and Savepoint
1209
854
unsigned char* yacc_yyss, *yacc_yyvs;
855
/* The owning Session of this LEX */
1210
856
Session *session;
1212
857
const CHARSET_INFO *charset;
1213
858
bool text_string_is_7bit;
1214
859
/* store original leaf_tables for INSERT SELECT and PS/SP */