~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Lee
  • Date: 2008-10-03 23:31:06 UTC
  • mfrom: (413.2.3 drizzle)
  • mto: This revision was merged to the branch mainline in revision 459.
  • Revision ID: lbieber@lbieber-desktop-20081003233106-tgvzu0fh25gb3xeg
breaking out enum field classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
  used when comparing keywords
43
43
*/
44
44
 
45
 
static unsigned char to_upper_lex[]=
 
45
static uchar to_upper_lex[]=
46
46
{
47
47
    0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
48
48
   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
74
74
  "FORCE INDEX"
75
75
};
76
76
 
77
 
inline int lex_casecmp(const char *s, const char *t, uint32_t len)
 
77
inline int lex_casecmp(const char *s, const char *t, uint len)
78
78
{
79
79
  while (len-- != 0 &&
80
 
         to_upper_lex[(unsigned char) *s++] == to_upper_lex[(unsigned char) *t++]) ;
 
80
         to_upper_lex[(uchar) *s++] == to_upper_lex[(uchar) *t++]) ;
81
81
  return (int) len+1;
82
82
}
83
83
 
86
86
 
87
87
void lex_init(void)
88
88
{
89
 
  uint32_t i;
 
89
  uint i;
90
90
  for (i=0 ; i < array_elements(symbols) ; i++)
91
 
    symbols[i].length=(unsigned char) strlen(symbols[i].name);
 
91
    symbols[i].length=(uchar) strlen(symbols[i].name);
92
92
  for (i=0 ; i < array_elements(sql_functions) ; i++)
93
 
    sql_functions[i].length=(unsigned char) strlen(sql_functions[i].name);
 
93
    sql_functions[i].length=(uchar) strlen(sql_functions[i].name);
94
94
 
95
95
  return;
96
96
}
163
163
  assert(begin_ptr);
164
164
  assert(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);
165
165
 
166
 
  uint32_t body_utf8_length=
 
166
  uint body_utf8_length=
167
167
    (m_buf_length / thd->variables.character_set_client->mbminlen) *
168
168
    my_charset_utf8_bin.mbmaxlen;
169
169
 
331
331
  lex->reset_query_tables_list(false);
332
332
  lex->expr_allows_subselect= true;
333
333
  lex->use_only_table_context= false;
334
 
  lex->parse_vcol_expr= false;
335
334
 
336
335
  lex->name.str= 0;
337
336
  lex->name.length= 0;
361
360
{
362
361
  if (lex->yacc_yyss)
363
362
  {
364
 
    free(lex->yacc_yyss);
365
 
    free(lex->yacc_yyvs);
 
363
    my_free(lex->yacc_yyss, MYF(0));
 
364
    my_free(lex->yacc_yyvs, MYF(0));
366
365
    lex->yacc_yyss= 0;
367
366
    lex->yacc_yyvs= 0;
368
367
  }
379
378
}
380
379
 
381
380
 
382
 
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
 
381
static int find_keyword(Lex_input_stream *lip, uint len, bool function)
383
382
{
384
383
  const char *tok= lip->get_tok_start();
385
384
 
408
407
    1         name isn't a keyword
409
408
*/
410
409
 
411
 
bool is_keyword(const char *name, uint32_t len)
 
410
bool is_keyword(const char *name, uint len)
412
411
{
413
412
  assert(len != 0);
414
413
  return get_hash_symbol(name,len,0)!=0;
422
421
 
423
422
/* make a copy of token before ptr and set yytoklen */
424
423
 
425
 
static LEX_STRING get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length)
 
424
static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
426
425
{
427
426
  LEX_STRING tmp;
428
427
  lip->yyUnget();                       // ptr points now after last token char
443
442
*/
444
443
 
445
444
static LEX_STRING get_quoted_token(Lex_input_stream *lip,
446
 
                                   uint32_t skip,
447
 
                                   uint32_t length, char quote)
 
445
                                   uint skip,
 
446
                                   uint length, char quote)
448
447
{
449
448
  LEX_STRING tmp;
450
449
  const char *from, *end;
479
478
 
480
479
static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip)
481
480
{
482
 
  register unsigned char c,sep;
483
 
  uint32_t found_escape=0;
 
481
  register uchar c,sep;
 
482
  uint found_escape=0;
484
483
  const CHARSET_INFO * const cs= lip->m_thd->charset();
485
484
 
486
485
  lip->tok_bitmap= 0;
605
604
/*
606
605
** Calc type of integer; long integer, int64_t integer or real.
607
606
** Returns smallest type that match the string.
608
 
** When using uint64_t values the result is converted to a real
 
607
** When using unsigned long long values the result is converted to a real
609
608
** because else they will be unexpected sign changes because all calculation
610
609
** is done with int64_t or double.
611
610
*/
612
611
 
613
612
static const char *long_str="2147483647";
614
 
static const uint32_t long_len=10;
 
613
static const uint long_len=10;
615
614
static const char *signed_long_str="-2147483648";
616
615
static const char *int64_t_str="9223372036854775807";
617
 
static const uint32_t int64_t_len=19;
 
616
static const uint int64_t_len=19;
618
617
static const char *signed_int64_t_str="-9223372036854775808";
619
 
static const uint32_t signed_int64_t_len=19;
 
618
static const uint signed_int64_t_len=19;
620
619
static const char *unsigned_int64_t_str="18446744073709551615";
621
 
static const uint32_t unsigned_int64_t_len=20;
 
620
static const uint unsigned_int64_t_len=20;
622
621
 
623
 
static inline uint32_t int_token(const char *str,uint32_t length)
 
622
static inline uint int_token(const char *str,uint length)
624
623
{
625
624
  if (length < long_len)                        // quick normal case
626
625
    return NUM;
642
641
  if (length < long_len)
643
642
    return NUM;
644
643
 
645
 
  uint32_t smaller,bigger;
 
644
  uint smaller,bigger;
646
645
  const char *cmp;
647
646
  if (neg)
648
647
  {
689
688
    }
690
689
  }
691
690
  while (*cmp && *cmp++ == *str++) ;
692
 
  return ((unsigned char) str[-1] <= (unsigned char) cmp[-1]) ? smaller : bigger;
 
691
  return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger;
693
692
}
694
693
 
695
694
 
767
766
  LEX *lex= thd->lex;
768
767
  YYSTYPE *yylval=(YYSTYPE*) arg;
769
768
  const CHARSET_INFO * const cs= thd->charset();
770
 
  unsigned char *state_map= cs->state_map;
771
 
  unsigned char *ident_map= cs->ident_map;
 
769
  uchar *state_map= cs->state_map;
 
770
  uchar *ident_map= cs->ident_map;
772
771
 
773
772
  lip->yylval=yylval;                   // The global state
774
773
 
1037
1036
 
1038
1037
    case MY_LEX_USER_VARIABLE_DELIMITER:        // Found quote char
1039
1038
    {
1040
 
      uint32_t double_quotes= 0;
 
1039
      uint double_quotes= 0;
1041
1040
      char quote_char= c;                       // Used char
1042
1041
      while ((c=lip->yyGet()))
1043
1042
      {
1592
1591
  linkage= UNSPECIFIED_TYPE;
1593
1592
  order_list.elements= 0;
1594
1593
  order_list.first= 0;
1595
 
  order_list.next= (unsigned char**) &order_list.first;
 
1594
  order_list.next= (uchar**) &order_list.first;
1596
1595
  /* Set limit and offset to default values */
1597
1596
  select_limit= 0;      /* denotes the default limit = HA_POS_ERROR */
1598
1597
  offset_limit= 0;      /* denotes the default offset = 0 */
1815
1814
bool st_select_lex_node::set_braces(bool value __attribute__((unused)))
1816
1815
{ return 1; }
1817
1816
bool st_select_lex_node::inc_in_sum_expr()           { return 1; }
1818
 
uint32_t st_select_lex_node::get_in_sum_expr()           { return 0; }
 
1817
uint st_select_lex_node::get_in_sum_expr()           { return 0; }
1819
1818
TableList* st_select_lex_node::get_table_list()     { return 0; }
1820
1819
List<Item>* st_select_lex_node::get_item_list()      { return 0; }
1821
1820
TableList *st_select_lex_node::add_table_to_list (THD *thd __attribute__((unused)),
1905
1904
}
1906
1905
 
1907
1906
 
1908
 
uint32_t st_select_lex::get_in_sum_expr()
 
1907
uint st_select_lex::get_in_sum_expr()
1909
1908
{
1910
1909
  return in_sum_expr;
1911
1910
}
1927
1926
}
1928
1927
 
1929
1928
 
1930
 
bool st_select_lex::setup_ref_array(THD *thd, uint32_t order_group_num)
 
1929
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
1931
1930
{
1932
1931
  if (ref_pointer_array)
1933
1932
    return 0;
1984
1983
    if (order->counter_used)
1985
1984
    {
1986
1985
      char buffer[20];
1987
 
      uint32_t length= snprintf(buffer, 20, "%d", order->counter);
 
1986
      uint length= snprintf(buffer, 20, "%d", order->counter);
1988
1987
      str->append(buffer, length);
1989
1988
    }
1990
1989
    else
2409
2408
    {
2410
2409
      select_lex.context.table_list= 
2411
2410
        select_lex.context.first_name_resolution_table= first->next_local;
2412
 
      select_lex.table_list.first= (unsigned char*) (first->next_local);
 
2411
      select_lex.table_list.first= (uchar*) (first->next_local);
2413
2412
      select_lex.table_list.elements--; //safety
2414
2413
      first->next_local= 0;
2415
2414
      /*
2490
2489
    {
2491
2490
      first->next_local= (TableList*) select_lex.table_list.first;
2492
2491
      select_lex.context.table_list= first;
2493
 
      select_lex.table_list.first= (unsigned char*) first;
 
2492
      select_lex.table_list.first= (uchar*) first;
2494
2493
      select_lex.table_list.elements++; //safety
2495
2494
    }
2496
2495
  }
2675
2674
  RETURN VALUE
2676
2675
    0 on success, non-zero otherwise
2677
2676
*/
2678
 
bool st_select_lex::add_index_hint (THD *thd, char *str, uint32_t length)
 
2677
bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
2679
2678
{
2680
2679
  return index_hints->push_front (new (thd->mem_root) 
2681
2680
                                 Index_hint(current_index_hint_type,