~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2011-02-03 00:52:25 UTC
  • mto: (2139.1.3 drizzle-build)
  • mto: This revision was merged to the branch mainline in revision 2140.
  • Revision ID: brian@tangent.org-20110203005225-bovqok78o3p1528p
Add documentation for BOOL/BOOLEAN type, and add a mysql compatible BOOL for
folks who are porting software.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1249
1249
              Lex->field()->set_type(message::Table::Field::DOUBLE);
1250
1250
            }
1251
1251
          }
1252
 
          | char '(' NUM ')'
1253
 
            {
1254
 
              Lex->length=$3.str;
1255
 
              $$=DRIZZLE_TYPE_VARCHAR;
1256
 
 
1257
 
            if (Lex->field())
1258
 
            {
1259
 
              Lex->field()->set_type(message::Table::Field::VARCHAR);
1260
 
              message::Table::Field::StringFieldOptions *string_field_options;
1261
 
 
1262
 
              string_field_options= Lex->field()->mutable_string_options();
1263
 
 
1264
 
              string_field_options->set_length(atoi($3.str));
1265
 
            }
1266
 
            }
1267
 
          | char
1268
 
            {
1269
 
              Lex->length=(char*) "1";
1270
 
              $$=DRIZZLE_TYPE_VARCHAR;
1271
 
 
1272
 
            if (Lex->field())
1273
 
              Lex->field()->set_type(message::Table::Field::VARCHAR);
1274
 
            }
1275
 
          | varchar '(' NUM ')'
1276
 
            {
1277
 
              Lex->length=$3.str;
1278
 
              $$= DRIZZLE_TYPE_VARCHAR;
1279
 
 
1280
 
            if (Lex->field())
1281
 
            {
1282
 
              Lex->field()->set_type(message::Table::Field::VARCHAR);
1283
 
 
1284
 
              message::Table::Field::StringFieldOptions *string_field_options;
1285
 
 
1286
 
              string_field_options= Lex->field()->mutable_string_options();
1287
 
 
1288
 
              string_field_options->set_length(atoi($3.str));
1289
 
            }
1290
 
            }
1291
 
          | VARBINARY '(' NUM ')'
1292
 
            {
1293
 
              Lex->length=$3.str;
1294
 
              Lex->charset=&my_charset_bin;
1295
 
              $$= DRIZZLE_TYPE_VARCHAR;
1296
 
 
1297
 
            if (Lex->field())
1298
 
            {
 
1252
        | char '(' NUM ')'
 
1253
          {
 
1254
            Lex->length=$3.str;
 
1255
            $$=DRIZZLE_TYPE_VARCHAR;
 
1256
 
 
1257
            if (Lex->field())
 
1258
            {
 
1259
              Lex->field()->set_type(message::Table::Field::VARCHAR);
 
1260
              message::Table::Field::StringFieldOptions *string_field_options;
 
1261
 
 
1262
              string_field_options= Lex->field()->mutable_string_options();
 
1263
 
 
1264
              string_field_options->set_length(atoi($3.str));
 
1265
            }
 
1266
          }
 
1267
        | char
 
1268
          {
 
1269
            Lex->length=(char*) "1";
 
1270
            $$=DRIZZLE_TYPE_VARCHAR;
 
1271
 
 
1272
            if (Lex->field())
 
1273
              Lex->field()->set_type(message::Table::Field::VARCHAR);
 
1274
          }
 
1275
        | varchar '(' NUM ')'
 
1276
          {
 
1277
            Lex->length=$3.str;
 
1278
            $$= DRIZZLE_TYPE_VARCHAR;
 
1279
 
 
1280
            if (Lex->field())
 
1281
            {
 
1282
              Lex->field()->set_type(message::Table::Field::VARCHAR);
 
1283
 
 
1284
              message::Table::Field::StringFieldOptions *string_field_options;
 
1285
 
 
1286
              string_field_options= Lex->field()->mutable_string_options();
 
1287
 
 
1288
              string_field_options->set_length(atoi($3.str));
 
1289
            }
 
1290
          }
 
1291
        | VARBINARY '(' NUM ')'
 
1292
          {
 
1293
            Lex->length=$3.str;
 
1294
            Lex->charset=&my_charset_bin;
 
1295
            $$= DRIZZLE_TYPE_VARCHAR;
 
1296
 
 
1297
            if (Lex->field())
 
1298
            {
1299
1299
              Lex->field()->set_type(message::Table::Field::VARCHAR);
1300
1300
              message::Table::Field::StringFieldOptions *string_field_options;
1301
1301
 
1305
1305
              string_field_options->set_collation_id(my_charset_bin.number);
1306
1306
              string_field_options->set_collation(my_charset_bin.name);
1307
1307
            }
1308
 
            }
1309
 
          | DATE_SYM
1310
 
            {
1311
 
              $$=DRIZZLE_TYPE_DATE;
1312
 
 
1313
 
              if (Lex->field())
1314
 
                Lex->field()->set_type(message::Table::Field::DATE);
1315
 
            }
1316
 
          | TIME_SYM
1317
 
            {
1318
 
              $$=DRIZZLE_TYPE_TIME;
1319
 
 
1320
 
              if (Lex->field())
1321
 
                Lex->field()->set_type(message::Table::Field::TIME);
1322
 
            }
1323
 
          | TIMESTAMP_SYM
1324
 
            {
1325
 
              $$=DRIZZLE_TYPE_TIMESTAMP;
1326
 
              Lex->length= 0;
1327
 
 
1328
 
              if (Lex->field())
1329
 
                Lex->field()->set_type(message::Table::Field::EPOCH);
1330
 
            }
1331
 
          | TIMESTAMP_SYM '(' NUM ')'
1332
 
            {
1333
 
              $$=DRIZZLE_TYPE_MICROTIME;
1334
 
              Lex->length= $3.str;
1335
 
 
1336
 
              if (Lex->field())
1337
 
                Lex->field()->set_type(message::Table::Field::EPOCH);
1338
 
            }
1339
 
          | DATETIME_SYM
1340
 
            {
1341
 
              $$=DRIZZLE_TYPE_DATETIME;
1342
 
 
1343
 
              if (Lex->field())
1344
 
                Lex->field()->set_type(message::Table::Field::DATETIME);
1345
 
            }
1346
 
          | BLOB_SYM
1347
 
            {
1348
 
              Lex->charset=&my_charset_bin;
1349
 
              $$=DRIZZLE_TYPE_BLOB;
1350
 
              Lex->length=(char*) 0; /* use default length */
1351
 
 
1352
 
              if (Lex->field())
1353
 
              {
1354
 
                Lex->field()->set_type(message::Table::Field::BLOB);
1355
 
                message::Table::Field::StringFieldOptions *string_field_options;
1356
 
 
1357
 
                string_field_options= Lex->field()->mutable_string_options();
1358
 
                string_field_options->set_collation_id(my_charset_bin.number);
1359
 
                string_field_options->set_collation(my_charset_bin.name);
1360
 
              }
1361
 
            }
1362
 
          | TEXT_SYM
1363
 
            {
1364
 
              $$=DRIZZLE_TYPE_BLOB;
1365
 
              Lex->length=(char*) 0; /* use default length */
1366
 
 
1367
 
            if (Lex->field())
 
1308
          }
 
1309
        | DATE_SYM
 
1310
          {
 
1311
            $$=DRIZZLE_TYPE_DATE;
 
1312
 
 
1313
            if (Lex->field())
 
1314
              Lex->field()->set_type(message::Table::Field::DATE);
 
1315
          }
 
1316
        | TIME_SYM
 
1317
          {
 
1318
            $$=DRIZZLE_TYPE_TIME;
 
1319
 
 
1320
            if (Lex->field())
 
1321
              Lex->field()->set_type(message::Table::Field::TIME);
 
1322
          }
 
1323
        | TIMESTAMP_SYM
 
1324
          {
 
1325
            $$=DRIZZLE_TYPE_TIMESTAMP;
 
1326
            Lex->length= 0;
 
1327
 
 
1328
            if (Lex->field())
 
1329
              Lex->field()->set_type(message::Table::Field::EPOCH);
 
1330
          }
 
1331
        | TIMESTAMP_SYM '(' NUM ')'
 
1332
          {
 
1333
            $$=DRIZZLE_TYPE_MICROTIME;
 
1334
            Lex->length= $3.str;
 
1335
 
 
1336
            if (Lex->field())
 
1337
              Lex->field()->set_type(message::Table::Field::EPOCH);
 
1338
          }
 
1339
        | DATETIME_SYM
 
1340
          {
 
1341
            $$=DRIZZLE_TYPE_DATETIME;
 
1342
 
 
1343
            if (Lex->field())
 
1344
              Lex->field()->set_type(message::Table::Field::DATETIME);
 
1345
          }
 
1346
        | BLOB_SYM
 
1347
          {
 
1348
            Lex->charset=&my_charset_bin;
 
1349
            $$=DRIZZLE_TYPE_BLOB;
 
1350
            Lex->length=(char*) 0; /* use default length */
 
1351
 
 
1352
            if (Lex->field())
 
1353
            {
1368
1354
              Lex->field()->set_type(message::Table::Field::BLOB);
 
1355
              message::Table::Field::StringFieldOptions *string_field_options;
 
1356
 
 
1357
              string_field_options= Lex->field()->mutable_string_options();
 
1358
              string_field_options->set_collation_id(my_charset_bin.number);
 
1359
              string_field_options->set_collation(my_charset_bin.name);
1369
1360
            }
1370
 
          | DECIMAL_SYM float_options
1371
 
          {
1372
 
            $$=DRIZZLE_TYPE_DECIMAL;
1373
 
 
1374
 
            if (Lex->field())
1375
 
              Lex->field()->set_type(message::Table::Field::DECIMAL);
1376
 
          }
1377
 
          | NUMERIC_SYM float_options
1378
 
          {
1379
 
            $$=DRIZZLE_TYPE_DECIMAL;
1380
 
 
1381
 
            if (Lex->field())
1382
 
              Lex->field()->set_type(message::Table::Field::DECIMAL);
1383
 
          }
1384
 
          | FIXED_SYM float_options
1385
 
          {
1386
 
            $$=DRIZZLE_TYPE_DECIMAL;
1387
 
 
1388
 
            if (Lex->field())
1389
 
              Lex->field()->set_type(message::Table::Field::DECIMAL);
1390
 
          }
1391
 
          | ENUM_SYM
1392
 
            {Lex->interval_list.empty();}
1393
 
            '(' string_list ')'
 
1361
          }
 
1362
        | TEXT_SYM
 
1363
          {
 
1364
            $$=DRIZZLE_TYPE_BLOB;
 
1365
            Lex->length=(char*) 0; /* use default length */
 
1366
 
 
1367
          if (Lex->field())
 
1368
            Lex->field()->set_type(message::Table::Field::BLOB);
 
1369
          }
 
1370
        | DECIMAL_SYM float_options
 
1371
          {
 
1372
            $$=DRIZZLE_TYPE_DECIMAL;
 
1373
 
 
1374
            if (Lex->field())
 
1375
              Lex->field()->set_type(message::Table::Field::DECIMAL);
 
1376
          }
 
1377
        | NUMERIC_SYM float_options
 
1378
          {
 
1379
            $$=DRIZZLE_TYPE_DECIMAL;
 
1380
 
 
1381
            if (Lex->field())
 
1382
              Lex->field()->set_type(message::Table::Field::DECIMAL);
 
1383
          }
 
1384
        | FIXED_SYM float_options
 
1385
          {
 
1386
            $$=DRIZZLE_TYPE_DECIMAL;
 
1387
 
 
1388
            if (Lex->field())
 
1389
              Lex->field()->set_type(message::Table::Field::DECIMAL);
 
1390
          }
 
1391
        | ENUM_SYM
 
1392
          {
 
1393
            Lex->interval_list.empty();
 
1394
          }
 
1395
          '(' string_list ')'
1394
1396
          {
1395
1397
            $$=DRIZZLE_TYPE_ENUM;
1396
1398
 
1436
1438
        ;
1437
1439
 
1438
1440
int_type:
1439
 
          INT_SYM    { $$=DRIZZLE_TYPE_LONG; }
1440
 
        | BIGINT_SYM { $$=DRIZZLE_TYPE_LONGLONG; }
 
1441
          INT_SYM 
 
1442
          {
 
1443
            $$= DRIZZLE_TYPE_LONG;
 
1444
          }
 
1445
        | BOOL_SYM
 
1446
          {
 
1447
            $$= DRIZZLE_TYPE_LONG;
 
1448
          }
 
1449
        | BIGINT_SYM
 
1450
          {
 
1451
            $$= DRIZZLE_TYPE_LONGLONG;
 
1452
          }
1441
1453
        ;
1442
1454
 
1443
1455
real_type:
1446
1458
            $$= DRIZZLE_TYPE_DOUBLE;
1447
1459
          }
1448
1460
        | DOUBLE_SYM
1449
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
1461
          {
 
1462
            $$= DRIZZLE_TYPE_DOUBLE;
 
1463
          }
1450
1464
        | DOUBLE_SYM PRECISION
1451
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
1465
          {
 
1466
            $$= DRIZZLE_TYPE_DOUBLE;
 
1467
          }
1452
1468
        ;
1453
1469
 
1454
1470
float_options: