~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Brian Aker
  • Date: 2010-12-31 06:44:35 UTC
  • mfrom: (2040.4.3 timestamp)
  • Revision ID: brian@tangent.org-20101231064435-g0h53tjfisjty2fy
Partial update to the time code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
18
18
 
19
19
#include "config.h"
20
 
 
21
20
#define DRIZZLE_LEX 1
22
 
 
23
 
#include "drizzled/sql_reserved_words.h"
24
 
 
25
21
#include "drizzled/configmake.h"
26
22
#include "drizzled/item/num.h"
27
23
#include "drizzled/error.h"
49
45
static bool add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
50
46
{
51
47
  Order *order;
52
 
 
53
 
  if (!(order = (Order *) session->getMemRoot()->allocate(sizeof(Order))))
54
 
    return true;
55
 
 
 
48
  if (!(order = (Order *) session->alloc(sizeof(Order))))
 
49
    return(1);
56
50
  order->item_ptr= item;
57
51
  order->item= &order->item_ptr;
58
52
  order->asc = asc;
59
53
  order->free_me=0;
60
54
  order->used=0;
61
55
  order->counter_used= 0;
62
 
  list.link_in_list((unsigned char*) order, (unsigned char**) &order->next);
63
 
 
64
 
  return false;
 
56
  list.link_in_list((unsigned char*) order,(unsigned char**) &order->next);
 
57
  return(0);
65
58
}
66
59
 
67
60
/**
71
64
 
72
65
Lex_input_stream::Lex_input_stream(Session *session,
73
66
                                   const char* buffer,
74
 
                                   unsigned int length) :
75
 
  m_session(session),
 
67
                                   unsigned int length)
 
68
: m_session(session),
76
69
  yylineno(1),
77
70
  yytoklen(0),
78
71
  yylval(NULL),
95
88
  ignore_space(1),
96
89
  in_comment(NO_COMMENT)
97
90
{
98
 
  m_cpp_buf= (char*) session->getMemRoot()->allocate(length + 1);
 
91
  m_cpp_buf= (char*) session->alloc(length + 1);
99
92
  m_cpp_ptr= m_cpp_buf;
100
93
}
101
94
 
122
115
    (m_buf_length / default_charset_info->mbminlen) *
123
116
    my_charset_utf8_bin.mbmaxlen;
124
117
 
125
 
  m_body_utf8= (char *) session->getMemRoot()->allocate(body_utf8_length + 1);
 
118
  m_body_utf8= (char *) session->alloc(body_utf8_length + 1);
126
119
  m_body_utf8_ptr= m_body_utf8;
127
120
  *m_body_utf8_ptr= 0;
128
121
 
249
242
  lex->derived_tables= 0;
250
243
  lex->lock_option= TL_READ;
251
244
  lex->leaf_tables_insert= 0;
252
 
  lex->var_list.clear();
253
245
  lex->select_lex.select_number= 1;
254
246
  lex->length=0;
255
247
  lex->select_lex.in_sum_expr=0;
269
261
  lex->nest_level=0 ;
270
262
  lex->allow_sum_func= 0;
271
263
  lex->in_sum_func= NULL;
272
 
  lex->type= 0;
273
264
 
274
265
  lex->is_lex_started= true;
275
266
  lex->statement= NULL;
276
267
  
277
268
  lex->is_cross= false;
 
269
 
278
270
  lex->reset();
279
271
}
280
272
 
289
281
  }
290
282
 
291
283
  delete result;
292
 
  delete _create_table;
293
 
  _create_table= NULL;
294
 
  _create_field= NULL;
295
284
 
296
285
  result= 0;
297
286
  setCacheable(true);
358
347
  char *to;
359
348
  lip->yyUnget();                       // ptr points now after last token char
360
349
  tmp.length= lip->yytoklen=length;
361
 
  tmp.str=(char*) lip->m_session->getMemRoot()->allocate(tmp.length+1);
 
350
  tmp.str=(char*) lip->m_session->alloc(tmp.length+1);
362
351
  from= lip->get_tok_start() + skip;
363
352
  to= tmp.str;
364
353
  end= to+length;
434
423
      end-= post_skip;
435
424
      assert(end >= str);
436
425
 
437
 
      if (!(start= (char*) lip->m_session->getMemRoot()->allocate((uint32_t) (end-str)+1)))
 
426
      if (!(start= (char*) lip->m_session->alloc((uint32_t) (end-str)+1)))
438
427
        return (char*) "";              // memory::SqlAlloc has set error flag
439
428
 
440
429
      lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip;
1397
1386
  select_limit= 0;      /* denotes the default limit = HA_POS_ERROR */
1398
1387
  offset_limit= 0;      /* denotes the default offset = 0 */
1399
1388
  with_sum_func= 0;
1400
 
  is_cross= false;
1401
1389
  is_correlated= 0;
1402
1390
  cur_pos_in_select_list= UNDEF_POS;
1403
1391
  non_agg_fields.empty();
1713
1701
    return false;
1714
1702
 
1715
1703
  return (ref_pointer_array=
1716
 
          (Item **)session->getMemRoot()->allocate(sizeof(Item*) * (n_child_sum_items +
 
1704
          (Item **)session->alloc(sizeof(Item*) * (n_child_sum_items +
1717
1705
                                                 item_list.elements +
1718
1706
                                                 select_n_having_items +
1719
1707
                                                 select_n_where_fields +
1813
1801
  }
1814
1802
}
1815
1803
 
1816
 
LEX::~LEX()
 
1804
/**
 
1805
  @brief Restore the LEX and Session in case of a parse error.
 
1806
 
 
1807
  This is a clean up call that is invoked by the Bison generated
 
1808
  parser before returning an error from DRIZZLEparse. If your
 
1809
  semantic actions manipulate with the global thread state (which
 
1810
  is a very bad practice and should not normally be employed) and
 
1811
  need a clean-up in case of error, and you can not use %destructor
 
1812
  rule in the grammar file itself, this function should be used
 
1813
  to implement the clean up.
 
1814
*/
 
1815
void LEX::cleanup_lex_after_parse_error(Session *)
1817
1816
{
1818
 
  delete _create_table;
1819
1817
}
1820
1818
 
1821
1819
/*
1865
1863
    statement parsing. On should use lex_start() function to prepare LEX
1866
1864
    for this.
1867
1865
*/
1868
 
LEX::LEX() :
 
1866
LEX::LEX()
 
1867
  :
1869
1868
    result(0), 
1870
1869
    yacc_yyss(0), 
1871
1870
    yacc_yyvs(0),
1872
 
    session(NULL),
1873
1871
    charset(NULL),
1874
 
    var_list(),
1875
1872
    sql_command(SQLCOM_END), 
1876
 
    statement(NULL),
1877
1873
    option_type(OPT_DEFAULT), 
1878
1874
    is_lex_started(0),
1879
1875
    cacheable(true),
1880
 
    sum_expr_used(false),
1881
 
    _create_table(NULL),
1882
 
    _create_field(NULL),
1883
 
    _exists(false)
 
1876
    sum_expr_used(false)
1884
1877
{
1885
1878
  reset_query_tables_list(true);
 
1879
  statement= NULL;
1886
1880
}
1887
1881
 
1888
1882
/**
2158
2152
                                            str, length));
2159
2153
}
2160
2154
 
2161
 
bool check_for_sql_keyword(drizzled::lex_string_t const& string)
2162
 
{
2163
 
  if (sql_reserved_words::in_word_set(string.str, string.length))
2164
 
      return true;
2165
 
 
2166
 
  return false;
2167
 
}
2168
 
 
2169
 
bool check_for_sql_keyword(drizzled::st_lex_symbol const& string)
2170
 
{
2171
 
  if (sql_reserved_words::in_word_set(string.str, string.length))
2172
 
      return true;
2173
 
 
2174
 
  return false;
2175
 
}
2176
 
 
2177
 
 
2178
2155
} /* namespace drizzled */