~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <drizzled/item/subselect.h>
34
34
#include <drizzled/statement.h>
35
35
#include <drizzled/sql_lex.h>
 
36
#include <drizzled/plugin.h>
 
37
#include <drizzled/lex_input_stream.h>
36
38
 
37
39
#include <cstdio>
38
40
#include <ctype.h>
39
41
 
 
42
#include <drizzled/message/alter_table.pb.h>
 
43
 
40
44
union ParserType;
41
45
 
42
46
using namespace std;
44
48
/* Stay outside of the namespace because otherwise bison goes nuts */
45
49
int base_sql_lex(ParserType *arg, drizzled::Session *yysession);
46
50
 
47
 
namespace drizzled
48
 
{
 
51
namespace drizzled {
49
52
 
50
53
static int lex_one_token(ParserType *arg, drizzled::Session *yysession);
51
54
 
52
55
/**
53
56
  save order by and tables in own lists.
54
57
*/
55
 
static bool add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
 
58
static void add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
56
59
{
57
 
  Order *order;
58
 
 
59
 
  if (!(order = (Order *) session->getMemRoot()->allocate(sizeof(Order))))
60
 
    return true;
61
 
 
 
60
  Order* order = new (session->mem) Order;
62
61
  order->item_ptr= item;
63
62
  order->item= &order->item_ptr;
64
63
  order->asc = asc;
66
65
  order->used=0;
67
66
  order->counter_used= 0;
68
67
  list.link_in_list((unsigned char*) order, (unsigned char**) &order->next);
69
 
 
70
 
  return false;
71
68
}
72
69
 
73
 
/**
74
 
  LEX_STRING constant for null-string to be used in parser and other places.
75
 
*/
76
 
const LEX_STRING null_lex_str= {NULL, 0};
77
 
 
78
70
Lex_input_stream::Lex_input_stream(Session *session,
79
71
                                   const char* buffer,
80
72
                                   unsigned int length) :
101
93
  ignore_space(1),
102
94
  in_comment(NO_COMMENT)
103
95
{
104
 
  m_cpp_buf= (char*) session->getMemRoot()->allocate(length + 1);
 
96
  m_cpp_buf= (char*) session->mem.alloc(length + 1);
105
97
  m_cpp_ptr= m_cpp_buf;
106
98
}
107
99
 
108
 
Lex_input_stream::~Lex_input_stream()
109
 
{}
110
 
 
111
 
/**
112
 
  The operation is called from the parser in order to
113
 
  1) designate the intention to have utf8 body;
114
 
  1) Indicate to the lexer that we will need a utf8 representation of this
115
 
     statement;
116
 
  2) Determine the beginning of the body.
117
 
 
118
 
  @param session        Thread context.
119
 
  @param begin_ptr  Pointer to the start of the body in the pre-processed
120
 
                    buffer.
121
 
*/
122
 
void Lex_input_stream::body_utf8_start(Session *session, const char *begin_ptr)
123
 
{
124
 
  assert(begin_ptr);
125
 
  assert(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);
126
 
 
127
 
  uint32_t body_utf8_length=
128
 
    (m_buf_length / default_charset_info->mbminlen) *
129
 
    my_charset_utf8_bin.mbmaxlen;
130
 
 
131
 
  m_body_utf8= (char *) session->getMemRoot()->allocate(body_utf8_length + 1);
132
 
  m_body_utf8_ptr= m_body_utf8;
133
 
  *m_body_utf8_ptr= 0;
134
 
 
135
 
  m_cpp_utf8_processed_ptr= begin_ptr;
136
 
}
137
 
 
138
100
/**
139
101
  @brief The operation appends unprocessed part of pre-processed buffer till
140
102
  the given pointer (ptr) and sets m_cpp_utf8_processed_ptr to end_ptr.
155
117
                  m_cpp_utf8_processed_ptr will be set in the end of the
156
118
                  operation.
157
119
*/
158
 
void Lex_input_stream::body_utf8_append(const char *ptr,
159
 
                                        const char *end_ptr)
 
120
void Lex_input_stream::body_utf8_append(const char *ptr, const char *end_ptr)
160
121
{
161
122
  assert(m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length);
162
123
  assert(m_cpp_buf <= end_ptr && end_ptr <= m_cpp_buf + m_buf_length);
199
160
                  m_cpp_utf8_processed_ptr will be set in the end of the
200
161
                  operation.
201
162
*/
202
 
void Lex_input_stream::body_utf8_append_literal(const LEX_STRING *txt,
203
 
                                                const char *end_ptr)
 
163
void Lex_input_stream::body_utf8_append_literal(str_ref txt, const char *end_ptr)
204
164
{
205
165
  if (!m_cpp_utf8_processed_ptr)
206
166
    return;
207
167
 
208
168
  /* NOTE: utf_txt.length is in bytes, not in symbols. */
209
169
 
210
 
  memcpy(m_body_utf8_ptr, txt->str, txt->length);
211
 
  m_body_utf8_ptr += txt->length;
 
170
  memcpy(m_body_utf8_ptr, txt.data(), txt.size());
 
171
  m_body_utf8_ptr += txt.size();
212
172
  *m_body_utf8_ptr= 0;
213
173
 
214
174
  m_cpp_utf8_processed_ptr= end_ptr;
270
230
  lex->expr_allows_subselect= true;
271
231
  lex->use_only_table_context= false;
272
232
 
273
 
  lex->name.str= 0;
274
 
  lex->name.length= 0;
 
233
  lex->name.assign(NULL, 0);
275
234
  lex->nest_level=0 ;
276
235
  lex->allow_sum_func= 0;
277
236
  lex->in_sum_func= NULL;
296
255
 
297
256
  safe_delete(result);
298
257
  safe_delete(_create_table);
 
258
  safe_delete(_alter_table);
299
259
  _create_table= NULL;
 
260
  _alter_table= NULL;
300
261
  _create_field= NULL;
301
262
 
302
263
  result= 0;
312
273
  const char *tok= lip->get_tok_start();
313
274
  uint32_t tok_pos= 0;
314
275
  for (;tok_pos<len && tok_pos<63;tok_pos++)
315
 
    tok_upper[tok_pos]=my_toupper(system_charset_info, tok[tok_pos]);
 
276
    tok_upper[tok_pos]= system_charset_info->toupper(tok[tok_pos]);
316
277
  tok_upper[tok_pos]=0;
317
278
 
318
279
  const SYMBOL *symbol= lookup_symbol(tok_upper, len, function);
328
289
  return 0;
329
290
}
330
291
 
331
 
bool is_lex_native_function(const LEX_STRING *name)
332
 
{
333
 
  assert(name != NULL);
334
 
  return (lookup_symbol(name->str, name->length, 1) != 0);
335
 
}
336
 
 
337
292
/* make a copy of token before ptr and set yytoklen */
338
 
static LEX_STRING get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length)
 
293
static lex_string_t get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length)
339
294
{
340
 
  LEX_STRING tmp;
341
295
  lip->yyUnget();                       // ptr points now after last token char
342
 
  tmp.length=lip->yytoklen=length;
343
 
  tmp.str= lip->m_session->strmake(lip->get_tok_start() + skip, tmp.length);
344
 
 
 
296
  lip->yytoklen= length;
 
297
  lex_string_t tmp;
 
298
  tmp.assign(lip->m_session->mem.strdup(lip->get_tok_start() + skip, length), length);
345
299
  lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
346
 
  lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.length;
347
 
 
 
300
  lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.size();
348
301
  return tmp;
349
302
}
350
303
 
354
307
   get_quoted_token yet. But it should be fixed in the
355
308
   future to operate multichar strings (like ucs2)
356
309
*/
357
 
static LEX_STRING get_quoted_token(Lex_input_stream *lip,
 
310
static lex_string_t get_quoted_token(Lex_input_stream *lip,
358
311
                                   uint32_t skip,
359
312
                                   uint32_t length, char quote)
360
313
{
361
 
  LEX_STRING tmp;
362
 
  const char *from, *end;
363
 
  char *to;
364
314
  lip->yyUnget();                       // ptr points now after last token char
365
 
  tmp.length= lip->yytoklen=length;
366
 
  tmp.str=(char*) lip->m_session->getMemRoot()->allocate(tmp.length+1);
367
 
  from= lip->get_tok_start() + skip;
368
 
  to= tmp.str;
369
 
  end= to+length;
 
315
  lip->yytoklen= length;
 
316
  lex_string_t tmp;
 
317
  tmp.assign((char*)lip->m_session->mem.alloc(length + 1), length);
 
318
  const char* from= lip->get_tok_start() + skip;
 
319
  char* to= (char*)tmp.data();
 
320
  const char* end= to+length;
370
321
 
371
322
  lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
372
323
  lip->m_cpp_text_end= lip->m_cpp_text_start + length;
390
341
*/
391
342
static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip)
392
343
{
393
 
  unsigned char c,sep;
394
344
  bool found_escape= false;
395
 
  const CHARSET_INFO * const cs= lip->m_session->charset();
 
345
  const charset_info_st* const cs= lip->m_session->charset();
396
346
 
397
347
  lip->tok_bitmap= 0;
398
 
  sep= lip->yyGetLast();                        // String should end with this
399
 
  while (! lip->eof())
 
348
  unsigned char sep= lip->yyGetLast();                        // String should end with this
 
349
  while (not lip->eof())
400
350
  {
401
 
    c= lip->yyGet();
 
351
    unsigned char c= lip->yyGet();
402
352
    lip->tok_bitmap|= c;
403
353
    {
404
354
      if (use_mb(cs))
429
379
        lip->yyUnget();
430
380
 
431
381
      /* Found end. Unescape and return string */
432
 
      const char *str, *end;
433
 
      char *start;
434
 
 
435
 
      str= lip->get_tok_start();
436
 
      end= lip->get_ptr();
 
382
      const char* str= lip->get_tok_start();
 
383
      const char* end= lip->get_ptr();
437
384
      /* Extract the text from the token */
438
385
      str+= pre_skip;
439
386
      end-= post_skip;
440
387
      assert(end >= str);
441
388
 
442
 
      if (!(start= (char*) lip->m_session->getMemRoot()->allocate((uint32_t) (end-str)+1)))
443
 
        return (char*) "";              // memory::SqlAlloc has set error flag
 
389
      char* start= (char*) lip->m_session->mem.alloc((uint32_t) (end-str)+1);
444
390
 
445
391
      lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip;
446
392
      lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip;
674
620
  enum my_lex_states state;
675
621
  Lex_input_stream *lip= session->m_lip;
676
622
  LEX *lex= &session->lex();
677
 
  const CHARSET_INFO * const cs= session->charset();
 
623
  const charset_info_st * const cs= session->charset();
678
624
  unsigned char *state_map= cs->state_map;
679
625
  unsigned char *ident_map= cs->ident_map;
680
626
 
705
651
    case MY_LEX_ESCAPE:
706
652
      if (lip->yyGet() == 'N')
707
653
      {                                 // Allow \N as shortcut for NULL
708
 
        yylval->lex_str.str=(char*) "\\N";
709
 
        yylval->lex_str.length=2;
 
654
        yylval->lex_str.assign("\\N", 2);
710
655
        return NULL_SYM;
711
656
      }
712
657
    case MY_LEX_CHAR:                   // Unknown or single char token
713
658
    case MY_LEX_SKIP:                   // This should not happen
714
659
      if (c == '-' && lip->yyPeek() == '-' &&
715
 
          (my_isspace(cs,lip->yyPeekn(1)) ||
716
 
           my_iscntrl(cs,lip->yyPeekn(1))))
 
660
          (cs->isspace(lip->yyPeekn(1)) ||
 
661
           cs->iscntrl(lip->yyPeekn(1))))
717
662
      {
718
663
        state=MY_LEX_COMMENT;
719
664
        break;
805
750
        }
806
751
        lip->yySkip();                  // next state does a unget
807
752
      }
808
 
      yylval->lex_str=get_token(lip, 0, length);
 
753
      yylval->lex_str= get_token(lip, 0, length);
809
754
 
810
755
      lip->body_utf8_append(lip->m_cpp_text_start);
811
756
 
812
 
      lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
 
757
      lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
813
758
 
814
759
      return(result_state);                     // IDENT or IDENT_QUOTED
815
760
 
816
761
    case MY_LEX_IDENT_SEP:              // Found ident and now '.'
817
 
      yylval->lex_str.str= (char*) lip->get_ptr();
818
 
      yylval->lex_str.length= 1;
 
762
      yylval->lex_str.assign(lip->get_ptr(), 1);
819
763
      c= lip->yyGet();                  // should be '.'
820
764
      lip->next_state= MY_LEX_IDENT_START;// Next is an ident (not a keyword)
821
765
      if (!ident_map[(uint8_t)lip->yyPeek()])            // Probably ` or "
828
772
        c= lip->yyGet();
829
773
        if (c == 'x')
830
774
        {
831
 
          while (my_isxdigit(cs,(c = lip->yyGet()))) ;
 
775
          while (cs->isxdigit((c = lip->yyGet()))) ;
832
776
          if ((lip->yyLength() >= 3) && !ident_map[c])
833
777
          {
834
778
            /* skip '0x' */
835
 
            yylval->lex_str=get_token(lip, 2, lip->yyLength()-2);
 
779
            yylval->lex_str= get_token(lip, 2, lip->yyLength()-2);
836
780
            return (HEX_NUM);
837
781
          }
838
782
          lip->yyUnget();
855
799
        lip->yyUnget();
856
800
      }
857
801
 
858
 
      while (my_isdigit(cs, (c = lip->yyGet()))) ;
 
802
      while (cs->isdigit((c = lip->yyGet()))) ;
859
803
      if (!ident_map[c])
860
804
      {                                 // Can't be identifier
861
805
        state=MY_LEX_INT_OR_REAL;
864
808
      if (c == 'e' || c == 'E')
865
809
      {
866
810
        // The following test is written this way to allow numbers of type 1e1
867
 
        if (my_isdigit(cs,lip->yyPeek()) ||
 
811
        if (cs->isdigit(lip->yyPeek()) ||
868
812
            (c=(lip->yyGet())) == '+' || c == '-')
869
813
        {                               // Allow 1E+10
870
 
          if (my_isdigit(cs,lip->yyPeek()))     // Number must have digit after sign
 
814
          if (cs->isdigit(lip->yyPeek()))     // Number must have digit after sign
871
815
          {
872
816
            lip->yySkip();
873
 
            while (my_isdigit(cs,lip->yyGet())) ;
874
 
            yylval->lex_str=get_token(lip, 0, lip->yyLength());
 
817
            while (cs->isdigit(lip->yyGet())) ;
 
818
            yylval->lex_str= get_token(lip, 0, lip->yyLength());
875
819
            return(FLOAT_NUM);
876
820
          }
877
821
        }
906
850
      yylval->lex_str= get_token(lip, 0, lip->yyLength());
907
851
 
908
852
      lip->body_utf8_append(lip->m_cpp_text_start);
909
 
 
910
 
      lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
 
853
      lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
911
854
 
912
855
      return(result_state);
913
856
 
933
876
          break;                                // Error
934
877
        lip->skip_binary(var_length-1);
935
878
      }
936
 
      if (double_quotes)
937
 
              yylval->lex_str=get_quoted_token(lip, 1, lip->yyLength() - double_quotes -1, quote_char);
938
 
      else
939
 
        yylval->lex_str=get_token(lip, 1, lip->yyLength() -1);
 
879
      yylval->lex_str= double_quotes
 
880
        ? get_quoted_token(lip, 1, lip->yyLength() - double_quotes - 1, quote_char)
 
881
        : get_token(lip, 1, lip->yyLength() - 1);
940
882
      if (c == quote_char)
941
883
        lip->yySkip();                  // Skip end `
942
884
      lip->next_state= MY_LEX_START;
943
885
      lip->body_utf8_append(lip->m_cpp_text_start);
944
 
      lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
945
 
      return(IDENT_QUOTED);
 
886
      lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
 
887
      return IDENT_QUOTED;
946
888
    }
947
889
    case MY_LEX_INT_OR_REAL:            // Complete int or incomplete real
948
890
      if (c != '.')
949
891
      {                                 // Found complete integer number.
950
892
        yylval->lex_str=get_token(lip, 0, lip->yyLength());
951
 
        return int_token(yylval->lex_str.str,yylval->lex_str.length);
 
893
        return int_token(yylval->lex_str.data(), yylval->lex_str.size());
952
894
      }
953
895
      // fall through
954
896
    case MY_LEX_REAL:                   // Incomplete real number
955
 
      while (my_isdigit(cs,c = lip->yyGet())) ;
 
897
      while (cs->isdigit(c = lip->yyGet())) ;
956
898
 
957
899
      if (c == 'e' || c == 'E')
958
900
      {
959
901
        c = lip->yyGet();
960
902
        if (c == '-' || c == '+')
961
903
                c = lip->yyGet();                     // Skip sign
962
 
        if (!my_isdigit(cs,c))
 
904
        if (!cs->isdigit(c))
963
905
        {                               // No digit after sign
964
906
          state= MY_LEX_CHAR;
965
907
          break;
966
908
        }
967
 
        while (my_isdigit(cs,lip->yyGet())) ;
 
909
        while (cs->isdigit(lip->yyGet())) ;
968
910
        yylval->lex_str=get_token(lip, 0, lip->yyLength());
969
911
        return(FLOAT_NUM);
970
912
      }
973
915
 
974
916
    case MY_LEX_HEX_NUMBER:             // Found x'hexstring'
975
917
      lip->yySkip();                    // Accept opening '
976
 
      while (my_isxdigit(cs, (c= lip->yyGet()))) ;
 
918
      while (cs->isxdigit((c= lip->yyGet()))) ;
977
919
      if (c != '\'')
978
920
        return(ABORT_SYM);              // Illegal hex constant
979
921
      lip->yySkip();                    // Accept closing '
980
922
      length= lip->yyLength();          // Length of hexnum+3
981
 
      if ((length % 2) == 0)
982
 
        return(ABORT_SYM);              // odd number of hex digits
 
923
      if (length % 2 == 0)
 
924
        return ABORT_SYM;               // odd number of hex digits
983
925
      yylval->lex_str=get_token(lip,
984
926
                                2,          // skip x'
985
927
                                length-3);  // don't count x' and last '
1044
986
      }
1045
987
      /* " used for strings */
1046
988
    case MY_LEX_STRING:                 // Incomplete text string
1047
 
      if (!(yylval->lex_str.str = get_text(lip, 1, 1)))
 
989
      if (!(yylval->lex_str.str_ = get_text(lip, 1, 1)))
1048
990
      {
1049
991
        state= MY_LEX_CHAR;             // Read char by char
1050
992
        break;
1051
993
      }
1052
 
      yylval->lex_str.length=lip->yytoklen;
 
994
      yylval->lex_str.assign(yylval->lex_str.data(), lip->yytoklen);
1053
995
 
1054
996
      lip->body_utf8_append(lip->m_cpp_text_start);
1055
 
 
1056
 
      lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
 
997
      lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
1057
998
 
1058
999
      lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1;
1059
1000
      return(TEXT_STRING);
1221
1162
      /* Actually real shouldn't start with . but allow them anyhow */
1222
1163
 
1223
1164
    case MY_LEX_REAL_OR_POINT:
1224
 
      if (my_isdigit(cs,lip->yyPeek()))
 
1165
      if (cs->isdigit(lip->yyPeek()))
1225
1166
        state= MY_LEX_REAL;             // Real
1226
1167
      else
1227
1168
      {
1243
1184
        lip->next_state=MY_LEX_HOSTNAME;
1244
1185
        break;
1245
1186
      }
1246
 
      yylval->lex_str.str=(char*) lip->get_ptr();
1247
 
      yylval->lex_str.length=1;
1248
 
      return((int) '@');
 
1187
      yylval->lex_str.assign(lip->get_ptr(), 1);
 
1188
      return '@';
1249
1189
 
1250
1190
    case MY_LEX_HOSTNAME:               // end '@' of user@hostname
1251
1191
      for (c=lip->yyGet() ;
1252
 
           my_isalnum(cs,c) || c == '.' || c == '_' ||  c == '$';
 
1192
           cs->isalnum(c) || c == '.' || c == '_' ||  c == '$';
1253
1193
           c= lip->yyGet()) ;
1254
1194
      yylval->lex_str=get_token(lip, 0, lip->yyLength());
1255
1195
      return(LEX_HOSTNAME);
1256
1196
 
1257
1197
    case MY_LEX_SYSTEM_VAR:
1258
 
      yylval->lex_str.str=(char*) lip->get_ptr();
1259
 
      yylval->lex_str.length=1;
 
1198
      yylval->lex_str.assign(lip->get_ptr(), 1);
1260
1199
      lip->yySkip();                                    // Skip '@'
1261
1200
      lip->next_state= (state_map[(uint8_t)lip->yyPeek()] ==
1262
1201
                        MY_LEX_USER_VARIABLE_DELIMITER ?
1290
1229
      yylval->lex_str=get_token(lip, 0, length);
1291
1230
 
1292
1231
      lip->body_utf8_append(lip->m_cpp_text_start);
1293
 
 
1294
 
      lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1295
 
 
1296
 
      return(result_state);
 
1232
      lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
 
1233
 
 
1234
      return result_state;
1297
1235
    }
1298
1236
  }
1299
1237
}
1300
1238
 
1301
 
void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str)
1302
 
{
1303
 
  /*
1304
 
    TODO:
1305
 
    This code assumes that there are no multi-bytes characters
1306
 
    that can be considered white-space.
1307
 
  */
1308
 
  while ((str->length > 0) && (my_isspace(cs, str->str[0])))
1309
 
  {
1310
 
    str->length--;
1311
 
    str->str++;
1312
 
  }
1313
 
 
1314
 
  /*
1315
 
    FIXME:
1316
 
    Also, parsing backward is not safe with multi bytes characters
1317
 
  */
1318
 
  while ((str->length > 0) && (my_isspace(cs, str->str[str->length-1])))
1319
 
  {
1320
 
    str->length--;
1321
 
  }
1322
 
}
1323
 
 
1324
1239
/*
1325
1240
  Select_Lex structures initialisations
1326
1241
*/
1634
1549
 
1635
1550
TableList *Select_Lex_Node::add_table_to_list(Session *,
1636
1551
                                              Table_ident *,
1637
 
                                              LEX_STRING *,
 
1552
                                              lex_string_t *,
1638
1553
                                              const bitset<NUM_OF_TABLE_OPTIONS>&,
1639
1554
                                              thr_lock_type,
1640
1555
                                              List<Index_hint> *,
1641
 
                                              LEX_STRING *)
 
1556
                                              lex_string_t *)
1642
1557
{
1643
1558
  return 0;
1644
1559
}
1668
1583
  return (Select_Lex*) master;
1669
1584
}
1670
1585
 
1671
 
bool Select_Lex::add_order_to_list(Session *session, Item *item, bool asc)
1672
 
{
1673
 
  return add_to_list(session, order_list, item, asc);
1674
 
}
1675
 
 
1676
 
bool Select_Lex::add_item_to_list(Session *, Item *item)
1677
 
{
1678
 
  return(item_list.push_back(item));
1679
 
}
1680
 
 
1681
 
bool Select_Lex::add_group_to_list(Session *session, Item *item, bool asc)
1682
 
{
1683
 
  return add_to_list(session, group_list, item, asc);
 
1586
void Select_Lex::add_order_to_list(Session *session, Item *item, bool asc)
 
1587
{
 
1588
  add_to_list(session, order_list, item, asc);
 
1589
}
 
1590
 
 
1591
void Select_Lex::add_item_to_list(Session *, Item *item)
 
1592
{
 
1593
        item_list.push_back(item);
 
1594
}
 
1595
 
 
1596
void Select_Lex::add_group_to_list(Session *session, Item *item, bool asc)
 
1597
{
 
1598
  add_to_list(session, group_list, item, asc);
1684
1599
}
1685
1600
 
1686
1601
Select_Lex_Unit* Select_Lex::master_unit()
1720
1635
  return &item_list;
1721
1636
}
1722
1637
 
1723
 
 
1724
 
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
 
1638
void Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1725
1639
{
1726
 
  if (ref_pointer_array)
1727
 
    return false;
1728
 
 
1729
 
  return (ref_pointer_array=
1730
 
          (Item **)session->getMemRoot()->allocate(sizeof(Item*) * (n_child_sum_items +
1731
 
                                                 item_list.size() +
1732
 
                                                 select_n_having_items +
1733
 
                                                 select_n_where_fields +
1734
 
                                                 order_group_num)*5)) == 0;
 
1640
  if (not ref_pointer_array)
 
1641
    ref_pointer_array= new (session->mem) Item*[5 * (n_child_sum_items + item_list.size() + select_n_having_items + select_n_where_fields + order_group_num)];
1735
1642
}
1736
1643
 
1737
1644
void Select_Lex_Unit::print(String *str)
1827
1734
LEX::~LEX()
1828
1735
{
1829
1736
  delete _create_table;
 
1737
  delete _alter_table;
1830
1738
}
1831
1739
 
1832
1740
/*
1890
1798
    cacheable(true),
1891
1799
    sum_expr_used(false),
1892
1800
    _create_table(NULL),
 
1801
    _alter_table(NULL),
1893
1802
    _create_field(NULL),
1894
1803
    _exists(false)
1895
1804
{
1896
1805
  reset_query_tables_list(true);
1897
1806
}
1898
1807
 
1899
 
/**
1900
 
  This method should be called only during parsing.
1901
 
  It is aware of compound statements (stored routine bodies)
1902
 
  and will initialize the destination with the default
1903
 
  database of the stored routine, rather than the default
1904
 
  database of the connection it is parsed in.
1905
 
  E.g. if one has no current database selected, or current database
1906
 
  set to 'bar' and then issues:
1907
 
 
1908
 
  CREATE PROCEDURE foo.p1() BEGIN SELECT * FROM t1 END//
1909
 
 
1910
 
  t1 is meant to refer to foo.t1, not to bar.t1.
1911
 
 
1912
 
  This method is needed to support this rule.
1913
 
 
1914
 
  @return true in case of error (parsing should be aborted, false in
1915
 
  case of success
1916
 
*/
1917
 
bool LEX::copy_db_to(char **p_db, size_t *p_db_length) const
1918
 
{
1919
 
  return session->copy_db_to(p_db, p_db_length);
1920
 
}
1921
 
 
1922
1808
/*
1923
1809
  initialize limit counters
1924
1810
 
2130
2016
    Then the context variable index_hint_type can be reset to the
2131
2017
    next hint type.
2132
2018
*/
2133
 
void Select_Lex::set_index_hint_type(enum index_hint_type type_arg, index_clause_map clause)
 
2019
void Select_Lex::set_index_hint_type(index_hint_type type_arg, index_clause_map clause)
2134
2020
{
2135
2021
  current_index_hint_type= type_arg;
2136
2022
  current_index_hint_clause= clause;
2161
2047
  RETURN VALUE
2162
2048
    0 on success, non-zero otherwise
2163
2049
*/
2164
 
bool Select_Lex::add_index_hint (Session *session, char *str, uint32_t length)
2165
 
{
2166
 
  return index_hints->push_front (new (session->mem_root)
2167
 
                                 Index_hint(current_index_hint_type,
2168
 
                                            current_index_hint_clause,
2169
 
                                            str, length));
2170
 
}
2171
 
 
2172
 
bool check_for_sql_keyword(drizzled::lex_string_t const& string)
2173
 
{
2174
 
  if (sql_reserved_words::in_word_set(string.str, string.length))
2175
 
      return true;
2176
 
 
2177
 
  return false;
2178
 
}
2179
 
 
2180
 
bool check_for_sql_keyword(drizzled::st_lex_symbol const& string)
2181
 
{
2182
 
  if (sql_reserved_words::in_word_set(string.str, string.length))
2183
 
      return true;
2184
 
 
2185
 
  return false;
2186
 
}
2187
 
 
 
2050
void Select_Lex::add_index_hint(Session *session, const char *str)
 
2051
{
 
2052
  index_hints->push_front(new (session->mem_root) Index_hint(current_index_hint_type, current_index_hint_clause, str));
 
2053
}
 
2054
 
 
2055
message::AlterTable *LEX::alter_table()
 
2056
{
 
2057
  if (not _alter_table)
 
2058
    _alter_table= new message::AlterTable;
 
2059
 
 
2060
  return _alter_table;
 
2061
}
2188
2062
 
2189
2063
} /* namespace drizzled */