~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
18
18
 
19
 
#define MYSQL_LEX 1
20
 
#include "mysql_priv.h"
21
 
#include "item_create.h"
22
 
#include <m_ctype.h>
23
 
#include <hash.h>
 
19
#define DRIZZLE_LEX 1
 
20
#include <drizzled/server_includes.h>
24
21
 
25
22
static int lex_one_token(void *arg, void *yythd);
26
23
 
45
42
  used when comparing keywords
46
43
*/
47
44
 
48
 
static uchar to_upper_lex[]=
 
45
static unsigned char to_upper_lex[]=
49
46
{
50
47
    0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
51
48
   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
77
74
  "FORCE INDEX"
78
75
};
79
76
 
80
 
inline int lex_casecmp(const char *s, const char *t, uint len)
 
77
inline int lex_casecmp(const char *s, const char *t, uint32_t len)
81
78
{
82
79
  while (len-- != 0 &&
83
 
         to_upper_lex[(uchar) *s++] == to_upper_lex[(uchar) *t++]) ;
 
80
         to_upper_lex[(unsigned char) *s++] == to_upper_lex[(unsigned char) *t++]) ;
84
81
  return (int) len+1;
85
82
}
86
83
 
89
86
 
90
87
void lex_init(void)
91
88
{
92
 
  uint i;
 
89
  uint32_t i;
93
90
  for (i=0 ; i < array_elements(symbols) ; i++)
94
 
    symbols[i].length=(uchar) strlen(symbols[i].name);
 
91
    symbols[i].length=(unsigned char) strlen(symbols[i].name);
95
92
  for (i=0 ; i < array_elements(sql_functions) ; i++)
96
 
    sql_functions[i].length=(uchar) strlen(sql_functions[i].name);
 
93
    sql_functions[i].length=(unsigned char) strlen(sql_functions[i].name);
97
94
 
98
95
  return;
99
96
}
139
136
  next_state(MY_LEX_START),
140
137
  found_semicolon(NULL),
141
138
  ignore_space(1),
142
 
  stmt_prepare_mode(false),
143
139
  in_comment(NO_COMMENT),
144
140
  m_underscore_cs(NULL)
145
141
{
167
163
  assert(begin_ptr);
168
164
  assert(m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length);
169
165
 
170
 
  uint body_utf8_length=
 
166
  uint32_t body_utf8_length=
171
167
    (m_buf_length / thd->variables.character_set_client->mbminlen) *
172
168
    my_charset_utf8_bin.mbmaxlen;
173
169
 
247
243
 
248
244
void Lex_input_stream::body_utf8_append_literal(THD *thd,
249
245
                                                const LEX_STRING *txt,
250
 
                                                CHARSET_INFO *txt_cs,
 
246
                                                const CHARSET_INFO * const txt_cs,
251
247
                                                const char *end_ptr)
252
248
{
253
249
  if (!m_cpp_utf8_processed_ptr)
299
295
  lex->value_list.empty();
300
296
  lex->update_list.empty();
301
297
  lex->param_list.empty();
302
 
  lex->view_list.empty();
303
298
  lex->auxiliary_table_list.empty();
304
299
  lex->unit.next= lex->unit.master=
305
300
    lex->unit.link_next= lex->unit.return_to= 0;
336
331
  lex->reset_query_tables_list(false);
337
332
  lex->expr_allows_subselect= true;
338
333
  lex->use_only_table_context= false;
 
334
  lex->parse_vcol_expr= false;
339
335
 
340
336
  lex->name.str= 0;
341
337
  lex->name.length= 0;
344
340
  lex->in_sum_func= NULL;
345
341
  /*
346
342
    ok, there must be a better solution for this, long-term
347
 
    I tried "bzero" in the sql_yacc.yy code, but that for
 
343
    I tried "memset" in the sql_yacc.yy code, but that for
348
344
    some reason made the values zero, even if they were set
349
345
  */
350
346
  lex->server_options.server_name= 0;
354
350
  lex->server_options.username= 0;
355
351
  lex->server_options.password= 0;
356
352
  lex->server_options.scheme= 0;
357
 
  lex->server_options.socket= 0;
358
353
  lex->server_options.owner= 0;
359
354
  lex->server_options.port= -1;
360
355
 
366
361
{
367
362
  if (lex->yacc_yyss)
368
363
  {
369
 
    my_free(lex->yacc_yyss, MYF(0));
370
 
    my_free(lex->yacc_yyvs, MYF(0));
 
364
    free(lex->yacc_yyss);
 
365
    free(lex->yacc_yyvs);
371
366
    lex->yacc_yyss= 0;
372
367
    lex->yacc_yyvs= 0;
373
368
  }
377
372
                     lex->plugins.elements);
378
373
  reset_dynamic(&lex->plugins);
379
374
 
 
375
  delete lex->result;
 
376
  lex->result= 0;
 
377
 
380
378
  return;
381
379
}
382
380
 
383
381
 
384
 
static int find_keyword(Lex_input_stream *lip, uint len, bool function)
 
382
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
385
383
{
386
384
  const char *tok= lip->get_tok_start();
387
385
 
410
408
    1         name isn't a keyword
411
409
*/
412
410
 
413
 
bool is_keyword(const char *name, uint len)
 
411
bool is_keyword(const char *name, uint32_t len)
414
412
{
415
413
  assert(len != 0);
416
414
  return get_hash_symbol(name,len,0)!=0;
424
422
 
425
423
/* make a copy of token before ptr and set yytoklen */
426
424
 
427
 
static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
 
425
static LEX_STRING get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length)
428
426
{
429
427
  LEX_STRING tmp;
430
428
  lip->yyUnget();                       // ptr points now after last token char
445
443
*/
446
444
 
447
445
static LEX_STRING get_quoted_token(Lex_input_stream *lip,
448
 
                                   uint skip,
449
 
                                   uint length, char quote)
 
446
                                   uint32_t skip,
 
447
                                   uint32_t length, char quote)
450
448
{
451
449
  LEX_STRING tmp;
452
450
  const char *from, *end;
481
479
 
482
480
static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip)
483
481
{
484
 
  register uchar c,sep;
485
 
  uint found_escape=0;
486
 
  CHARSET_INFO *cs= lip->m_thd->charset();
 
482
  register unsigned char c,sep;
 
483
  uint32_t found_escape=0;
 
484
  const CHARSET_INFO * const cs= lip->m_thd->charset();
487
485
 
488
486
  lip->tok_bitmap= 0;
489
487
  sep= lip->yyGetLast();                        // String should end with this
559
557
              continue;
560
558
          }
561
559
#endif
562
 
          if (!(lip->m_thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
563
 
              *str == '\\' && str+1 != end)
 
560
          if (*str == '\\' && str+1 != end)
564
561
          {
565
562
            switch(*++str) {
566
563
            case 'n':
608
605
/*
609
606
** Calc type of integer; long integer, int64_t integer or real.
610
607
** Returns smallest type that match the string.
611
 
** When using unsigned long long values the result is converted to a real
 
608
** When using uint64_t values the result is converted to a real
612
609
** because else they will be unexpected sign changes because all calculation
613
610
** is done with int64_t or double.
614
611
*/
615
612
 
616
613
static const char *long_str="2147483647";
617
 
static const uint long_len=10;
 
614
static const uint32_t long_len=10;
618
615
static const char *signed_long_str="-2147483648";
619
616
static const char *int64_t_str="9223372036854775807";
620
 
static const uint int64_t_len=19;
 
617
static const uint32_t int64_t_len=19;
621
618
static const char *signed_int64_t_str="-9223372036854775808";
622
 
static const uint signed_int64_t_len=19;
 
619
static const uint32_t signed_int64_t_len=19;
623
620
static const char *unsigned_int64_t_str="18446744073709551615";
624
 
static const uint unsigned_int64_t_len=20;
 
621
static const uint32_t unsigned_int64_t_len=20;
625
622
 
626
 
static inline uint int_token(const char *str,uint length)
 
623
static inline uint32_t int_token(const char *str,uint32_t length)
627
624
{
628
625
  if (length < long_len)                        // quick normal case
629
626
    return NUM;
645
642
  if (length < long_len)
646
643
    return NUM;
647
644
 
648
 
  uint smaller,bigger;
 
645
  uint32_t smaller,bigger;
649
646
  const char *cmp;
650
647
  if (neg)
651
648
  {
692
689
    }
693
690
  }
694
691
  while (*cmp && *cmp++ == *str++) ;
695
 
  return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger;
 
692
  return ((unsigned char) str[-1] <= (unsigned char) cmp[-1]) ? smaller : bigger;
696
693
}
697
694
 
698
695
 
729
726
  switch(token) {
730
727
  case WITH:
731
728
    /*
732
 
      Parsing 'WITH' 'ROLLUP' or 'WITH' 'CUBE' requires 2 look ups,
 
729
      Parsing 'WITH' 'ROLLUP' requires 2 look ups,
733
730
      which makes the grammar LALR(2).
734
731
      Replace by a single 'WITH_ROLLUP' or 'WITH_CUBE' token,
735
732
      to transform the grammar into a LALR(1) grammar,
736
733
      which sql_yacc.yy can process.
737
734
    */
738
735
    token= lex_one_token(arg, yythd);
739
 
    switch(token) {
740
 
    case CUBE_SYM:
741
 
      return WITH_CUBE_SYM;
742
 
    case ROLLUP_SYM:
 
736
    if (token == ROLLUP_SYM)
 
737
    {
743
738
      return WITH_ROLLUP_SYM;
744
 
    default:
 
739
    }
 
740
    else
 
741
    {
745
742
      /*
746
743
        Save the token following 'WITH'
747
744
      */
769
766
  Lex_input_stream *lip= thd->m_lip;
770
767
  LEX *lex= thd->lex;
771
768
  YYSTYPE *yylval=(YYSTYPE*) arg;
772
 
  CHARSET_INFO *cs= thd->charset();
773
 
  uchar *state_map= cs->state_map;
774
 
  uchar *ident_map= cs->ident_map;
 
769
  const CHARSET_INFO * const cs= thd->charset();
 
770
  unsigned char *state_map= cs->state_map;
 
771
  unsigned char *ident_map= cs->ident_map;
775
772
 
776
773
  lip->yylval=yylval;                   // The global state
777
774
 
830
827
        */
831
828
        lip->restart_token();
832
829
      }
833
 
      else
834
 
      {
835
 
        /*
836
 
          Check for a placeholder: it should not precede a possible identifier
837
 
          because of binlogging: when a placeholder is replaced with
838
 
          its value in a query for the binlog, the query must stay
839
 
          grammatically correct.
840
 
        */
841
 
        if (c == '?' && lip->stmt_prepare_mode && !ident_map[(uint8_t)(lip->yyPeek())])
842
 
        return(PARAM_MARKER);
843
 
      }
844
830
 
845
831
      return((int) c);
846
832
 
847
 
    case MY_LEX_IDENT_OR_NCHAR:
848
 
      if (lip->yyPeek() != '\'')
849
 
      {
850
 
        state= MY_LEX_IDENT;
851
 
        break;
852
 
      }
853
 
      /* Found N'string' */
854
 
      lip->yySkip();                         // Skip '
855
 
      if (!(yylval->lex_str.str = get_text(lip, 2, 1)))
856
 
      {
857
 
        state= MY_LEX_CHAR;             // Read char by char
858
 
        break;
859
 
      }
860
 
      yylval->lex_str.length= lip->yytoklen;
861
 
      lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1;
862
 
      return(NCHAR_STRING);
863
 
 
864
833
    case MY_LEX_IDENT_OR_HEX:
865
834
      if (lip->yyPeek() == '\'')
866
835
      {                                 // Found x'hex-number'
943
912
 
944
913
      if (yylval->lex_str.str[0] == '_')
945
914
      {
946
 
        CHARSET_INFO *cs= get_charset_by_csname(yylval->lex_str.str + 1,
947
 
                                                MY_CS_PRIMARY, MYF(0));
 
915
        const CHARSET_INFO * const cs= get_charset_by_csname(yylval->lex_str.str + 1,
 
916
                                                             MY_CS_PRIMARY, MYF(0));
948
917
        if (cs)
949
918
        {
950
919
          yylval->charset= cs;
1068
1037
 
1069
1038
    case MY_LEX_USER_VARIABLE_DELIMITER:        // Found quote char
1070
1039
    {
1071
 
      uint double_quotes= 0;
 
1040
      uint32_t double_quotes= 0;
1072
1041
      char quote_char= c;                       // Used char
1073
1042
      while ((c=lip->yyGet()))
1074
1043
      {
1278
1247
          /* Accept 'M' 'm' 'm' 'd' 'd' */
1279
1248
          lip->yySkipn(5);
1280
1249
 
1281
 
          if (version <= MYSQL_VERSION_ID)
 
1250
          if (version <= DRIZZLE_VERSION_ID)
1282
1251
          {
1283
1252
            /* Expand the content of the special comment as real code */
1284
1253
            lip->set_echo(true);
1358
1327
    case MY_LEX_SEMICOLON:                      // optional line terminator
1359
1328
      if (lip->yyPeek())
1360
1329
      {
1361
 
        if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) && 
1362
 
            !lip->stmt_prepare_mode)
 
1330
        if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS))
1363
1331
        {
1364
1332
          lip->found_semicolon= lip->get_ptr();
1365
1333
          thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
1508
1476
}
1509
1477
 
1510
1478
 
1511
 
void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str)
 
1479
void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str)
1512
1480
{
1513
1481
  /*
1514
1482
    TODO:
1600
1568
  select_n_having_items= 0;
1601
1569
  subquery_in_having= explicit_limit= 0;
1602
1570
  is_item_list_lookup= 0;
1603
 
  first_execution= 1;
1604
 
  first_cond_optimization= 1;
1605
1571
  parsing_place= NO_MATTER;
1606
1572
  exclude_from_table_unique_test= false;
1607
1573
  nest_level= 0;
1626
1592
  linkage= UNSPECIFIED_TYPE;
1627
1593
  order_list.elements= 0;
1628
1594
  order_list.first= 0;
1629
 
  order_list.next= (uchar**) &order_list.first;
 
1595
  order_list.next= (unsigned char**) &order_list.first;
1630
1596
  /* Set limit and offset to default values */
1631
1597
  select_limit= 0;      /* denotes the default limit = HA_POS_ERROR */
1632
1598
  offset_limit= 0;      /* denotes the default offset = 0 */
1846
1812
  }
1847
1813
}
1848
1814
 
1849
 
bool st_select_lex_node::set_braces(bool value __attribute__((__unused__)))
 
1815
bool st_select_lex_node::set_braces(bool value __attribute__((unused)))
1850
1816
{ return 1; }
1851
1817
bool st_select_lex_node::inc_in_sum_expr()           { return 1; }
1852
 
uint st_select_lex_node::get_in_sum_expr()           { return 0; }
1853
 
TABLE_LIST* st_select_lex_node::get_table_list()     { return 0; }
 
1818
uint32_t st_select_lex_node::get_in_sum_expr()           { return 0; }
 
1819
TableList* st_select_lex_node::get_table_list()     { return 0; }
1854
1820
List<Item>* st_select_lex_node::get_item_list()      { return 0; }
1855
 
TABLE_LIST *st_select_lex_node::add_table_to_list (THD *thd __attribute__((__unused__)),
1856
 
                                                   Table_ident *table __attribute__((__unused__)),
1857
 
                                                  LEX_STRING *alias __attribute__((__unused__)),
1858
 
                                                  ulong table_join_options __attribute__((__unused__)),
1859
 
                                                  thr_lock_type flags __attribute__((__unused__)),
1860
 
                                                  List<Index_hint> *hints __attribute__((__unused__)),
1861
 
                                                  LEX_STRING *option __attribute__((__unused__)))
 
1821
TableList *st_select_lex_node::add_table_to_list (THD *thd __attribute__((unused)),
 
1822
                                                   Table_ident *table __attribute__((unused)),
 
1823
                                                  LEX_STRING *alias __attribute__((unused)),
 
1824
                                                  uint32_t table_join_options __attribute__((unused)),
 
1825
                                                  thr_lock_type flags __attribute__((unused)),
 
1826
                                                  List<Index_hint> *hints __attribute__((unused)),
 
1827
                                                  LEX_STRING *option __attribute__((unused)))
1862
1828
{
1863
1829
  return 0;
1864
1830
}
1865
 
ulong st_select_lex_node::get_table_join_options()
 
1831
uint32_t st_select_lex_node::get_table_join_options()
1866
1832
{
1867
1833
  return 0;
1868
1834
}
1900
1866
}
1901
1867
 
1902
1868
 
1903
 
bool st_select_lex::add_item_to_list(THD *thd __attribute__((__unused__)),
 
1869
bool st_select_lex::add_item_to_list(THD *thd __attribute__((unused)),
1904
1870
                                     Item *item)
1905
1871
{
1906
1872
  return(item_list.push_back(item));
1939
1905
}
1940
1906
 
1941
1907
 
1942
 
uint st_select_lex::get_in_sum_expr()
 
1908
uint32_t st_select_lex::get_in_sum_expr()
1943
1909
{
1944
1910
  return in_sum_expr;
1945
1911
}
1946
1912
 
1947
1913
 
1948
 
TABLE_LIST* st_select_lex::get_table_list()
 
1914
TableList* st_select_lex::get_table_list()
1949
1915
{
1950
 
  return (TABLE_LIST*) table_list.first;
 
1916
  return (TableList*) table_list.first;
1951
1917
}
1952
1918
 
1953
1919
List<Item>* st_select_lex::get_item_list()
1955
1921
  return &item_list;
1956
1922
}
1957
1923
 
1958
 
ulong st_select_lex::get_table_join_options()
 
1924
uint32_t st_select_lex::get_table_join_options()
1959
1925
{
1960
1926
  return table_join_options;
1961
1927
}
1962
1928
 
1963
1929
 
1964
 
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
 
1930
bool st_select_lex::setup_ref_array(THD *thd, uint32_t order_group_num)
1965
1931
{
1966
1932
  if (ref_pointer_array)
1967
1933
    return 0;
1968
1934
 
1969
 
  /*
1970
 
    We have to create array in prepared statement memory if it is
1971
 
    prepared statement
1972
 
  */
1973
 
  Query_arena *arena= thd->stmt_arena;
1974
1935
  return (ref_pointer_array=
1975
 
          (Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items +
 
1936
          (Item **)thd->alloc(sizeof(Item*) * (n_child_sum_items +
1976
1937
                                                 item_list.elements +
1977
1938
                                                 select_n_having_items +
1978
1939
                                                 select_n_where_fields +
2006
1967
      str->append(STRING_WITH_LEN(" order by "));
2007
1968
      fake_select_lex->print_order(
2008
1969
        str,
2009
 
        (ORDER *) fake_select_lex->order_list.first,
 
1970
        (order_st *) fake_select_lex->order_list.first,
2010
1971
        query_type);
2011
1972
    }
2012
1973
    fake_select_lex->print_limit(thd, str, query_type);
2015
1976
 
2016
1977
 
2017
1978
void st_select_lex::print_order(String *str,
2018
 
                                ORDER *order,
 
1979
                                order_st *order,
2019
1980
                                enum_query_type query_type)
2020
1981
{
2021
1982
  for (; order; order= order->next)
2023
1984
    if (order->counter_used)
2024
1985
    {
2025
1986
      char buffer[20];
2026
 
      uint length= snprintf(buffer, 20, "%d", order->counter);
 
1987
      uint32_t length= snprintf(buffer, 20, "%d", order->counter);
2027
1988
      str->append(buffer, length);
2028
1989
    }
2029
1990
    else
2036
1997
}
2037
1998
 
2038
1999
 
2039
 
void st_select_lex::print_limit(THD *thd __attribute__((__unused__)),
 
2000
void st_select_lex::print_limit(THD *thd __attribute__((unused)),
2040
2001
                                String *str,
2041
2002
                                enum_query_type query_type)
2042
2003
{
2059
2020
                    ((Item_in_subselect*)item)->exec_method ==
2060
2021
                    Item_in_subselect::MATERIALIZATION) ?
2061
2022
                   true :
2062
 
                   (select_limit->val_int() == 1LL) &&
 
2023
                   (select_limit->val_int() == 1L) &&
2063
2024
                   offset_limit == 0));
2064
2025
      return;
2065
2026
    }
2088
2049
  to implement the clean up.
2089
2050
*/
2090
2051
 
2091
 
void st_lex::cleanup_lex_after_parse_error(THD *thd __attribute__((__unused__)))
 
2052
void st_lex::cleanup_lex_after_parse_error(THD *thd __attribute__((unused)))
2092
2053
{
2093
2054
}
2094
2055
 
2114
2075
{
2115
2076
  if (!init && query_tables)
2116
2077
  {
2117
 
    TABLE_LIST *table= query_tables;
 
2078
    TableList *table= query_tables;
2118
2079
    for (;;)
2119
2080
    {
2120
2081
      if (query_tables_last == &table->next_global ||
2352
2313
  }
2353
2314
}
2354
2315
 
2355
 
/*
2356
 
  Get effective type of CHECK OPTION for given view
2357
 
 
2358
 
  SYNOPSIS
2359
 
    get_effective_with_check()
2360
 
    view    given view
2361
 
 
2362
 
  NOTE
2363
 
    It have not sense to set CHECK OPTION for SELECT satement or subqueries,
2364
 
    so we do not.
2365
 
 
2366
 
  RETURN
2367
 
    VIEW_CHECK_NONE      no need CHECK OPTION
2368
 
    VIEW_CHECK_LOCAL     CHECK OPTION LOCAL
2369
 
    VIEW_CHECK_CASCADED  CHECK OPTION CASCADED
2370
 
*/
2371
 
 
2372
 
uint8 st_lex::get_effective_with_check(TABLE_LIST *view __attribute__((__unused__)))
2373
 
{
2374
 
  return 0;
2375
 
}
2376
 
 
2377
2316
 
2378
2317
/**
2379
2318
  This method should be called only during parsing.
2424
2363
    select_limit_val= HA_POS_ERROR;
2425
2364
#endif
2426
2365
  offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :
2427
 
                                                 0ULL);
 
2366
                                                 0UL);
2428
2367
  select_limit_cnt= select_limit_val + offset_limit_cnt;
2429
2368
  if (select_limit_cnt < select_limit_val)
2430
2369
    select_limit_cnt= HA_POS_ERROR;             // no limit
2449
2388
      In this case link_to_local is set.
2450
2389
 
2451
2390
*/
2452
 
TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
 
2391
TableList *st_lex::unlink_first_table(bool *link_to_local)
2453
2392
{
2454
 
  TABLE_LIST *first;
 
2393
  TableList *first;
2455
2394
  if ((first= query_tables))
2456
2395
  {
2457
2396
    /*
2470
2409
    {
2471
2410
      select_lex.context.table_list= 
2472
2411
        select_lex.context.first_name_resolution_table= first->next_local;
2473
 
      select_lex.table_list.first= (uchar*) (first->next_local);
 
2412
      select_lex.table_list.first= (unsigned char*) (first->next_local);
2474
2413
      select_lex.table_list.elements--; //safety
2475
2414
      first->next_local= 0;
2476
2415
      /*
2502
2441
 
2503
2442
void st_lex::first_lists_tables_same()
2504
2443
{
2505
 
  TABLE_LIST *first_table= (TABLE_LIST*) select_lex.table_list.first;
 
2444
  TableList *first_table= (TableList*) select_lex.table_list.first;
2506
2445
  if (query_tables != first_table && first_table != 0)
2507
2446
  {
2508
 
    TABLE_LIST *next;
 
2447
    TableList *next;
2509
2448
    if (query_tables_last == &first_table->next_global)
2510
2449
      query_tables_last= first_table->prev_global;
2511
2450
 
2536
2475
    global list
2537
2476
*/
2538
2477
 
2539
 
void st_lex::link_first_table_back(TABLE_LIST *first,
 
2478
void st_lex::link_first_table_back(TableList *first,
2540
2479
                                   bool link_to_local)
2541
2480
{
2542
2481
  if (first)
2549
2488
 
2550
2489
    if (link_to_local)
2551
2490
    {
2552
 
      first->next_local= (TABLE_LIST*) select_lex.table_list.first;
 
2491
      first->next_local= (TableList*) select_lex.table_list.first;
2553
2492
      select_lex.context.table_list= first;
2554
 
      select_lex.table_list.first= (uchar*) first;
 
2493
      select_lex.table_list.first= (unsigned char*) first;
2555
2494
      select_lex.table_list.elements++; //safety
2556
2495
    }
2557
2496
  }
2606
2545
      backup  Pointer to Query_tables_list instance to be used for backup
2607
2546
*/
2608
2547
 
2609
 
void st_lex::reset_n_backup_query_tables_list(Query_tables_list *backup __attribute__((__unused__)))
 
2548
void st_lex::reset_n_backup_query_tables_list(Query_tables_list *backup __attribute__((unused)))
2610
2549
{
2611
2550
}
2612
2551
 
2619
2558
      backup  Pointer to Query_tables_list instance used for backup
2620
2559
*/
2621
2560
 
2622
 
void st_lex::restore_backup_query_tables_list(Query_tables_list *backup __attribute__((__unused__)))
 
2561
void st_lex::restore_backup_query_tables_list(Query_tables_list *backup __attribute__((unused)))
2623
2562
{
2624
2563
}
2625
2564
 
2659
2598
 
2660
2599
*/
2661
2600
 
2662
 
static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
 
2601
static void fix_prepare_info_in_table_list(THD *thd, TableList *tbl)
2663
2602
{
2664
2603
  for (; tbl; tbl= tbl->next_local)
2665
2604
  {
2736
2675
  RETURN VALUE
2737
2676
    0 on success, non-zero otherwise
2738
2677
*/
2739
 
bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
 
2678
bool st_select_lex::add_index_hint (THD *thd, char *str, uint32_t length)
2740
2679
{
2741
2680
  return index_hints->push_front (new (thd->mem_root) 
2742
2681
                                 Index_hint(current_index_hint_type,