~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

First pass on cleanup of Stewart's patch, plus re-engineer to make it work a
bit more with the current system. Engines approve key/pair.

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
  Currently there are 88 shift/reduce conflicts.
373
373
  We should not introduce new conflicts any more.
374
374
*/
375
 
%expect 88
 
375
%expect 94
376
376
 
377
377
/*
378
378
   Comments for TOKENS.
417
417
%token  BIN_NUM
418
418
%token  BIT_SYM                       /* MYSQL-FUNC */
419
419
%token  BLOB_SYM                      /* SQL-2003-R */
420
 
%token  BLOCK_SIZE_SYM
421
 
%token  BLOCK_SYM
422
420
%token  BOOLEAN_SYM                   /* SQL-2003-R */
423
421
%token  BOOL_SYM
424
422
%token  BOTH                          /* SQL-2003-R */
873
871
 
874
872
%type <interval_time_st> interval_time_stamp
875
873
 
876
 
%type <row_type> row_types
877
 
 
878
874
%type <column_format_type> column_format_types
879
875
 
880
876
%type <tx_isolation> isolation_types
1190
1186
opt_create_database_options:
1191
1187
          /* empty */ {}
1192
1188
        | default_collation_schema {}
 
1189
        | opt_database_custom_options {}
 
1190
        ;
 
1191
 
 
1192
opt_database_custom_options:
 
1193
        custom_database_option
 
1194
        | custom_database_option ',' opt_database_custom_options
 
1195
        ;
 
1196
 
 
1197
custom_database_option:
 
1198
          ident_or_text
 
1199
        {
 
1200
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
 
1201
          drizzled::message::Schema::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
 
1202
 
 
1203
          opt->set_name($1.str);
 
1204
        }
 
1205
        | ident_or_text equal ident_or_text
 
1206
        {
 
1207
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
 
1208
          drizzled::message::Schema::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
 
1209
 
 
1210
          opt->set_name($1.str);
 
1211
          opt->set_state($3.str);
 
1212
        }
 
1213
        | ident_or_text equal ulonglong_num
 
1214
        {
 
1215
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
 
1216
          char number_as_string[22];
 
1217
 
 
1218
          snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
 
1219
 
 
1220
          drizzled::message::Schema::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
 
1221
 
 
1222
          opt->set_name($1.str);
 
1223
          opt->set_state(number_as_string);
 
1224
        }
1193
1225
        ;
1194
1226
 
1195
1227
opt_table_options:
1216
1248
          create_table_option
1217
1249
        | create_table_option     create_table_options
1218
1250
        | create_table_option ',' create_table_options
1219
 
        ;
1220
1251
 
1221
1252
create_table_option:
1222
 
          ENGINE_SYM opt_equal ident_or_text
 
1253
          custom_engine_option;
 
1254
 
 
1255
custom_engine_option:
 
1256
        ENGINE_SYM equal ident_or_text
1223
1257
          {
1224
1258
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1225
1259
            message::Table::StorageEngine *protoengine;
1247
1281
            statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1248
1282
            tableopts->set_auto_increment_value($3);
1249
1283
          }
1250
 
        | ROW_FORMAT_SYM opt_equal row_types
1251
 
          {
1252
 
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1253
 
            message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
1254
 
 
1255
 
            statement->create_info.row_type= $3;
1256
 
            statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1257
 
            statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1258
 
 
1259
 
            switch(statement->create_info.row_type)
1260
 
            {
1261
 
            case ROW_TYPE_DEFAULT:
1262
 
              /* No use setting a default row type... just adds redundant info to message */
1263
 
              break;
1264
 
            case ROW_TYPE_FIXED:
1265
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
1266
 
              break;
1267
 
            case ROW_TYPE_DYNAMIC:
1268
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
1269
 
              break;
1270
 
            case ROW_TYPE_COMPRESSED:
1271
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
1272
 
              break;
1273
 
            case ROW_TYPE_REDUNDANT:
1274
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
1275
 
              break;
1276
 
            case ROW_TYPE_COMPACT:
1277
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
1278
 
              break;
1279
 
            case ROW_TYPE_PAGE:
1280
 
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
1281
 
              break;
1282
 
            default:
1283
 
              abort();
1284
 
            }
 
1284
        |  ident_or_text equal ident_or_text
 
1285
          {
 
1286
            message::Table::StorageEngine *protoengine;
 
1287
            protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
 
1288
 
 
1289
            drizzled::message::Table::StorageEngine::EngineOption *opt= protoengine->add_options();
 
1290
 
 
1291
            opt->set_name($1.str);
 
1292
            opt->set_state($3.str);
 
1293
          }
 
1294
        | ident_or_text equal ulonglong_num
 
1295
          {
 
1296
            char number_as_string[22];
 
1297
            snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
 
1298
 
 
1299
            message::Table::StorageEngine *protoengine;
 
1300
            protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
 
1301
 
 
1302
            drizzled::message::Table::StorageEngine::EngineOption *opt= protoengine->add_options();
 
1303
            opt->set_name($1.str);
 
1304
            opt->set_state(number_as_string);
1285
1305
          }
1286
1306
        | default_collation
1287
1307
        ;
1320
1340
        | FIXED_SYM   { $$= COLUMN_FORMAT_TYPE_FIXED; }
1321
1341
        | DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1322
1342
 
1323
 
row_types:
1324
 
          DEFAULT        { $$= ROW_TYPE_DEFAULT; }
1325
 
        | FIXED_SYM      { $$= ROW_TYPE_FIXED; }
1326
 
        | DYNAMIC_SYM    { $$= ROW_TYPE_DYNAMIC; }
1327
 
        | COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1328
 
        | REDUNDANT_SYM  { $$= ROW_TYPE_REDUNDANT; }
1329
 
        | COMPACT_SYM    { $$= ROW_TYPE_COMPACT; }
1330
 
        | PAGE_SYM       { $$= ROW_TYPE_PAGE; }
1331
 
        ;
1332
1343
 
1333
1344
opt_select_from:
1334
1345
          opt_limit_clause {}
5798
5809
        | AVG_ROW_LENGTH           {}
5799
5810
        | AVG_SYM                  {}
5800
5811
        | BIT_SYM                  {}
5801
 
        | BLOCK_SIZE_SYM           {}
5802
 
        | BLOCK_SYM                {}
5803
5812
        | BOOL_SYM                 {}
5804
5813
        | BOOLEAN_SYM              {}
5805
5814
        | BTREE_SYM                {}