~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Olaf van der Spek
  • Date: 2011-02-28 14:09:50 UTC
  • mfrom: (2207 bootstrap)
  • mto: (2209.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2210.
  • Revision ID: olafvdspek@gmail.com-20110228140950-2nu0hyzhuww3wssx
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include <drizzled/alter_column.h>
42
42
#include <drizzled/alter_drop.h>
43
43
#include <drizzled/alter_info.h>
 
44
#include <drizzled/item/subselect.h>
44
45
 
45
46
int yylex(union ParserType *yylval, drizzled::Session *session);
46
47
 
176
177
  Currently there are 70 shift/reduce conflicts.
177
178
  We should not introduce new conflicts any more.
178
179
*/
179
 
%expect 75
 
180
%expect 79
180
181
 
181
182
/*
182
183
   Comments for TOKENS.
572
573
%nonassoc IN_SYM
573
574
%nonassoc IS NULL_SYM TRUE_SYM FALSE_SYM
574
575
 
 
576
%nonassoc CONCAT
575
577
%nonassoc '|'
576
578
%nonassoc '&'
577
579
%nonassoc SHIFT_LEFT SHIFT_RIGHT
619
621
        text_string opt_gconcat_separator
620
622
 
621
623
%type <field_val>
622
 
      field_definition
 
624
      field_def
623
625
      int_type
624
626
      real_type
625
627
 
635
637
 
636
638
%type <num>
637
639
        order_dir
638
 
        field_def
639
640
        opt_table_options
640
641
        all_or_any opt_distinct
641
642
        union_option
662
663
        predicate bit_expr
663
664
        table_wild simple_expr udf_expr
664
665
        expr_or_default set_expr_or_default
665
 
        signed_literal now_or_signed_literal opt_escape
 
666
        opt_escape
 
667
        signed_literal
 
668
        integer_literal
 
669
        date_literal
 
670
        boolean_literal
666
671
        simple_ident_q
667
672
        field_or_var limit_option
668
673
        function_call_keyword
742
747
        opt_delete_option varchar
743
748
        opt_outer table_list table_name
744
749
        opt_option opt_place
745
 
        opt_attribute opt_attribute_list attribute
 
750
        opt_attribute
 
751
        opt_attribute_boolean
 
752
        opt_attribute_timestamp
 
753
        opt_attribute_number
 
754
        opt_attribute_string
746
755
        flush_options flush_option
747
756
        equal optional_braces
748
757
        normal_join
1006
1015
 
1007
1016
opt_if_not_exists:
1008
1017
          /* empty */ { $$= false; }
1009
 
        | IF not EXISTS { $$= true; YYSession->getLex()->setExists(); }
 
1018
        | IF NOT_SYM EXISTS { $$= true; YYSession->getLex()->setExists(); }
1010
1019
        ;
1011
1020
 
1012
1021
opt_create_table_options:
1171
1180
          {
1172
1181
            parser::buildCreateFieldIdent(Lex);
1173
1182
          }
1174
 
          field_def
 
1183
          field_def opt_attribute_comment
1175
1184
          {
1176
1185
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1177
1186
 
1193
1202
        ;
1194
1203
 
1195
1204
field_def:
1196
 
          field_definition opt_attribute {}
1197
 
        ;
1198
 
 
1199
 
field_definition:
1200
 
          int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1201
 
          { 
1202
 
            $$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1203
 
          }
1204
 
        | real_type opt_precision
1205
 
          {
1206
 
            assert ($1 == DRIZZLE_TYPE_DOUBLE);
1207
 
            $$= parser::buildDoubleColumn(Lex);
1208
 
          }
1209
 
        | char '(' NUM ')'
1210
 
          {
1211
 
            $$= parser::buildVarcharColumn(Lex, $3.str);
1212
 
          }
1213
 
        | char
1214
 
          {
1215
 
            $$= parser::buildVarcharColumn(Lex, "1");
1216
 
          }
1217
 
        | varchar '(' NUM ')'
1218
 
          {
1219
 
            $$= parser::buildVarcharColumn(Lex, $3.str);
1220
 
          }
1221
 
        | VARBINARY '(' NUM ')'
1222
 
          {
1223
 
            $$= parser::buildVarbinaryColumn(Lex, $3.str);
1224
 
          }
1225
 
        | DATE_SYM
1226
 
          {
1227
 
            $$=DRIZZLE_TYPE_DATE;
1228
 
 
1229
 
            if (Lex->field())
1230
 
              Lex->field()->set_type(message::Table::Field::DATE);
1231
 
          }
1232
 
        | TIME_SYM
1233
 
          {
1234
 
            $$=DRIZZLE_TYPE_TIME;
1235
 
 
1236
 
            if (Lex->field())
1237
 
              Lex->field()->set_type(message::Table::Field::TIME);
1238
 
          }
1239
 
        | TIMESTAMP_SYM
 
1205
          TIMESTAMP_SYM opt_attribute_timestamp
1240
1206
          {
1241
1207
            $$=parser::buildTimestampColumn(Lex, NULL);
1242
1208
          }
1243
 
        | TIMESTAMP_SYM '(' NUM ')'
 
1209
        | TIMESTAMP_SYM '(' NUM ')' opt_attribute_timestamp
1244
1210
          {
1245
1211
            $$=parser::buildTimestampColumn(Lex, $3.str);
1246
 
          }
1247
 
        | DATETIME_SYM
 
1212
          } 
 
1213
        | DATETIME_SYM opt_attribute_timestamp
1248
1214
          {
1249
1215
            $$=DRIZZLE_TYPE_DATETIME;
1250
1216
 
1251
1217
            if (Lex->field())
1252
1218
              Lex->field()->set_type(message::Table::Field::DATETIME);
1253
 
          }
1254
 
        | BLOB_SYM
1255
 
          {
1256
 
            $$= parser::buildBlobColumn(Lex);
1257
 
          }
1258
 
        | TEXT_SYM
 
1219
          } 
 
1220
        | int_type opt_attribute_number
 
1221
          { 
 
1222
            $$= $1;
 
1223
          }
 
1224
        | CHAR_SYM opt_attribute_string
 
1225
          {
 
1226
            $$= parser::buildVarcharColumn(Lex, "1");
 
1227
          }
 
1228
        | varchar '(' NUM ')' opt_attribute_string
 
1229
          {
 
1230
            $$= parser::buildVarcharColumn(Lex, $3.str);
 
1231
          }
 
1232
        | TEXT_SYM opt_attribute_string
1259
1233
          {
1260
1234
            $$=DRIZZLE_TYPE_BLOB;
1261
1235
            Lex->length=(char*) 0; /* use default length */
1262
1236
 
1263
 
          if (Lex->field())
1264
 
            Lex->field()->set_type(message::Table::Field::BLOB);
1265
 
          }
1266
 
        | DECIMAL_SYM float_options
1267
 
          {
1268
 
            $$= parser::buildDecimalColumn(Lex);
1269
 
          }
1270
 
        | NUMERIC_SYM float_options
1271
 
          {
1272
 
            $$= parser::buildDecimalColumn(Lex);
1273
 
          }
1274
 
        | FIXED_SYM float_options
1275
 
          {
1276
 
            $$= parser::buildDecimalColumn(Lex);
 
1237
            if (Lex->field())
 
1238
              Lex->field()->set_type(message::Table::Field::BLOB);
1277
1239
          }
1278
1240
        | ENUM_SYM
1279
1241
          {
1280
1242
            Lex->interval_list.clear();
1281
1243
          }
1282
 
          '(' string_list ')'
 
1244
          '(' string_list ')' opt_attribute_string
1283
1245
          {
1284
1246
            $$=DRIZZLE_TYPE_ENUM;
1285
1247
 
1286
1248
            if (Lex->field())
1287
1249
              Lex->field()->set_type(message::Table::Field::ENUM);
1288
1250
          }
1289
 
        | UUID_SYM
 
1251
        | VARBINARY '(' NUM ')' opt_attribute
 
1252
          {
 
1253
            $$= parser::buildVarbinaryColumn(Lex, $3.str);
 
1254
          }
 
1255
        | real_type opt_attribute_number
 
1256
          {
 
1257
            assert ($1 == DRIZZLE_TYPE_DOUBLE);
 
1258
            $$= parser::buildDoubleColumn(Lex);
 
1259
          } 
 
1260
        | DATE_SYM opt_attribute
 
1261
          {
 
1262
            $$=DRIZZLE_TYPE_DATE;
 
1263
 
 
1264
            if (Lex->field())
 
1265
              Lex->field()->set_type(message::Table::Field::DATE);
 
1266
          }
 
1267
        | TIME_SYM opt_attribute
 
1268
          {
 
1269
            $$=DRIZZLE_TYPE_TIME;
 
1270
 
 
1271
            if (Lex->field())
 
1272
              Lex->field()->set_type(message::Table::Field::TIME);
 
1273
          }
 
1274
        | BLOB_SYM opt_attribute
 
1275
          {
 
1276
            $$= parser::buildBlobColumn(Lex);
 
1277
          }
 
1278
        | DECIMAL_SYM float_options opt_attribute_number
 
1279
          {
 
1280
            $$= parser::buildDecimalColumn(Lex);
 
1281
          }
 
1282
        | NUMERIC_SYM float_options opt_attribute_number
 
1283
          {
 
1284
            $$= parser::buildDecimalColumn(Lex);
 
1285
          }
 
1286
        | FIXED_SYM float_options opt_attribute_number
 
1287
          {
 
1288
            $$= parser::buildDecimalColumn(Lex);
 
1289
          }
 
1290
        | UUID_SYM opt_attribute
1290
1291
          {
1291
1292
            $$= parser::buildUuidColumn(Lex);
1292
1293
          }
1293
 
        | BOOLEAN_SYM
 
1294
        | BOOLEAN_SYM opt_attribute_boolean
1294
1295
          {
1295
1296
            $$= parser::buildBooleanColumn(Lex);
1296
1297
          }
1300
1301
          }
1301
1302
        ;
1302
1303
 
1303
 
char:
1304
 
          CHAR_SYM {}
1305
 
        ;
1306
 
 
1307
1304
varchar:
1308
 
          char VARYING {}
1309
 
        | VARCHAR_SYM {}
 
1305
          CHAR_SYM VARYING
 
1306
          { }
 
1307
        | CHAR_SYM
 
1308
          { }
 
1309
        | VARCHAR_SYM
 
1310
          { }
1310
1311
        ;
1311
1312
 
1312
1313
int_type:
1313
 
          INT_SYM 
1314
 
          {
1315
 
            $$= DRIZZLE_TYPE_LONG;
1316
 
          }
1317
 
        | BOOL_SYM
1318
 
          {
1319
 
            $$= DRIZZLE_TYPE_LONG;
1320
 
          }
1321
 
        | BIGINT_SYM
1322
 
          {
1323
 
            $$= DRIZZLE_TYPE_LONGLONG;
 
1314
          INT_SYM  ignored_field_number_length opt_field_number_signed opt_zerofill 
 
1315
          {
 
1316
            $$= parser::buildIntegerColumn(Lex, DRIZZLE_TYPE_LONG, ($3 or $4));
 
1317
          }
 
1318
        | BIGINT_SYM ignored_field_number_length opt_field_number_signed opt_zerofill 
 
1319
          {
 
1320
            $$= parser::buildIntegerColumn(Lex, DRIZZLE_TYPE_LONGLONG, ($3 or $4));
1324
1321
          }
1325
1322
        ;
1326
1323
 
1327
1324
real_type:
1328
 
          REAL
1329
 
          {
1330
 
            $$= DRIZZLE_TYPE_DOUBLE;
1331
 
          }
1332
 
        | DOUBLE_SYM
1333
 
          {
1334
 
            $$= DRIZZLE_TYPE_DOUBLE;
1335
 
          }
1336
 
        | DOUBLE_SYM PRECISION
 
1325
          REAL opt_precision
 
1326
          {
 
1327
            $$= DRIZZLE_TYPE_DOUBLE;
 
1328
          }
 
1329
        | DOUBLE_SYM opt_precision
 
1330
          {
 
1331
            $$= DRIZZLE_TYPE_DOUBLE;
 
1332
          }
 
1333
        | DOUBLE_SYM PRECISION opt_precision
1337
1334
          {
1338
1335
            $$= DRIZZLE_TYPE_DOUBLE;
1339
1336
          }
1386
1383
          {}
1387
1384
        ;
1388
1385
 
1389
 
opt_attribute:
1390
 
          /* empty */ {}
1391
 
        | opt_attribute_list {}
1392
 
        ;
1393
 
 
1394
 
opt_attribute_list:
1395
 
          opt_attribute_list attribute {}
1396
 
        | attribute
1397
 
        ;
1398
 
 
1399
 
attribute:
 
1386
opt_attribute_not_null:
1400
1387
          NULL_SYM
1401
1388
          {
1402
1389
            Lex->type&= ~ NOT_NULL_FLAG;
1403
1390
          }
1404
 
        | not NULL_SYM
 
1391
        | NOT_SYM NULL_SYM
1405
1392
          {
1406
1393
            Lex->type|= NOT_NULL_FLAG;
1407
1394
 
1410
1397
              Lex->field()->mutable_constraints()->set_is_notnull(true);
1411
1398
            }
1412
1399
          }
1413
 
        | DEFAULT now_or_signed_literal
1414
 
          {
1415
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1400
        ;
1416
1401
 
1417
 
            statement->default_value=$2;
1418
 
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1419
 
          }
1420
 
        | ON UPDATE_SYM NOW_SYM optional_braces
1421
 
          {
1422
 
            ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
1423
 
          }
1424
 
        | AUTO_INC
1425
 
          {
1426
 
            parser::buildAutoOnColumn(Lex);
1427
 
          }
1428
 
        | SERIAL_SYM DEFAULT VALUE_SYM
1429
 
          {
1430
 
            (void)parser::buildSerialColumn(Lex);
1431
 
          }
1432
 
        | opt_primary KEY_SYM
 
1402
opt_attribute_index:
 
1403
          opt_primary KEY_SYM
1433
1404
          {
1434
1405
            parser::buildPrimaryOnColumn(Lex);
1435
1406
          }
1441
1412
          {
1442
1413
            parser::buildKeyOnColumn(Lex);
1443
1414
          }
1444
 
        | COMMENT_SYM TEXT_STRING_sys
1445
 
          {
1446
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1447
 
            statement->comment= $2;
1448
 
 
1449
 
            if (Lex->field())
1450
 
              Lex->field()->set_comment($2.str);
 
1415
        ;
 
1416
 
 
1417
opt_attribute:
 
1418
          /* empty */ {}
 
1419
        | opt_attribute opt_attribute_not_null
 
1420
          { }
 
1421
        | opt_attribute DEFAULT signed_literal
 
1422
          {
 
1423
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1424
 
 
1425
            statement->default_value= $3;
 
1426
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1427
          }
 
1428
        | opt_attribute opt_attribute_index
 
1429
          { }
 
1430
        ;
 
1431
 
 
1432
opt_attribute_boolean:
 
1433
          /* empty */ { }
 
1434
        | opt_attribute_boolean opt_attribute_not_null
 
1435
          { }
 
1436
        | opt_attribute_boolean DEFAULT boolean_literal
 
1437
          {
 
1438
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1439
 
 
1440
            statement->default_value= $3;
 
1441
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1442
          }
 
1443
        | opt_attribute_boolean opt_attribute_index
 
1444
          { }
 
1445
        ;
 
1446
 
 
1447
opt_attribute_string:
 
1448
          /* empty */ {}
 
1449
        | opt_attribute_list_string {}
 
1450
        ;
 
1451
 
 
1452
opt_attribute_list_string:
 
1453
          opt_attribute_list_string attribute_string {}
 
1454
        | attribute_string
 
1455
        ;
 
1456
 
 
1457
attribute_string:
 
1458
          opt_attribute_not_null
 
1459
          { }
 
1460
        | DEFAULT signed_literal
 
1461
          {
 
1462
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1463
 
 
1464
            statement->default_value=$2;
 
1465
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1451
1466
          }
1452
1467
        | COLLATE_SYM collation_name
1453
1468
          {
1462
1477
              Lex->charset=$2;
1463
1478
            }
1464
1479
          }
1465
 
        ;
1466
 
 
1467
 
now_or_signed_literal:
1468
 
          NOW_SYM optional_braces
1469
 
          { $$= new Item_func_now_local(); }
1470
 
        | signed_literal
1471
 
          { $$=$1; }
 
1480
        | opt_attribute_index
 
1481
          { }
 
1482
        ;
 
1483
 
 
1484
opt_attribute_number:
 
1485
          /* empty */ {}
 
1486
        | opt_attribute_list_integer {}
 
1487
        ;
 
1488
 
 
1489
opt_attribute_list_integer:
 
1490
          opt_attribute_list_integer attribute_integer {}
 
1491
        | attribute_integer
 
1492
        ;
 
1493
 
 
1494
attribute_integer:
 
1495
          opt_attribute_not_null
 
1496
          { }
 
1497
        | AUTO_INC
 
1498
          {
 
1499
            parser::buildAutoOnColumn(Lex);
 
1500
          }
 
1501
        | SERIAL_SYM DEFAULT VALUE_SYM
 
1502
          {
 
1503
            (void)parser::buildSerialColumn(Lex);
 
1504
          }
 
1505
        | DEFAULT integer_literal
 
1506
          {
 
1507
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1508
 
 
1509
            statement->default_value=$2;
 
1510
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1511
          }
 
1512
        | opt_attribute_index
 
1513
          { }
 
1514
        ;
 
1515
 
 
1516
opt_attribute_timestamp:
 
1517
          /* empty */ {}
 
1518
        | opt_attribute_list_timestamp {}
 
1519
        ;
 
1520
 
 
1521
opt_attribute_list_timestamp:
 
1522
          opt_attribute_list_timestamp attribute_timestamp {}
 
1523
        | attribute_timestamp
 
1524
        ;
 
1525
 
 
1526
attribute_timestamp:
 
1527
          opt_attribute_not_null
 
1528
          { }
 
1529
        | DEFAULT NOW_SYM optional_braces
 
1530
          {
 
1531
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1532
 
 
1533
            statement->default_value= new Item_func_now_local();
 
1534
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1535
          }
 
1536
        | DEFAULT date_literal
 
1537
          {
 
1538
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1539
 
 
1540
            statement->default_value=$2;
 
1541
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1542
          }
 
1543
        | ON UPDATE_SYM NOW_SYM optional_braces
 
1544
          {
 
1545
            ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
 
1546
          }
 
1547
        | opt_attribute_index
 
1548
          { }
 
1549
        ;
 
1550
 
 
1551
opt_attribute_comment:
 
1552
          /* empty */ { }
 
1553
        | COMMENT_SYM TEXT_STRING_sys
 
1554
          {
 
1555
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1556
            statement->comment= $2;
 
1557
 
 
1558
            if (Lex->field())
 
1559
              Lex->field()->set_comment($2.str);
 
1560
          }
1472
1561
        ;
1473
1562
 
1474
1563
collation_name:
1788
1877
 
1789
1878
            Lex->setField(NULL);
1790
1879
          }
1791
 
          field_def
 
1880
          field_def opt_attribute_comment
1792
1881
          {
1793
1882
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1794
1883
 
2233
2322
 
2234
2323
/* all possible expressions */
2235
2324
expr:
2236
 
          expr or expr %prec OR_SYM
 
2325
          expr OR_SYM expr %prec OR_SYM
2237
2326
          {
2238
2327
            /*
2239
2328
              Design notes:
2287
2376
            /* XOR is a proprietary extension */
2288
2377
            $$ = new (YYSession->mem_root) Item_cond_xor($1, $3);
2289
2378
          }
2290
 
        | expr and expr %prec AND_SYM
 
2379
        | expr AND_SYM expr %prec AND_SYM
2291
2380
          {
2292
2381
            /* See comments in rule expr: expr or expr */
2293
2382
            Item_cond_and *item1;
2331
2420
        | NOT_SYM expr %prec NOT_SYM
2332
2421
          { $$= negate_expression(YYSession, $2); }
2333
2422
        | bool_pri IS TRUE_SYM %prec IS
2334
 
          { $$= new (YYSession->mem_root) Item_func_istrue($1); }
2335
 
        | bool_pri IS not TRUE_SYM %prec IS
2336
 
          { $$= new (YYSession->mem_root) Item_func_isnottrue($1); }
 
2423
          { 
 
2424
            $$= new (YYSession->mem_root) Item_func_istrue($1);
 
2425
          }
 
2426
        | bool_pri IS NOT_SYM TRUE_SYM %prec IS
 
2427
          {
 
2428
            $$= new (YYSession->mem_root) Item_func_isnottrue($1);
 
2429
          }
2337
2430
        | bool_pri IS FALSE_SYM %prec IS
2338
 
          { $$= new (YYSession->mem_root) Item_func_isfalse($1); }
2339
 
        | bool_pri IS not FALSE_SYM %prec IS
2340
 
          { $$= new (YYSession->mem_root) Item_func_isnotfalse($1); }
 
2431
          {
 
2432
            $$= new (YYSession->mem_root) Item_func_isfalse($1);
 
2433
          }
 
2434
        | bool_pri IS NOT_SYM FALSE_SYM %prec IS
 
2435
          {
 
2436
            $$= new (YYSession->mem_root) Item_func_isnotfalse($1);
 
2437
          }
2341
2438
        | bool_pri IS UNKNOWN_SYM %prec IS
2342
 
          { $$= new Item_func_isnull($1); }
2343
 
        | bool_pri IS not UNKNOWN_SYM %prec IS
2344
 
          { $$= new Item_func_isnotnull($1); }
 
2439
          {
 
2440
            $$= new Item_func_isnull($1);
 
2441
          }
 
2442
        | bool_pri IS NOT_SYM UNKNOWN_SYM %prec IS
 
2443
          {
 
2444
            $$= new Item_func_isnotnull($1);
 
2445
          }
2345
2446
        | bool_pri
2346
2447
        ;
2347
2448
 
2348
2449
bool_pri:
2349
2450
          bool_pri IS NULL_SYM %prec IS
2350
 
          { $$= new Item_func_isnull($1); }
2351
 
        | bool_pri IS not NULL_SYM %prec IS
2352
 
          { $$= new Item_func_isnotnull($1); }
 
2451
          {
 
2452
            $$= new Item_func_isnull($1);
 
2453
          }
 
2454
        | bool_pri IS NOT_SYM NULL_SYM %prec IS
 
2455
          {
 
2456
            $$= new Item_func_isnotnull($1);
 
2457
          }
2353
2458
        | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
2354
 
          { $$= new Item_func_equal($1,$3); }
 
2459
          {
 
2460
            $$= new Item_func_equal($1,$3);
 
2461
          }
2355
2462
        | bool_pri comp_op predicate %prec '='
2356
 
          { $$= (*$2)(0)->create($1,$3); }
 
2463
          {
 
2464
            $$= (*$2)(0)->create($1,$3);
 
2465
          }
2357
2466
        | bool_pri comp_op all_or_any '(' subselect ')' %prec '='
2358
 
          { $$= all_any_subquery_creator($1, $2, $3, $5); }
 
2467
          {
 
2468
            $$= all_any_subquery_creator($1, $2, $3, $5);
 
2469
          }
2359
2470
        | predicate
2360
2471
        ;
2361
2472
 
2364
2475
          {
2365
2476
            $$= new (YYSession->mem_root) Item_in_subselect($1, $4);
2366
2477
          }
2367
 
        | bit_expr not IN_SYM '(' subselect ')'
 
2478
        | bit_expr NOT_SYM IN_SYM '(' subselect ')'
2368
2479
          {
2369
2480
            Item *item= new (YYSession->mem_root) Item_in_subselect($1, $5);
2370
2481
            $$= negate_expression(YYSession, item);
2379
2490
            $6->push_front($1);
2380
2491
            $$= new (YYSession->mem_root) Item_func_in(*$6);
2381
2492
          }
2382
 
        | bit_expr not IN_SYM '(' expr ')'
 
2493
        | bit_expr NOT_SYM IN_SYM '(' expr ')'
2383
2494
          {
2384
2495
            $$= parser::handle_sql2003_note184_exception(YYSession, $1, false, $5);
2385
2496
          }
2386
 
        | bit_expr not IN_SYM '(' expr ',' expr_list ')'
 
2497
        | bit_expr NOT_SYM IN_SYM '(' expr ',' expr_list ')'
2387
2498
          {
2388
2499
            $7->push_front($5);
2389
2500
            $7->push_front($1);
2395
2506
          {
2396
2507
            $$= new Item_func_between($1,$3,$5);
2397
2508
          }
2398
 
        | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
 
2509
        | bit_expr NOT_SYM BETWEEN_SYM bit_expr AND_SYM predicate
2399
2510
          {
2400
2511
            Item_func_between *item= new Item_func_between($1,$4,$6);
2401
2512
            item->negate();
2405
2516
          { 
2406
2517
            $$= new Item_func_like($1,$3,$4,Lex->escape_used);
2407
2518
          }
2408
 
        | bit_expr not LIKE simple_expr opt_escape
 
2519
        | bit_expr NOT_SYM LIKE simple_expr opt_escape
2409
2520
          { 
2410
2521
            $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used));
2411
2522
          }
2419
2530
              DRIZZLE_YYABORT;
2420
2531
            }
2421
2532
          }
2422
 
        | bit_expr not REGEXP_SYM bit_expr
 
2533
        | bit_expr NOT_SYM REGEXP_SYM bit_expr
2423
2534
          { 
2424
2535
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2425
2536
            args->push_back($1);
2451
2562
            $$= new function::bit::ShiftLeft($1, $3);
2452
2563
          }
2453
2564
        | bit_expr '+' bit_expr %prec '+'
2454
 
          { $$= new Item_func_plus($1,$3); }
 
2565
          {
 
2566
            $$= new Item_func_plus($1,$3);
 
2567
          }
2455
2568
        | bit_expr '-' bit_expr %prec '-'
2456
 
          { $$= new Item_func_minus($1,$3); }
 
2569
          { 
 
2570
            $$= new Item_func_minus($1,$3);
 
2571
          }
2457
2572
        | bit_expr '+' INTERVAL_SYM expr interval %prec '+'
2458
 
          { $$= new Item_date_add_interval($1,$4,$5,0); }
 
2573
          {
 
2574
            $$= new Item_date_add_interval($1,$4,$5,0);
 
2575
          }
2459
2576
        | bit_expr '-' INTERVAL_SYM expr interval %prec '-'
2460
 
          { $$= new Item_date_add_interval($1,$4,$5,1); }
 
2577
          {
 
2578
            $$= new Item_date_add_interval($1,$4,$5,1);
 
2579
          }
2461
2580
        | bit_expr '*' bit_expr %prec '*'
2462
 
          { $$= new Item_func_mul($1,$3); }
 
2581
          {
 
2582
            $$= new Item_func_mul($1,$3);
 
2583
          }
2463
2584
        | bit_expr '/' bit_expr %prec '/'
2464
 
          { $$= new Item_func_div(YYSession,$1,$3); }
 
2585
          {
 
2586
            $$= new Item_func_div(YYSession,$1,$3);
 
2587
          }
2465
2588
        | bit_expr '%' bit_expr %prec '%'
2466
 
          { $$= new Item_func_mod($1,$3); }
 
2589
          {
 
2590
            $$= new Item_func_mod($1,$3);
 
2591
          }
2467
2592
        | bit_expr DIV_SYM bit_expr %prec DIV_SYM
2468
 
          { $$= new Item_func_int_div($1,$3); }
 
2593
          {
 
2594
            $$= new Item_func_int_div($1,$3);
 
2595
          }
2469
2596
        | bit_expr MOD_SYM bit_expr %prec MOD_SYM
2470
 
          { $$= new Item_func_mod($1,$3); }
 
2597
          {
 
2598
            $$= new Item_func_mod($1,$3);
 
2599
          }
2471
2600
        | bit_expr '^' bit_expr
2472
2601
          {
2473
2602
            $$= new (YYSession->mem_root) function::bit::Xor($1, $3);
2475
2604
        | simple_expr
2476
2605
        ;
2477
2606
 
2478
 
or:
2479
 
          OR_SYM
2480
 
       ;
2481
 
 
2482
 
and:
2483
 
          AND_SYM
2484
 
       ;
2485
 
 
2486
 
not:
2487
 
          NOT_SYM
2488
 
        ;
2489
 
 
2490
2607
comp_op:
2491
2608
          '='     { $$ = &comp_eq_creator; }
2492
2609
        | GE     { $$ = &comp_ge_creator; }
2520
2637
          {
2521
2638
            Lex->setSumExprUsed();
2522
2639
          }
 
2640
        | simple_expr CONCAT simple_expr
 
2641
          {
 
2642
            $$= new (YYSession->mem_root) Item_func_concat(*YYSession, $1, $3);
 
2643
          }
2523
2644
        | '+' simple_expr %prec UMINUS { $$= $2; }
2524
2645
        | '-' simple_expr %prec UMINUS
2525
2646
          {
2892
3013
function_call_generic:
2893
3014
          IDENT_sys '('
2894
3015
          {
2895
 
            const plugin::Function *udf= plugin::Function::get($1.str, $1.length);
 
3016
            const plugin::Function *udf= plugin::Function::get(std::string($1.str, $1.length));
2896
3017
 
2897
3018
            /* Temporary placing the result of getFunction in $3 */
2898
3019
            $<udf>$= udf;
4818
4939
        | TIMESTAMP_SYM text_literal { $$ = $2; }
4819
4940
        ;
4820
4941
 
 
4942
integer_literal:
 
4943
          text_literal { $$ = $1; }
 
4944
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
 
4945
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
 
4946
        | NUM_literal { $$ = $1; }
 
4947
        | NULL_SYM
 
4948
          {
 
4949
            $$ = new Item_null();
 
4950
            YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
 
4951
          }
 
4952
        | '+' NUM_literal { $$ = $2; }
 
4953
        | '-' NUM_literal
 
4954
          {
 
4955
            $2->max_length++;
 
4956
            $$= $2->neg();
 
4957
          }
 
4958
        ;
 
4959
 
 
4960
boolean_literal:
 
4961
          NULL_SYM
 
4962
          {
 
4963
            $$ = new Item_null();
 
4964
            YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
 
4965
          }
 
4966
        | FALSE_SYM
 
4967
          {
 
4968
            $$= new drizzled::item::False();
 
4969
          }
 
4970
        | TRUE_SYM
 
4971
          {
 
4972
            $$= new drizzled::item::True();
 
4973
          }
 
4974
        ;
 
4975
 
 
4976
date_literal:
 
4977
          text_literal { $$ = $1; }
 
4978
        | NULL_SYM
 
4979
          {
 
4980
            $$ = new Item_null();
 
4981
            YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
 
4982
          }
 
4983
        | NUM_literal { $$ = $1; }
 
4984
        | DATE_SYM text_literal { $$ = $2; }
 
4985
        | TIMESTAMP_SYM text_literal { $$ = $2; }
 
4986
        ;
 
4987
 
4821
4988
NUM_literal:
4822
4989
          NUM
4823
4990
          {