~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2009-01-23 02:15:04 UTC
  • mfrom: (798.2.32 drizzle)
  • Revision ID: brian@tangent.org-20090123021504-2j99e6hxab1ew601
Merge for replication removal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
658
658
%token  LOOP_SYM
659
659
%token  LOW_PRIORITY
660
660
%token  LT                            /* OPERATOR */
661
 
%token  MASTER_CONNECT_RETRY_SYM
662
 
%token  MASTER_HOST_SYM
663
661
%token  MASTER_LOG_FILE_SYM
664
662
%token  MASTER_LOG_POS_SYM
665
 
%token  MASTER_PASSWORD_SYM
666
663
%token  MASTER_PORT_SYM
667
664
%token  MASTER_SERVER_ID_SYM
668
665
%token  MASTER_SYM
669
 
%token  MASTER_USER_SYM
670
 
%token  MASTER_HEARTBEAT_PERIOD_SYM
671
666
%token  MATCH                         /* SQL-2003-R */
672
667
%token  MAX_CONNECTIONS_PER_HOUR
673
668
%token  MAX_QUERIES_PER_HOUR
820
815
%token  SQL_CALC_FOUND_ROWS
821
816
%token  SQL_SMALL_RESULT
822
817
%token  SQL_SYM                       /* SQL-2003-R */
823
 
%token  SQL_THREAD
824
818
%token  STARTING
825
819
%token  STARTS_SYM
826
820
%token  START_SYM                     /* SQL-2003-R */
1053
1047
%type <build_method> build_method
1054
1048
 
1055
1049
%type <NONE>
1056
 
        query verb_clause create change select drop insert replace insert2
 
1050
        query verb_clause create select drop insert replace insert2
1057
1051
        insert_values update delete truncate rename
1058
1052
        show describe load alter optimize keycache flush
1059
 
        reset purge begin commit rollback savepoint release
1060
 
        slave master_def master_defs master_file_def slave_until_opts
 
1053
        begin commit rollback savepoint release
1061
1054
        repair analyze check start checksum
1062
1055
        field_list field_list_item field_spec kill column_def key_def
1063
1056
        keycache_list assign_to_keycache
1082
1075
        opt_extended_describe
1083
1076
        statement
1084
1077
        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
1085
 
        binlog_base64_event
1086
1078
        init_key_options key_options key_opts key_opt key_using_alg
1087
1079
        parse_vcol_expr vcol_opt_attribute vcol_opt_attribute_list
1088
1080
        vcol_attribute
1145
1137
statement:
1146
1138
          alter
1147
1139
        | analyze
1148
 
        | binlog_base64_event
1149
 
        | change
1150
1140
        | check
1151
1141
        | checksum
1152
1142
        | commit
1162
1152
        | optimize
1163
1153
        | keycache
1164
1154
        | parse_vcol_expr
1165
 
        | purge
1166
1155
        | release
1167
1156
        | rename
1168
1157
        | repair
1169
1158
        | replace
1170
 
        | reset
1171
1159
        | rollback
1172
1160
        | savepoint
1173
1161
        | select
1174
1162
        | set
1175
1163
        | show
1176
 
        | slave
1177
1164
        | start
1178
1165
        | truncate
1179
1166
        | unlock
1181
1168
        | use
1182
1169
        ;
1183
1170
 
1184
 
 
1185
 
/* change master */
1186
 
 
1187
 
change:
1188
 
          CHANGE MASTER_SYM TO_SYM
1189
 
          {
1190
 
            LEX *lex = Lex;
1191
 
            lex->sql_command = SQLCOM_CHANGE_MASTER;
1192
 
            memset(&lex->mi, 0, sizeof(lex->mi));
1193
 
          }
1194
 
          master_defs
1195
 
          {}
1196
 
        ;
1197
 
 
1198
 
master_defs:
1199
 
          master_def
1200
 
        | master_defs ',' master_def
1201
 
        ;
1202
 
 
1203
 
master_def:
1204
 
          MASTER_HOST_SYM EQ TEXT_STRING_sys
1205
 
          {
1206
 
            Lex->mi.host = $3.str;
1207
 
          }
1208
 
        | MASTER_USER_SYM EQ TEXT_STRING_sys
1209
 
          {
1210
 
            Lex->mi.user = $3.str;
1211
 
          }
1212
 
        | MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
1213
 
          {
1214
 
            Lex->mi.password = $3.str;
1215
 
          }
1216
 
        | MASTER_PORT_SYM EQ ulong_num
1217
 
          {
1218
 
            Lex->mi.port = $3;
1219
 
          }
1220
 
        | MASTER_CONNECT_RETRY_SYM EQ ulong_num
1221
 
          {
1222
 
            Lex->mi.connect_retry = $3;
1223
 
          }
1224
 
        | MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
1225
 
          {
1226
 
            Lex->mi.heartbeat_period= (float) $3->val_real();
1227
 
            if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
1228
 
                Lex->mi.heartbeat_period < 0.0)
1229
 
            {
1230
 
              char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1231
 
              sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
1232
 
              my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1233
 
                       MYF(0),
1234
 
                       " is negative or exceeds the maximum ",
1235
 
                       buf); 
1236
 
              DRIZZLE_YYABORT;
1237
 
            }
1238
 
            if (Lex->mi.heartbeat_period > slave_net_timeout)
1239
 
            {
1240
 
              push_warning_printf(YYSession, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1241
 
                                  ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1242
 
                                  ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1243
 
                                  " exceeds the value of `slave_net_timeout' sec.",
1244
 
                                  " A sensible value for the period should be"
1245
 
                                  " less than the timeout.");
1246
 
            }
1247
 
            if (Lex->mi.heartbeat_period < 0.001)
1248
 
            {
1249
 
              if (Lex->mi.heartbeat_period != 0.0)
1250
 
              {
1251
 
                push_warning_printf(YYSession, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1252
 
                                    ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1253
 
                                    ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1254
 
                                    " is less than 1 msec.",
1255
 
                                    " The period is reset to zero which means"
1256
 
                                    " no heartbeats will be sending");
1257
 
                Lex->mi.heartbeat_period= 0.0;
1258
 
              }
1259
 
              Lex->mi.heartbeat_opt=  LEX_MASTER_INFO::LEX_MI_DISABLE;
1260
 
            }
1261
 
            Lex->mi.heartbeat_opt=  LEX_MASTER_INFO::LEX_MI_ENABLE;
1262
 
          }
1263
 
        |
1264
 
        master_file_def
1265
 
        ;
1266
 
 
1267
 
master_file_def:
1268
 
          MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
1269
 
          {
1270
 
            Lex->mi.log_file_name = $3.str;
1271
 
          }
1272
 
        | MASTER_LOG_POS_SYM EQ ulonglong_num
1273
 
          {
1274
 
            Lex->mi.pos = $3;
1275
 
            /* 
1276
 
               If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it
1277
 
               instead of causing subsequent errors. 
1278
 
               We need to do it in this file, because only there we know that 
1279
 
               MASTER_LOG_POS has been explicitely specified. On the contrary
1280
 
               in change_master() (sql_repl.cc) we cannot distinguish between 0
1281
 
               (MASTER_LOG_POS explicitely specified as 0) and 0 (unspecified),
1282
 
               whereas we want to distinguish (specified 0 means "read the binlog
1283
 
               from 0" (4 in fact), unspecified means "don't change the position
1284
 
               (keep the preceding value)").
1285
 
            */
1286
 
            Lex->mi.pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1287
 
          }
1288
 
        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1289
 
          {
1290
 
            Lex->mi.relay_log_name = $3.str;
1291
 
          }
1292
 
        | RELAY_LOG_POS_SYM EQ ulong_num
1293
 
          {
1294
 
            Lex->mi.relay_log_pos = $3;
1295
 
            /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
1296
 
            Lex->mi.relay_log_pos = cmax((uint32_t)BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
1297
 
          }
1298
 
        ;
1299
 
 
1300
1171
/* create a table */
1301
1172
 
1302
1173
create:
2590
2461
        | AS {}
2591
2462
        ;
2592
2463
 
2593
 
/*
2594
 
  SLAVE START and SLAVE STOP are deprecated. We keep them for compatibility.
2595
 
*/
2596
 
 
2597
 
slave:
2598
 
          START_SYM SLAVE slave_thread_opts
2599
 
          {
2600
 
            LEX *lex=Lex;
2601
 
            lex->sql_command = SQLCOM_SLAVE_START;
2602
 
            lex->type = 0;
2603
 
            /* We'll use mi structure for UNTIL options */
2604
 
            memset(&lex->mi, 0, sizeof(lex->mi));
2605
 
            /* If you change this code don't forget to update SLAVE START too */
2606
 
          }
2607
 
          slave_until
2608
 
          {}
2609
 
        | STOP_SYM SLAVE slave_thread_opts
2610
 
          {
2611
 
            LEX *lex=Lex;
2612
 
            lex->sql_command = SQLCOM_SLAVE_STOP;
2613
 
            lex->type = 0;
2614
 
            /* If you change this code don't forget to update SLAVE STOP too */
2615
 
          }
2616
 
        | SLAVE START_SYM slave_thread_opts
2617
 
          {
2618
 
            LEX *lex=Lex;
2619
 
            lex->sql_command = SQLCOM_SLAVE_START;
2620
 
            lex->type = 0;
2621
 
            /* We'll use mi structure for UNTIL options */
2622
 
            memset(&lex->mi, 0, sizeof(lex->mi));
2623
 
          }
2624
 
          slave_until
2625
 
          {}
2626
 
        | SLAVE STOP_SYM slave_thread_opts
2627
 
          {
2628
 
            LEX *lex=Lex;
2629
 
            lex->sql_command = SQLCOM_SLAVE_STOP;
2630
 
            lex->type = 0;
2631
 
          }
2632
 
        ;
2633
 
 
2634
2464
start:
2635
2465
          START_SYM TRANSACTION_SYM start_transaction_opts
2636
2466
          {
2648
2478
          }
2649
2479
        ;
2650
2480
 
2651
 
slave_thread_opts:
2652
 
          { Lex->slave_session_opt= 0; }
2653
 
          slave_thread_opt_list
2654
 
          {}
2655
 
        ;
2656
 
 
2657
 
slave_thread_opt_list:
2658
 
          slave_thread_opt
2659
 
        | slave_thread_opt_list ',' slave_thread_opt
2660
 
        ;
2661
 
 
2662
 
slave_thread_opt:
2663
 
          /*empty*/ {}
2664
 
        | SQL_THREAD   { Lex->slave_session_opt|=SLAVE_SQL; }
2665
 
        | RELAY_THREAD { Lex->slave_session_opt|=SLAVE_IO; }
2666
 
        ;
2667
 
 
2668
 
slave_until:
2669
 
          /*empty*/ {}
2670
 
        | UNTIL_SYM slave_until_opts
2671
 
          {
2672
 
            LEX *lex=Lex;
2673
 
            if (((lex->mi.log_file_name || lex->mi.pos) && (lex->mi.relay_log_name || lex->mi.relay_log_pos)) ||
2674
 
                !((lex->mi.log_file_name && lex->mi.pos) ||
2675
 
                  (lex->mi.relay_log_name && lex->mi.relay_log_pos)))
2676
 
            {
2677
 
               my_message(ER_BAD_SLAVE_UNTIL_COND,
2678
 
                          ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
2679
 
               DRIZZLE_YYABORT;
2680
 
            }
2681
 
          }
2682
 
        ;
2683
 
 
2684
 
slave_until_opts:
2685
 
          master_file_def
2686
 
        | slave_until_opts ',' master_file_def
2687
 
        ;
2688
2481
 
2689
2482
checksum:
2690
2483
          CHECKSUM_SYM table_or_tables
2740
2533
          {}
2741
2534
        ;
2742
2535
 
2743
 
binlog_base64_event:
2744
 
          BINLOG_SYM TEXT_STRING_sys
2745
 
          {
2746
 
            Lex->sql_command = SQLCOM_BINLOG_BASE64_EVENT;
2747
 
            Lex->comment= $2;
2748
 
          }
2749
 
        ;
2750
 
 
2751
2536
check:
2752
2537
          CHECK_SYM table_or_tables
2753
2538
          {
4262
4047
          {
4263
4048
            LEX *lex= Lex;
4264
4049
            lex->derived_tables|= DERIVED_SUBQUERY;
4265
 
            if (!lex->expr_allows_subselect ||
4266
 
                lex->sql_command == (int)SQLCOM_PURGE)
 
4050
            if (!lex->expr_allows_subselect)
4267
4051
            {
4268
4052
              my_parse_error(ER(ER_SYNTAX_ERROR));
4269
4053
              DRIZZLE_YYABORT;
5254
5038
            if (prepare_schema_table(YYSession, lex, $4, SCH_COLUMNS))
5255
5039
              DRIZZLE_YYABORT;
5256
5040
          }
5257
 
        | master_or_binary LOGS_SYM
5258
 
          {
5259
 
            Lex->sql_command = SQLCOM_SHOW_BINLOGS;
5260
 
          }
5261
5041
        | keys_or_index from_or_in table_ident opt_db where_clause
5262
5042
          {
5263
5043
            LEX *lex= Lex;
5306
5086
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
5307
5087
              DRIZZLE_YYABORT;
5308
5088
          }
5309
 
        | MASTER_SYM STATUS_SYM
5310
 
          {
5311
 
            Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
5312
 
          }
5313
 
        | SLAVE STATUS_SYM
5314
 
          {
5315
 
            Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
5316
 
          }
5317
 
 
5318
 
master_or_binary:
5319
 
          MASTER_SYM
5320
 
        | BINARY
5321
 
        ;
5322
5089
 
5323
5090
opt_db:
5324
5091
          /* empty */  { $$= 0; }
5414
5181
          opt_table_list {}
5415
5182
        | TABLES WITH READ_SYM LOCK_SYM
5416
5183
          { Lex->type|= REFRESH_TABLES | REFRESH_READ_LOCK; }
5417
 
        | QUERY_SYM CACHE_SYM
5418
 
          { Lex->type|= REFRESH_QUERY_CACHE_FREE; }
5419
5184
        | HOSTS_SYM
5420
5185
          { Lex->type|= REFRESH_HOSTS; }
5421
5186
        | LOGS_SYM
5422
5187
          { Lex->type|= REFRESH_LOG; }
5423
5188
        | STATUS_SYM
5424
5189
          { Lex->type|= REFRESH_STATUS; }
5425
 
        | SLAVE
5426
 
          { Lex->type|= REFRESH_SLAVE; }
5427
 
        | MASTER_SYM
5428
 
          { Lex->type|= REFRESH_MASTER; }
5429
 
        | RESOURCES
5430
 
          { Lex->type|= REFRESH_USER_RESOURCES; }
5431
5190
        ;
5432
5191
 
5433
5192
opt_table_list:
5435
5194
        | table_list {}
5436
5195
        ;
5437
5196
 
5438
 
reset:
5439
 
          RESET_SYM
5440
 
          {
5441
 
            LEX *lex=Lex;
5442
 
            lex->sql_command= SQLCOM_RESET; lex->type=0;
5443
 
          }
5444
 
          reset_options
5445
 
          {}
5446
 
        ;
5447
 
 
5448
 
reset_options:
5449
 
          reset_options ',' reset_option
5450
 
        | reset_option
5451
 
        ;
5452
 
 
5453
 
reset_option:
5454
 
          SLAVE               { Lex->type|= REFRESH_SLAVE; }
5455
 
        | MASTER_SYM          { Lex->type|= REFRESH_MASTER; }
5456
 
        | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
5457
 
        ;
5458
 
 
5459
 
purge:
5460
 
          PURGE
5461
 
          {
5462
 
            LEX *lex=Lex;
5463
 
            lex->type=0;
5464
 
            lex->sql_command = SQLCOM_PURGE;
5465
 
          }
5466
 
          purge_options
5467
 
          {}
5468
 
        ;
5469
 
 
5470
 
purge_options:
5471
 
          master_or_binary LOGS_SYM purge_option
5472
 
        ;
5473
 
 
5474
 
purge_option:
5475
 
          TO_SYM TEXT_STRING_sys
5476
 
          {
5477
 
            Lex->to_log = $2.str;
5478
 
          }
5479
 
        | BEFORE_SYM expr
5480
 
          {
5481
 
            LEX *lex= Lex;
5482
 
            lex->value_list.empty();
5483
 
            lex->value_list.push_front($2);
5484
 
            lex->sql_command= SQLCOM_PURGE_BEFORE;
5485
 
          }
5486
 
        ;
5487
 
 
5488
5197
/* kill threads */
5489
5198
 
5490
5199
kill:
6235
5944
        | LOGS_SYM                 {}
6236
5945
        | MAX_ROWS                 {}
6237
5946
        | MASTER_SYM               {}
6238
 
        | MASTER_HOST_SYM          {}
6239
5947
        | MASTER_PORT_SYM          {}
6240
5948
        | MASTER_LOG_FILE_SYM      {}
6241
5949
        | MASTER_LOG_POS_SYM       {}
6242
 
        | MASTER_USER_SYM          {}
6243
 
        | MASTER_PASSWORD_SYM      {}
6244
5950
        | MASTER_SERVER_ID_SYM     {}
6245
 
        | MASTER_CONNECT_RETRY_SYM {}
6246
5951
        | MAX_CONNECTIONS_PER_HOUR {}
6247
5952
        | MAX_QUERIES_PER_HOUR     {}
6248
5953
        | MAX_SIZE_SYM             {}
6318
6023
        | SNAPSHOT_SYM             {}
6319
6024
        | SOURCE_SYM               {}
6320
6025
        | SQL_BUFFER_RESULT        {}
6321
 
        | SQL_THREAD               {}
6322
6026
        | STARTS_SYM               {}
6323
6027
        | STATUS_SYM               {}
6324
6028
        | STORAGE_SYM              {}
6801
6505
subselect_start:
6802
6506
          {
6803
6507
            LEX *lex=Lex;
6804
 
            if (!lex->expr_allows_subselect ||
6805
 
               lex->sql_command == (int)SQLCOM_PURGE)
 
6508
            if (!lex->expr_allows_subselect)
6806
6509
            {
6807
6510
              my_parse_error(ER(ER_SYNTAX_ERROR));
6808
6511
              DRIZZLE_YYABORT;