~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Mark Atwood
  • Date: 2011-08-21 06:56:57 UTC
  • mfrom: (2385.3.34 rf)
  • Revision ID: me@mark.atwood.name-20110821065657-vk2at03z9u17mf1d
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    unsigned long val= *(F);                          \
58
58
    if (drizzled::my_yyoverflow((B), (D), &val)) \
59
59
    {                                         \
60
 
      yyerror(NULL, (char*) (A));                   \
 
60
      yyerror(NULL, (A));                   \
61
61
      return 2;                               \
62
62
    }                                         \
63
63
    else                                      \
114
114
  to abort from the parser.
115
115
*/
116
116
 
117
 
static void base_sql_error(drizzled::Session *session, const char *s)
 
117
static void base_sql_error(drizzled::Session *session, const char* s)
118
118
{
119
119
  parser::errorOn(session, s);
120
120
}
133
133
  drizzled::lex_string_t *lex_str_ptr;
134
134
  drizzled::LEX_SYMBOL symbol;
135
135
  drizzled::Table_ident *table;
136
 
  char *simple_string;
 
136
  const char* simple_string;
137
137
  drizzled::Item *item;
138
138
  drizzled::Item_num *item_num;
139
139
  drizzled::List<drizzled::Item> *item_list;
1227
1227
          }
1228
1228
          field_def opt_attribute_comment
1229
1229
          {
1230
 
            statement::CreateTable *statement= (statement::CreateTable *)Lex.statement;
 
1230
            statement::CreateTable *statement= (statement::CreateTable*)Lex.statement;
1231
1231
 
1232
1232
            if (Lex.field())
1233
1233
            {
1277
1277
        | TEXT_SYM opt_attribute_string
1278
1278
          {
1279
1279
            $$=DRIZZLE_TYPE_BLOB;
1280
 
            Lex.length=(char*) 0; /* use default length */
 
1280
            Lex.length= NULL; /* use default length */
1281
1281
 
1282
1282
            if (Lex.field())
1283
1283
              Lex.field()->set_type(message::Table::Field::BLOB);
1387
1387
 
1388
1388
float_options:
1389
1389
          /* empty */
1390
 
          { Lex.dec=Lex.length= (char*)0; }
 
1390
          { Lex.dec=Lex.length= NULL; }
1391
1391
        | '(' NUM ')'
1392
 
          { Lex.length=$2.str; Lex.dec= (char*)0; }
 
1392
          { Lex.length=$2.str; Lex.dec= NULL; }
1393
1393
        | precision
1394
1394
          {}
1395
1395
        ;
1403
1403
        ;
1404
1404
 
1405
1405
opt_len:
1406
 
          /* empty */ { Lex.length=(char*) 0; /* use default length */ }
 
1406
          /* empty */ { Lex.length= NULL; /* use default length */ }
1407
1407
        | '(' NUM ')' { Lex.length= $2.str; }
1408
1408
        ;
1409
1409
 
1425
1425
 
1426
1426
opt_precision:
1427
1427
          /* empty */
1428
 
          { Lex.dec=Lex.length= (char*)0; }
 
1428
          { Lex.dec=Lex.length= NULL; }
1429
1429
        | '(' NUM ')'
1430
 
          { Lex.length=Lex.dec= (char*)0; }
 
1430
          { Lex.length=Lex.dec= NULL; }
1431
1431
        | precision
1432
1432
          {}
1433
1433
        ;
1469
1469
          { }
1470
1470
        | opt_attribute DEFAULT signed_literal
1471
1471
          {
1472
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1472
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1473
1473
 
1474
1474
            statement->default_value= $3;
1475
1475
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1484
1484
          { }
1485
1485
        | opt_attribute_boolean DEFAULT boolean_literal
1486
1486
          {
1487
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1487
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1488
1488
 
1489
1489
            statement->default_value= $3;
1490
1490
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1508
1508
          { }
1509
1509
        | DEFAULT signed_literal
1510
1510
          {
1511
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1511
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1512
1512
 
1513
1513
            statement->default_value=$2;
1514
1514
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1553
1553
          }
1554
1554
        | DEFAULT integer_literal
1555
1555
          {
1556
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1556
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1557
1557
 
1558
1558
            statement->default_value=$2;
1559
1559
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1577
1577
          { }
1578
1578
        | DEFAULT NOW_SYM optional_braces
1579
1579
          {
1580
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1580
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1581
1581
 
1582
1582
            statement->default_value= new Item_func_now_local();
1583
1583
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1584
1584
          }
1585
1585
        | DEFAULT date_literal
1586
1586
          {
1587
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1587
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1588
1588
 
1589
1589
            statement->default_value=$2;
1590
1590
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1591
1591
          }
1592
1592
        | ON UPDATE_SYM NOW_SYM optional_braces
1593
1593
          {
1594
 
            ((statement::AlterTable *)Lex.statement)->on_update_value= new Item_func_now_local();
 
1594
            ((statement::AlterTable*)Lex.statement)->on_update_value= new Item_func_now_local();
1595
1595
          }
1596
1596
        | opt_attribute_index
1597
1597
          { }
1601
1601
          /* empty */ { }
1602
1602
        | COMMENT_SYM TEXT_STRING_sys
1603
1603
          {
1604
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1604
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1605
1605
            statement->comment= $2;
1606
1606
 
1607
1607
            if (Lex.field())
1660
1660
 
1661
1661
opt_match_clause:
1662
1662
          /* empty */
1663
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
 
1663
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1664
1664
        | MATCH FULL
1665
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
 
1665
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1666
1666
        | MATCH PARTIAL
1667
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
 
1667
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1668
1668
        | MATCH SIMPLE_SYM
1669
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
 
1669
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1670
1670
        ;
1671
1671
 
1672
1672
opt_on_update_delete:
1673
1673
          /* empty */
1674
1674
          {
1675
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1676
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1675
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1676
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1677
1677
          }
1678
1678
        | ON UPDATE_SYM delete_option
1679
1679
          {
1680
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= $3;
1681
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1680
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= $3;
 
1681
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1682
1682
          }
1683
1683
        | ON DELETE_SYM delete_option
1684
1684
          {
1685
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1686
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= $3;
 
1685
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1686
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= $3;
1687
1687
          }
1688
1688
        | ON UPDATE_SYM delete_option
1689
1689
          ON DELETE_SYM delete_option
1830
1830
 
1831
1831
            Lex.col_list.clear();
1832
1832
            Lex.select_lex.init_order();
1833
 
            Lex.select_lex.db= const_cast<char *>(((TableList*) Lex.select_lex.table_list.first)->getSchemaName());
 
1833
            Lex.select_lex.db= const_cast<char*>(((TableList*) Lex.select_lex.table_list.first)->getSchemaName());
1834
1834
          }
1835
1835
          alter_commands
1836
1836
          {}
2356
2356
remember_name:
2357
2357
          {
2358
2358
            Lex_input_stream *lip= YYSession->m_lip;
2359
 
            $$= (char*) lip->get_cpp_tok_start();
 
2359
            $$= lip->get_cpp_tok_start();
2360
2360
          }
2361
2361
        ;
2362
2362
 
2363
2363
remember_end:
2364
2364
          {
2365
2365
            Lex_input_stream *lip= YYSession->m_lip;
2366
 
            $$= (char*) lip->get_cpp_tok_end();
 
2366
            $$= lip->get_cpp_tok_end();
2367
2367
          }
2368
2368
        ;
2369
2369
 
3296
3296
        | BOOLEAN_SYM
3297
3297
          { $$=ITEM_CAST_BOOLEAN; Lex.charset= &my_charset_bin; Lex.dec= 0; }
3298
3298
        | SIGNED_SYM
3299
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3299
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3300
3300
        | SIGNED_SYM INT_SYM
3301
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3301
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3302
3302
        | INT_SYM
3303
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3303
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3304
3304
        | UNSIGNED_SYM
3305
 
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3305
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3306
3306
        | UNSIGNED_SYM INT_SYM
3307
 
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3307
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3308
3308
        | CHAR_SYM opt_len
3309
3309
          { $$=ITEM_CAST_CHAR; Lex.dec= 0; }
3310
3310
        | DATE_SYM
3311
 
          { $$=ITEM_CAST_DATE; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3311
          { $$=ITEM_CAST_DATE; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3312
3312
        | TIME_SYM
3313
 
          { $$=ITEM_CAST_TIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3313
          { $$=ITEM_CAST_TIME; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3314
3314
        | DATETIME_SYM
3315
 
          { $$=ITEM_CAST_DATETIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3315
          { $$=ITEM_CAST_DATETIME; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3316
3316
        | DECIMAL_SYM float_options
3317
3317
          { $$=ITEM_CAST_DECIMAL; Lex.charset= NULL; }
3318
3318
        ;
3805
3805
        ;
3806
3806
 
3807
3807
opt_key_usage_list:
3808
 
          /* empty */ { Lex.current_select->add_index_hint(YYSession, NULL, 0); }
 
3808
          /* empty */ { Lex.current_select->add_index_hint(YYSession, NULL); }
3809
3809
        | key_usage_list {}
3810
3810
        ;
3811
3811
 
3812
3812
key_usage_element:
3813
3813
          ident
3814
 
          { Lex.current_select->add_index_hint(YYSession, $1.str, $1.length); }
 
3814
          { Lex.current_select->add_index_hint(YYSession, $1.str); }
3815
3815
        | PRIMARY_SYM
3816
 
          { Lex.current_select->add_index_hint(YYSession, (char *)"PRIMARY", 7); }
 
3816
          { Lex.current_select->add_index_hint(YYSession, "PRIMARY"); }
3817
3817
        ;
3818
3818
 
3819
3819
key_usage_list:
3825
3825
          ident
3826
3826
          {
3827
3827
            $$= new List<String>;
3828
 
            $$->push_back(new (YYSession->mem_root)
3829
 
                              String((const char *) $1.str, $1.length,
3830
 
                                      system_charset_info));
 
3828
            $$->push_back(new (YYSession->mem_root) String($1.str, $1.length, system_charset_info));
3831
3829
          }
3832
3830
        | using_list ',' ident
3833
3831
          {
3834
 
            $1->push_back(new (YYSession->mem_root)
3835
 
                              String((const char *) $3.str, $3.length,
3836
 
                                      system_charset_info));
 
3832
            $1->push_back(new (YYSession->mem_root) String($3.str, $3.length, system_charset_info));
3837
3833
            $$= $1;
3838
3834
          }
3839
3835
        ;
4103
4099
        ;
4104
4100
 
4105
4101
ulong_num:
4106
 
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4107
 
        | HEX_NUM       { $$= (unsigned long) strtol($1.str, (char**) 0, 16); }
4108
 
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4109
 
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4110
 
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4111
 
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
 
4102
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
 
4103
        | HEX_NUM       { $$= (unsigned long) strtol($1.str, NULL, 16); }
 
4104
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
 
4105
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
 
4106
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
 
4107
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.str, NULL, &error); }
4112
4108
        ;
4113
4109
 
4114
4110
ulonglong_num:
4115
 
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4116
 
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4117
 
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4118
 
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4119
 
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
 
4111
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
 
4112
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
 
4113
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
 
4114
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
 
4115
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.str, NULL, &error); }
4120
4116
        ;
4121
4117
 
4122
4118
select_var_list_init:
4670
4666
        | text_string { Lex.wild= $1; }
4671
4667
        | ident
4672
4668
          {
4673
 
            Lex.wild= new (YYSession->mem_root) String((const char*) $1.str,
4674
 
                                                    $1.length,
4675
 
                                                    system_charset_info);
 
4669
            Lex.wild= new (YYSession->mem_root) String($1.str, $1.length, system_charset_info);
4676
4670
          }
4677
4671
        ;
4678
4672