~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

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
 
#include "config.h"
20
19
#define DRIZZLE_LEX 1
21
 
#include "drizzled/configmake.h"
 
20
#include "drizzled/server_includes.h"
22
21
#include "drizzled/item/num.h"
23
22
#include "drizzled/error.h"
24
23
#include "drizzled/session.h"
30
29
 
31
30
using namespace std;
32
31
 
33
 
/* Stay outside of the namespace because otherwise bison goes nuts */
 
32
static int lex_one_token(void *arg, void *yysession);
34
33
int DRIZZLElex(void *arg, void *yysession);
35
34
 
36
 
namespace drizzled
37
 
{
38
 
 
39
 
static int lex_one_token(void *arg, void *yysession);
40
 
 
41
35
/**
42
36
  save order by and tables in own lists.
43
37
*/
56
50
  return(0);
57
51
}
58
52
 
 
53
 
 
54
 
 
55
/*
 
56
  We are using pointer to this variable for distinguishing between assignment
 
57
  to NEW row field (when parsing trigger definition) and structured variable.
 
58
*/
 
59
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
 
60
 
59
61
/**
60
62
  LEX_STRING constant for null-string to be used in parser and other places.
61
63
*/
84
86
  m_body_utf8(NULL),
85
87
  m_cpp_utf8_processed_ptr(NULL),
86
88
  next_state(MY_LEX_START),
 
89
  found_semicolon(NULL),
87
90
  ignore_space(1),
88
91
  in_comment(NO_COMMENT)
89
92
{
219
222
  lex->select_lex.init_query();
220
223
  lex->value_list.empty();
221
224
  lex->update_list.empty();
 
225
  lex->param_list.empty();
222
226
  lex->auxiliary_table_list.empty();
223
227
  lex->unit.next= lex->unit.master=
224
228
    lex->unit.link_next= lex->unit.return_to= 0;
257
261
  lex->in_sum_func= NULL;
258
262
 
259
263
  lex->is_lex_started= true;
 
264
  lex->create_table_proto= NULL;
260
265
  lex->statement= NULL;
261
266
}
262
267
 
272
277
 
273
278
  delete lex->result;
274
279
 
 
280
  if(lex->create_table_proto)
 
281
    delete lex->create_table_proto;
275
282
  lex->result= 0;
276
283
 
277
284
  if (lex->statement) 
413
420
      assert(end >= str);
414
421
 
415
422
      if (!(start= (char*) lip->m_session->alloc((uint32_t) (end-str)+1)))
416
 
        return (char*) "";              // memory::SqlAlloc has set error flag
 
423
        return (char*) "";              // Sql_alloc has set error flag
417
424
 
418
425
      lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip;
419
426
      lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip;
576
583
  return ((unsigned char) str[-1] <= (unsigned char) cmp[-1]) ? smaller : bigger;
577
584
}
578
585
 
579
 
} /* namespace drizzled */
580
586
/*
581
587
  DRIZZLElex remember the following states from the following DRIZZLElex()
582
588
 
586
592
*/
587
593
int DRIZZLElex(void *arg, void *yysession)
588
594
{
589
 
  drizzled::Session *session= (drizzled::Session *)yysession;
590
 
  drizzled::Lex_input_stream *lip= session->m_lip;
 
595
  Session *session= (Session *)yysession;
 
596
  Lex_input_stream *lip= session->m_lip;
591
597
  YYSTYPE *yylval=(YYSTYPE*) arg;
592
598
  int token;
593
599
 
604
610
    return token;
605
611
  }
606
612
 
607
 
  token= drizzled::lex_one_token(arg, yysession);
 
613
  token= lex_one_token(arg, yysession);
608
614
 
609
615
  switch(token) {
610
616
  case WITH:
615
621
      to transform the grammar into a LALR(1) grammar,
616
622
      which sql_yacc.yy can process.
617
623
    */
618
 
    token= drizzled::lex_one_token(arg, yysession);
 
624
    token= lex_one_token(arg, yysession);
619
625
    if (token == ROLLUP_SYM)
620
626
    {
621
627
      return WITH_ROLLUP_SYM;
637
643
  return token;
638
644
}
639
645
 
640
 
namespace drizzled
641
 
{
642
 
 
643
646
int lex_one_token(void *arg, void *yysession)
644
647
{
645
648
  register unsigned char c= 0; /* Just set to shutup GCC */
1262
1265
  }
1263
1266
}
1264
1267
 
 
1268
/**
 
1269
  Construct a copy of this object to be used for mysql_alter_table
 
1270
  and mysql_create_table.
 
1271
 
 
1272
  Historically, these two functions modify their Alter_info
 
1273
  arguments. This behaviour breaks re-execution of prepared
 
1274
  statements and stored procedures and is compensated by always
 
1275
  supplying a copy of Alter_info to these functions.
 
1276
 
 
1277
  @return You need to use check the error in Session for out
 
1278
  of memory condition after calling this function.
 
1279
*/
 
1280
Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
 
1281
  :drop_list(rhs.drop_list, mem_root),
 
1282
  alter_list(rhs.alter_list, mem_root),
 
1283
  key_list(rhs.key_list, mem_root),
 
1284
  create_list(rhs.create_list, mem_root),
 
1285
  flags(rhs.flags),
 
1286
  keys_onoff(rhs.keys_onoff),
 
1287
  tablespace_op(rhs.tablespace_op),
 
1288
  no_parts(rhs.no_parts),
 
1289
  build_method(rhs.build_method),
 
1290
  datetime_field(rhs.datetime_field),
 
1291
  error_if_not_empty(rhs.error_if_not_empty)
 
1292
{
 
1293
  /*
 
1294
    Make deep copies of used objects.
 
1295
    This is not a fully deep copy - clone() implementations
 
1296
    of Alter_drop, Alter_column, Key, foreign_key, Key_part_spec
 
1297
    do not copy string constants. At the same length the only
 
1298
    reason we make a copy currently is that ALTER/CREATE TABLE
 
1299
    code changes input Alter_info definitions, but string
 
1300
    constants never change.
 
1301
  */
 
1302
  list_copy_and_replace_each_value(drop_list, mem_root);
 
1303
  list_copy_and_replace_each_value(alter_list, mem_root);
 
1304
  list_copy_and_replace_each_value(key_list, mem_root);
 
1305
  list_copy_and_replace_each_value(create_list, mem_root);
 
1306
}
 
1307
 
1265
1308
void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str)
1266
1309
{
1267
1310
  /*
1360
1403
{
1361
1404
  sj_nests.empty();
1362
1405
  group_list.empty();
1363
 
  db= 0;
 
1406
  type= db= 0;
1364
1407
  having= 0;
1365
1408
  table_join_options= 0;
1366
1409
  in_sum_expr= with_wild= 0;
1861
1904
   sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0)
1862
1905
{
1863
1906
  reset_query_tables_list(true);
 
1907
  create_table_proto= NULL;
1864
1908
  statement= NULL;
1865
1909
}
1866
1910
 
1876
1920
*/
1877
1921
bool LEX::only_view_structure()
1878
1922
{
1879
 
  if (sql_command == SQLCOM_SHOW_CREATE)
 
1923
  switch (sql_command) {
 
1924
  case SQLCOM_SHOW_CREATE:
 
1925
  case SQLCOM_SHOW_TABLES:
 
1926
  case SQLCOM_SHOW_FIELDS:
1880
1927
    return true;
1881
 
 
1882
 
  return false;
 
1928
  default:
 
1929
    return false;
 
1930
  }
1883
1931
}
1884
1932
 
1885
1933
/*
1894
1942
*/
1895
1943
bool LEX::need_correct_ident()
1896
1944
{
1897
 
  if (sql_command== SQLCOM_SHOW_CREATE)
 
1945
  switch(sql_command)
 
1946
  {
 
1947
  case SQLCOM_SHOW_CREATE:
 
1948
  case SQLCOM_SHOW_TABLES:
1898
1949
    return true;
1899
 
 
1900
 
  return false;
 
1950
  default:
 
1951
    return false;
 
1952
  }
1901
1953
}
1902
1954
 
1903
1955
/**
2172
2224
                                            current_index_hint_clause,
2173
2225
                                            str, length));
2174
2226
}
2175
 
 
2176
 
} /* namespace drizzled */