~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_yacc.yy

  • Committer: Monty Taylor
  • Date: 2008-07-15 21:40:58 UTC
  • mfrom: (77.1.113 codestyle32)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: mordred@camelot-20080715214058-rm3phulldos9xehv
Merged from codestyle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define YYENABLE_NLS 0
33
33
#define YYLTYPE_IS_TRIVIAL 0
34
34
 
35
 
#define DRIZZLE_YACC
 
35
#define MYSQL_YACC
36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200                        /* Because of 64K stack */
38
38
#define Lex (YYTHD->lex)
39
39
#define Select Lex->current_select
40
 
#include <drizzled/server_includes.h>
 
40
#include "mysql_priv.h"
 
41
#include "slave.h"
41
42
#include "lex_symbol.h"
42
 
#include <storage/myisam/myisam.h>
43
 
#include <drizzled/drizzled_error_messages.h>
 
43
#include "item_create.h"
 
44
#include <myisam.h>
44
45
 
45
46
int yylex(void *yylval, void *yythd);
46
47
 
58
59
    }                                         \
59
60
  }
60
61
 
61
 
#define DRIZZLE_YYABORT                         \
 
62
#define MYSQL_YYABORT                         \
62
63
  do                                          \
63
64
  {                                           \
64
65
    LEX::cleanup_lex_after_parse_error(YYTHD);\
65
66
    YYABORT;                                  \
66
67
  } while (0)
67
68
 
68
 
#define DRIZZLE_YYABORT_UNLESS(A)         \
 
69
#define MYSQL_YYABORT_UNLESS(A)         \
69
70
  if (!(A))                             \
70
71
  {                                     \
71
72
    my_parse_error(ER(ER_SYNTAX_ERROR));\
72
 
    DRIZZLE_YYABORT;                      \
 
73
    MYSQL_YYABORT;                      \
73
74
  }
74
75
 
75
76
/*
127
128
  condition occurs. This function is not invoked when the
128
129
  parser is requested to abort by semantic action code
129
130
  by means of YYABORT or YYACCEPT macros. This is why these
130
 
  macros should not be used (use DRIZZLE_YYABORT/DRIZZLE_YYACCEPT
 
131
  macros should not be used (use MYSQL_YYABORT/MYSQL_YYACCEPT
131
132
  instead).
132
133
 
133
134
  The parser will abort immediately after invoking this callback.
135
136
  This function is not for use in semantic actions and is internal to
136
137
  the parser, as it performs some pre-return cleanup. 
137
138
  In semantic actions, please use my_parse_error or my_error to
138
 
  push an error into the error stack and DRIZZLE_YYABORT
 
139
  push an error into the error stack and MYSQL_YYABORT
139
140
  to abort from the parser.
140
141
*/
141
142
 
323
324
  List<String> *string_list;
324
325
  String *string;
325
326
  Key_part_spec *key_part;
326
 
  TableList *table_list;
 
327
  TABLE_LIST *table_list;
327
328
  udf_func *udf;
328
329
  LEX_USER *lex_user;
329
330
  struct sys_var_with_base variable;
337
338
  enum enum_tx_isolation tx_isolation;
338
339
  enum Cast_target cast_type;
339
340
  enum ha_choice choice;
340
 
  const CHARSET_INFO *charset;
 
341
  CHARSET_INFO *charset;
341
342
  thr_lock_type lock_type;
342
343
  struct st_table_lock_info table_lock_info;
343
344
  interval_type interval, interval_time_st;
344
 
  enum enum_drizzle_timestamp_type date_time_type;
 
345
  timestamp_type date_time_type;
345
346
  st_select_lex *select_lex;
346
347
  chooser_compare_func_creator boolfunc2creator;
347
348
  struct sp_cond_type *spcondtype;
360
361
 
361
362
%pure_parser                                    /* We have threads */
362
363
/*
363
 
  Currently there are 93 shift/reduce conflicts.
 
364
  Currently there are 100 shift/reduce conflicts.
364
365
  We should not introduce new conflicts any more.
365
366
*/
366
 
%expect 93
 
367
%expect 100
367
368
 
368
369
/*
369
370
   Comments for TOKENS.
393
394
%token  ALL                           /* SQL-2003-R */
394
395
%token  ALTER                         /* SQL-2003-R */
395
396
%token  ANALYZE_SYM
 
397
%token  AND_AND_SYM                   /* OPERATOR */
396
398
%token  AND_SYM                       /* SQL-2003-R */
397
399
%token  ANY_SYM                       /* SQL-2003-R */
398
400
%token  AS                            /* SQL-2003-R */
412
414
%token  BINARY                        /* SQL-2003-R */
413
415
%token  BINLOG_SYM
414
416
%token  BIN_NUM
 
417
%token  BIT_AND                       /* MYSQL-FUNC */
 
418
%token  BIT_OR                        /* MYSQL-FUNC */
415
419
%token  BIT_SYM                       /* MYSQL-FUNC */
 
420
%token  BIT_XOR                       /* MYSQL-FUNC */
416
421
%token  BLOB_SYM                      /* SQL-2003-R */
417
 
%token  BLOCK_SIZE_SYM
418
422
%token  BLOCK_SYM
419
423
%token  BOOLEAN_SYM                   /* SQL-2003-R */
420
424
%token  BOOL_SYM
435
439
%token  CHAR_SYM                      /* SQL-2003-R */
436
440
%token  CHECKSUM_SYM
437
441
%token  CHECK_SYM                     /* SQL-2003-R */
 
442
%token  CIPHER_SYM
 
443
%token  CLIENT_SYM
438
444
%token  CLOSE_SYM                     /* SQL-2003-R */
439
445
%token  COALESCE                      /* SQL-2003-N */
 
446
%token  CODE_SYM
440
447
%token  COLLATE_SYM                   /* SQL-2003-R */
441
448
%token  COLLATION_SYM                 /* SQL-2003-N */
442
449
%token  COLUMNS
455
462
%token  CONTAINS_SYM                  /* SQL-2003-N */
456
463
%token  CONTEXT_SYM
457
464
%token  CONTINUE_SYM                  /* SQL-2003-R */
 
465
%token  CONTRIBUTORS_SYM
458
466
%token  CONVERT_SYM                   /* SQL-2003-N */
459
467
%token  COUNT_SYM                     /* SQL-2003-N */
 
468
%token  CPU_SYM
460
469
%token  CREATE                        /* SQL-2003-R */
461
470
%token  CROSS                         /* SQL-2003-R */
462
471
%token  CUBE_SYM                      /* SQL-2003-R */
482
491
%token  DECIMAL_SYM                   /* SQL-2003-R */
483
492
%token  DECLARE_SYM                   /* SQL-2003-R */
484
493
%token  DEFAULT                       /* SQL-2003-R */
 
494
%token  DEFINER_SYM
485
495
%token  DELAYED_SYM
486
496
%token  DELAY_KEY_WRITE_SYM
487
497
%token  DELETE_SYM                    /* SQL-2003-R */
488
498
%token  DESC                          /* SQL-2003-N */
489
499
%token  DESCRIBE                      /* SQL-2003-R */
 
500
%token  DES_KEY_FILE
490
501
%token  DETERMINISTIC_SYM             /* SQL-2003-R */
491
502
%token  DIRECTORY_SYM
492
503
%token  DISABLE_SYM
506
517
%token  END                           /* SQL-2003-R */
507
518
%token  ENDS_SYM
508
519
%token  END_OF_INPUT                  /* INTERNAL */
 
520
%token  ENGINES_SYM
509
521
%token  ENGINE_SYM
510
522
%token  ENUM
511
523
%token  EQ                            /* OPERATOR */
513
525
%token  ERRORS
514
526
%token  ESCAPED
515
527
%token  ESCAPE_SYM                    /* SQL-2003-R */
 
528
%token  EVENTS_SYM
 
529
%token  EVERY_SYM                     /* SQL-2003-N */
516
530
%token  EXCLUSIVE_SYM
517
531
%token  EXISTS                        /* SQL-2003-R */
518
532
%token  EXIT_SYM
573
587
%token  INTO                          /* SQL-2003-R */
574
588
%token  INT_SYM                       /* SQL-2003-R */
575
589
%token  IN_SYM                        /* SQL-2003-R */
 
590
%token  IO_SYM
 
591
%token  IPC_SYM
576
592
%token  IS                            /* SQL-2003-R */
577
593
%token  ISOLATION                     /* SQL-2003-R */
 
594
%token  ISSUER_SYM
578
595
%token  ITERATE_SYM
579
596
%token  JOIN_SYM                      /* SQL-2003-R */
580
597
%token  KEYS
643
660
%token  NAME_SYM                      /* SQL-2003-N */
644
661
%token  NATIONAL_SYM                  /* SQL-2003-R */
645
662
%token  NATURAL                       /* SQL-2003-R */
 
663
%token  NCHAR_STRING
 
664
%token  NCHAR_SYM                     /* SQL-2003-R */
646
665
%token  NE                            /* OPERATOR */
647
666
%token  NEG
648
667
%token  NEW_SYM                       /* SQL-2003-R */
658
677
%token  NULL_SYM                      /* SQL-2003-R */
659
678
%token  NUM
660
679
%token  NUMERIC_SYM                   /* SQL-2003-R */
 
680
%token  NVARCHAR_SYM
661
681
%token  OFFLINE_SYM
662
682
%token  OFFSET_SYM
663
683
%token  ON                            /* SQL-2003-R */
678
698
%token  PAGE_SYM
679
699
%token  PAGE_CHECKSUM_SYM
680
700
%token  PARAM_MARKER
681
 
%token  PARSE_VCOL_EXPR_SYM
682
701
%token  PARTIAL                       /* SQL-2003-N */
 
702
%token  PASSWORD
683
703
%token  PHASE_SYM
684
704
%token  PLUGINS_SYM
685
705
%token  PLUGIN_SYM
686
706
%token  POINT_SYM
 
707
%token  POLYGON
687
708
%token  PORT_SYM
688
709
%token  POSITION_SYM                  /* SQL-2003-N */
689
710
%token  PRECISION                     /* SQL-2003-R */
691
712
%token  PRIMARY_SYM                   /* SQL-2003-R */
692
713
%token  PROCESS
693
714
%token  PROCESSLIST_SYM
 
715
%token  PROFILE_SYM
 
716
%token  PROFILES_SYM
694
717
%token  PURGE
695
718
%token  QUARTER_SYM
696
719
%token  QUERY_SYM
751
774
%token  SET                           /* SQL-2003-R */
752
775
%token  SET_VAR
753
776
%token  SHARE_SYM
 
777
%token  SHIFT_LEFT                    /* OPERATOR */
 
778
%token  SHIFT_RIGHT                   /* OPERATOR */
754
779
%token  SHOW
755
780
%token  SHUTDOWN
 
781
%token  SIGNED_SYM
756
782
%token  SIMPLE_SYM                    /* SQL-2003-N */
757
783
%token  SLAVE
 
784
%token  SMALLINT                      /* SQL-2003-R */
758
785
%token  SNAPSHOT_SYM
759
786
%token  SOCKET_SYM
760
787
%token  SONAME_SYM
777
804
%token  STD_SYM
778
805
%token  STOP_SYM
779
806
%token  STORAGE_SYM
780
 
%token  STORED_SYM
781
807
%token  STRAIGHT_JOIN
782
808
%token  STRING_SYM
783
809
%token  SUBDATE_SYM
805
831
%token  TIMESTAMP_ADD
806
832
%token  TIMESTAMP_DIFF
807
833
%token  TIME_SYM                      /* SQL-2003-R */
 
834
%token  TINYINT
808
835
%token  TO_SYM                        /* SQL-2003-R */
809
836
%token  TRAILING                      /* SQL-2003-R */
810
837
%token  TRANSACTION_SYM
820
847
%token  UNDERSCORE_CHARSET
821
848
%token  UNDOFILE_SYM
822
849
%token  UNDO_SYM                      /* FUTURE-USE */
 
850
%token  UNICODE_SYM
 
851
%token  UNINSTALL_SYM
823
852
%token  UNION_SYM                     /* SQL-2003-R */
824
853
%token  UNIQUE_SYM
825
854
%token  UNKNOWN_SYM                   /* SQL-2003-R */
826
855
%token  UNLOCK_SYM
 
856
%token  UNSIGNED
827
857
%token  UNTIL_SYM
828
858
%token  UPDATE_SYM                    /* SQL-2003-R */
829
859
%token  UPGRADE_SYM
843
873
%token  VARIANCE_SYM
844
874
%token  VARYING                       /* SQL-2003-R */
845
875
%token  VAR_SAMP_SYM
846
 
%token  VIRTUAL_SYM
847
876
%token  WAIT_SYM
848
877
%token  WARNINGS
849
878
%token  WEEK_SYM
851
880
%token  WHEN_SYM                      /* SQL-2003-R */
852
881
%token  WHERE                         /* SQL-2003-R */
853
882
%token  WITH                          /* SQL-2003-R */
 
883
%token  WITH_CUBE_SYM                 /* INTERNAL */
854
884
%token  WITH_ROLLUP_SYM               /* INTERNAL */
855
885
%token  WORK_SYM                      /* SQL-2003-N */
 
886
%token  WRAPPER_SYM
856
887
%token  WRITE_SYM                     /* SQL-2003-N */
 
888
%token  XML_SYM
857
889
%token  XOR
858
890
%token  YEAR_MONTH_SYM
859
891
%token  YEAR_SYM                      /* SQL-2003-R */
 
892
%token  ZEROFILL
860
893
 
861
894
%left   JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT
862
895
/* A dummy token to force the priority of table_ref production in a join. */
864
897
%left   SET_VAR
865
898
%left   OR_SYM
866
899
%left   XOR
867
 
%left   AND_SYM
 
900
%left   AND_SYM AND_AND_SYM
868
901
%left   BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
869
902
%left   EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE IN_SYM
 
903
%left   '|'
 
904
%left   '&'
 
905
%left   SHIFT_LEFT SHIFT_RIGHT
870
906
%left   '-' '+'
871
907
%left   '*' '/' '%' DIV_SYM MOD_SYM
872
 
%left   NEG
 
908
%left   '^'
 
909
%left   NEG '~'
873
910
%right  NOT_SYM
874
911
%right  BINARY COLLATE_SYM
875
912
%left  INTERVAL_SYM
878
915
        IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
879
916
        LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text
880
917
        IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
881
 
        opt_component key_cache_name
 
918
        NCHAR_STRING opt_component key_cache_name
882
919
        BIN_NUM TEXT_STRING_filesystem ident_or_empty
883
920
        opt_constraint constraint opt_ident
884
921
 
895
932
        text_string opt_gconcat_separator
896
933
 
897
934
%type <num>
898
 
        type int_type real_type order_dir field_def
 
935
        type int_type real_type order_dir
899
936
        if_exists opt_local opt_table_options table_options
900
 
        table_option opt_if_not_exists
 
937
        table_option opt_if_not_exists opt_no_write_to_binlog
901
938
        opt_temporary all_or_any opt_distinct
902
939
        union_option
903
940
        start_transaction_opts opt_chain opt_release
934
971
        predicate bit_expr
935
972
        table_wild simple_expr udf_expr
936
973
        expr_or_default set_expr_or_default
 
974
        param_marker 
937
975
        signed_literal now_or_signed_literal opt_escape
938
976
        simple_ident_nospvar simple_ident_q
939
977
        field_or_var limit_option
989
1027
%type <symbol> keyword keyword_sp
990
1028
 
991
1029
%type <charset>
 
1030
        opt_collate
 
1031
        charset_name
 
1032
        charset_name_or_default
 
1033
        old_or_new_charset_name
 
1034
        old_or_new_charset_name_or_default
992
1035
        collation_name
993
1036
        collation_name_or_default
 
1037
        opt_load_data_charset
994
1038
        UNDERSCORE_CHARSET
995
1039
 
996
1040
%type <variable> internal_variable_name
1014
1058
        keycache_list assign_to_keycache
1015
1059
        select_item_list select_item values_list no_braces
1016
1060
        opt_limit_clause delete_limit_clause fields opt_values values
1017
 
        opt_precision opt_ignore opt_column
1018
 
        set lock unlock string_list
1019
 
        opt_binary table_lock_list table_lock
 
1061
        opt_precision opt_ignore opt_column opt_restrict
 
1062
        set lock unlock string_list field_options field_option
 
1063
        field_opt_list opt_binary table_lock_list table_lock
1020
1064
        ref_list opt_match_clause opt_on_update_delete use
1021
 
        opt_delete_options opt_delete_option varchar
 
1065
        opt_delete_options opt_delete_option varchar nchar nvarchar
1022
1066
        opt_outer table_list table_name table_alias_ref_list table_alias_ref
1023
1067
        opt_option opt_place
1024
1068
        opt_attribute opt_attribute_list attribute
1035
1079
        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
1036
1080
        binlog_base64_event
1037
1081
        init_key_options key_options key_opts key_opt key_using_alg
1038
 
        parse_vcol_expr vcol_opt_attribute vcol_opt_attribute_list
1039
 
        vcol_attribute
1040
1082
END_OF_INPUT
1041
1083
 
1042
1084
%type <index_hint> index_hint_type
1043
1085
%type <num> index_hint_clause
1044
 
%type <filetype> data_file
 
1086
%type <filetype> data_or_xml
1045
1087
 
1046
1088
%type <NONE>
1047
1089
        '-' '+' '*' '/' '%' '(' ')'
1048
 
        ',' '!' '{' '}' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
1049
 
        THEN_SYM WHEN_SYM DIV_SYM MOD_SYM DELETE_SYM
 
1090
        ',' '!' '{' '}' '&' '|' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
 
1091
        THEN_SYM WHEN_SYM DIV_SYM MOD_SYM AND_AND_SYM DELETE_SYM
1050
1092
%%
1051
1093
 
1052
1094
/*
1074
1116
          END_OF_INPUT
1075
1117
          {
1076
1118
            THD *thd= YYTHD;
1077
 
            if (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))
 
1119
            if (!thd->bootstrap &&
 
1120
              (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
1078
1121
            {
1079
1122
              my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
1080
 
              DRIZZLE_YYABORT;
 
1123
              MYSQL_YYABORT;
1081
1124
            }
1082
1125
            else
1083
1126
            {
1112
1155
        | lock
1113
1156
        | optimize
1114
1157
        | keycache
1115
 
        | parse_vcol_expr
1116
1158
        | purge
1117
1159
        | release
1118
1160
        | rename
1140
1182
          {
1141
1183
            LEX *lex = Lex;
1142
1184
            lex->sql_command = SQLCOM_CHANGE_MASTER;
1143
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
1185
            bzero((char*) &lex->mi, sizeof(lex->mi));
1144
1186
          }
1145
1187
          master_defs
1146
1188
          {}
1179
1221
                Lex->mi.heartbeat_period < 0.0)
1180
1222
            {
1181
1223
              char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1182
 
              sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
 
1224
              my_sprintf(buf, (buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD));
1183
1225
              my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1184
1226
                       MYF(0),
1185
1227
                       " is negative or exceeds the maximum ",
1186
1228
                       buf); 
1187
 
              DRIZZLE_YYABORT;
 
1229
              MYSQL_YYABORT;
1188
1230
            }
1189
1231
            if (Lex->mi.heartbeat_period > slave_net_timeout)
1190
1232
            {
1191
 
              push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1233
              push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1192
1234
                                  ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1193
1235
                                  ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1194
1236
                                  " exceeds the value of `slave_net_timeout' sec.",
1199
1241
            {
1200
1242
              if (Lex->mi.heartbeat_period != 0.0)
1201
1243
              {
1202
 
                push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1244
                push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1203
1245
                                    ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1204
1246
                                    ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1205
1247
                                    " is less than 1 msec.",
1234
1276
               from 0" (4 in fact), unspecified means "don't change the position
1235
1277
               (keep the preceding value)").
1236
1278
            */
1237
 
            Lex->mi.pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
 
1279
            Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1238
1280
          }
1239
1281
        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1240
1282
          {
1244
1286
          {
1245
1287
            Lex->mi.relay_log_pos = $3;
1246
1288
            /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
1247
 
            Lex->mi.relay_log_pos = cmax((uint32_t)BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
 
1289
            Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
1248
1290
          }
1249
1291
        ;
1250
1292
 
1259
1301
            if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
1260
1302
                                                   TL_OPTION_UPDATING,
1261
1303
                                                   TL_WRITE))
1262
 
              DRIZZLE_YYABORT;
 
1304
              MYSQL_YYABORT;
1263
1305
            lex->alter_info.reset();
1264
1306
            lex->col_list.empty();
1265
 
            lex->change=NULL;
1266
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
1307
            lex->change=NullS;
 
1308
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
1267
1309
            lex->create_info.options=$2 | $4;
1268
1310
            lex->create_info.db_type= ha_default_handlerton(thd);
1269
1311
            lex->create_info.default_table_charset= NULL;
1277
1319
            if (!lex->create_info.db_type)
1278
1320
            {
1279
1321
              lex->create_info.db_type= ha_default_handlerton(YYTHD);
1280
 
              push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1322
              push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1281
1323
                                  ER_WARN_USING_OTHER_HANDLER,
1282
1324
                                  ER(ER_WARN_USING_OTHER_HANDLER),
1283
1325
                                  ha_resolve_storage_engine_name(lex->create_info.db_type),
1292
1334
            if (!lex->current_select->add_table_to_list(lex->thd, $8,
1293
1335
                                                        NULL,
1294
1336
                                                        TL_OPTION_UPDATING))
1295
 
              DRIZZLE_YYABORT;
 
1337
              MYSQL_YYABORT;
1296
1338
            lex->alter_info.reset();
1297
1339
            lex->alter_info.flags= ALTER_ADD_INDEX;
1298
1340
            lex->alter_info.build_method= $2;
1299
1341
            lex->col_list.empty();
1300
 
            lex->change=NULL;
 
1342
            lex->change=NullS;
1301
1343
          }
1302
1344
          '(' key_list ')' key_options
1303
1345
          {
1333
1375
 
1334
1376
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1335
1377
            if (!lex->select_lex.add_table_to_list(thd, $2, NULL, 0, TL_READ))
1336
 
              DRIZZLE_YYABORT;
 
1378
              MYSQL_YYABORT;
1337
1379
          }
1338
1380
        | '(' LIKE table_ident ')'
1339
1381
          {
1342
1384
 
1343
1385
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1344
1386
            if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0, TL_READ))
1345
 
              DRIZZLE_YYABORT;
 
1387
              MYSQL_YYABORT;
1346
1388
          }
1347
1389
        ;
1348
1390
 
1412
1454
 
1413
1455
create_database_option:
1414
1456
          default_collation {}
 
1457
        | default_charset {}
1415
1458
        ;
1416
1459
 
1417
1460
opt_table_options:
1470
1513
            Lex->create_info.avg_row_length=$3;
1471
1514
            Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1472
1515
          }
1473
 
        | BLOCK_SIZE_SYM opt_equal ulong_num    
1474
 
          { 
1475
 
            Lex->create_info.block_size= $3; 
1476
 
            Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1477
 
          }
1478
1516
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1479
1517
          {
1480
1518
            Lex->create_info.comment=$3;
1496
1534
                break;
1497
1535
            default:
1498
1536
                my_parse_error(ER(ER_SYNTAX_ERROR));
1499
 
                DRIZZLE_YYABORT;
 
1537
                MYSQL_YYABORT;
1500
1538
            }
1501
1539
            Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1502
1540
          }
1532
1570
            Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1533
1571
            Lex->alter_info.flags|= ALTER_ROW_FORMAT;
1534
1572
          }
 
1573
        | UNION_SYM opt_equal '(' opt_table_list ')'
 
1574
          {
 
1575
            /* Move the union list to the merge_list */
 
1576
            LEX *lex=Lex;
 
1577
            TABLE_LIST *table_list= lex->select_lex.get_table_list();
 
1578
            lex->create_info.merge_list= lex->select_lex.table_list;
 
1579
            lex->create_info.merge_list.elements--;
 
1580
            lex->create_info.merge_list.first=
 
1581
              (uchar*) (table_list->next_local);
 
1582
            lex->select_lex.table_list.elements=1;
 
1583
            lex->select_lex.table_list.next=
 
1584
              (uchar**) &(table_list->next_local);
 
1585
            table_list->next_local= 0;
 
1586
            lex->create_info.used_fields|= HA_CREATE_USED_UNION;
 
1587
          }
 
1588
        | default_charset
1535
1589
        | default_collation
1536
1590
        | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1537
1591
          {
1554
1608
            Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1555
1609
            Lex->create_info.key_block_size= $3;
1556
1610
          }
 
1611
        | TRANSACTIONAL_SYM opt_equal choice
 
1612
          {
 
1613
            Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL;
 
1614
            Lex->create_info.transactional= $3;
 
1615
          }
 
1616
        ;
 
1617
 
 
1618
default_charset:
 
1619
          opt_default charset opt_equal charset_name_or_default
 
1620
          {
 
1621
            HA_CREATE_INFO *cinfo= &Lex->create_info;
 
1622
            if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
 
1623
                 cinfo->default_table_charset && $4 &&
 
1624
                 !my_charset_same(cinfo->default_table_charset,$4))
 
1625
            {
 
1626
              my_error(ER_CONFLICTING_DECLARATIONS, MYF(0),
 
1627
                       "CHARACTER SET ", cinfo->default_table_charset->csname,
 
1628
                       "CHARACTER SET ", $4->csname);
 
1629
              MYSQL_YYABORT;
 
1630
            }
 
1631
            Lex->create_info.default_table_charset= $4;
 
1632
            Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
 
1633
          }
1557
1634
        ;
1558
1635
 
1559
1636
default_collation:
1566
1643
              {
1567
1644
                my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1568
1645
                         $4->name, cinfo->default_table_charset->csname);
1569
 
                DRIZZLE_YYABORT;
 
1646
                MYSQL_YYABORT;
1570
1647
              }
1571
1648
              Lex->create_info.default_table_charset= $4;
1572
1649
              Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1583
1660
            else
1584
1661
            {
1585
1662
              my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1586
 
              DRIZZLE_YYABORT;
 
1663
              MYSQL_YYABORT;
1587
1664
            }
1588
1665
          }
1589
1666
        ;
1597
1674
            else
1598
1675
            {
1599
1676
              my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1600
 
              DRIZZLE_YYABORT;
 
1677
              MYSQL_YYABORT;
1601
1678
            }
1602
1679
          }
1603
1680
        ;
1714
1791
            lex->comment=null_lex_str;
1715
1792
            lex->charset=NULL;
1716
1793
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1717
 
            lex->vcol_info= NULL;
1718
1794
          }
1719
 
          field_def
 
1795
          type opt_attribute
1720
1796
          {
1721
1797
            LEX *lex=Lex;
1722
1798
            if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3,
1724
1800
                                  lex->column_format,
1725
1801
                                  lex->default_value, lex->on_update_value, 
1726
1802
                                  &lex->comment,
1727
 
                                  lex->change,&lex->interval_list,lex->charset,
1728
 
                                  lex->vcol_info))
1729
 
              DRIZZLE_YYABORT;
1730
 
          }
1731
 
        ;
1732
 
field_def:
1733
 
          type opt_attribute {}
1734
 
        | VIRTUAL_SYM type AS '(' virtual_column_func ')' vcol_opt_attribute
1735
 
          {
1736
 
            $$=DRIZZLE_TYPE_VIRTUAL;
1737
 
            Lex->vcol_info->set_field_type((enum enum_field_types) $2);
1738
 
          }
1739
 
        ;
1740
 
 
1741
 
vcol_opt_attribute:
1742
 
          /* empty */ {}
1743
 
        | vcol_opt_attribute_list {}
1744
 
        ;
1745
 
 
1746
 
vcol_opt_attribute_list:
1747
 
          vcol_opt_attribute_list vcol_attribute {}
1748
 
        | vcol_attribute
1749
 
        ;
1750
 
 
1751
 
vcol_attribute:
1752
 
          UNIQUE_SYM
1753
 
          {
1754
 
            LEX *lex=Lex;
1755
 
            lex->type|= UNIQUE_FLAG; 
1756
 
            lex->alter_info.flags|= ALTER_ADD_INDEX;
1757
 
          }
1758
 
        | UNIQUE_SYM KEY_SYM
1759
 
          {
1760
 
            LEX *lex=Lex;
1761
 
            lex->type|= UNIQUE_KEY_FLAG; 
1762
 
            lex->alter_info.flags|= ALTER_ADD_INDEX; 
1763
 
          }
1764
 
        | COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1765
 
        | STORED_SYM
1766
 
          {
1767
 
            Lex->vcol_info->set_field_stored(true);
1768
 
          }
1769
 
        ;
1770
 
 
1771
 
parse_vcol_expr:
1772
 
          PARSE_VCOL_EXPR_SYM '(' virtual_column_func ')'
1773
 
          {
1774
 
            /* 
1775
 
              "PARSE_VCOL_EXPR" can only be used by the SQL server
1776
 
              when reading a '*.frm' file.
1777
 
              Prevent the end user from invoking this command.
1778
 
            */
1779
 
            if (not Lex->parse_vcol_expr)
1780
 
            {
1781
 
              my_message(ER_SYNTAX_ERROR, ER(ER_SYNTAX_ERROR), MYF(0));
1782
 
              DRIZZLE_YYABORT;
1783
 
            }
1784
 
          }
1785
 
        ;
1786
 
 
1787
 
virtual_column_func:
1788
 
          remember_name expr remember_end
1789
 
          {
1790
 
            Lex->vcol_info= new virtual_column_info();
1791
 
            if (not Lex->vcol_info)
1792
 
            {
1793
 
              my_error(ER_OUTOFMEMORY, MYF(0), sizeof(virtual_column_info));
1794
 
              DRIZZLE_YYABORT;
1795
 
            }
1796
 
            uint expr_len= (uint)($3 - $1) - 1;
1797
 
            Lex->vcol_info->expr_str.str= (char* ) sql_memdup($1 + 1, expr_len);
1798
 
            Lex->vcol_info->expr_str.length= expr_len;
1799
 
            Lex->vcol_info->expr_item= $2;
 
1803
                                  lex->change,&lex->interval_list,lex->charset))
 
1804
              MYSQL_YYABORT;
1800
1805
          }
1801
1806
        ;
1802
1807
 
1803
1808
type:
1804
 
        int_type
1805
 
        { 
1806
 
          $$=$1; 
1807
 
          Lex->length=(char*) 0; /* use default length */
1808
 
        }
1809
 
        | real_type opt_precision { $$=$1; }
 
1809
          int_type opt_len field_options { $$=$1; }
 
1810
        | real_type opt_precision field_options { $$=$1; }
 
1811
        | BIT_SYM
 
1812
          {
 
1813
            Lex->length= (char*) "1";
 
1814
            $$=FIELD_TYPE_TINY;
 
1815
          }
 
1816
        | BOOL_SYM
 
1817
          {
 
1818
            Lex->length=(char*) "1";
 
1819
            $$=MYSQL_TYPE_TINY;
 
1820
          }
 
1821
        | BOOLEAN_SYM
 
1822
          {
 
1823
            Lex->length=(char*) "1";
 
1824
            $$=MYSQL_TYPE_TINY;
 
1825
          }
1810
1826
        | char '(' NUM ')' opt_binary
1811
1827
          {
1812
1828
            Lex->length=$3.str;
1813
 
            $$=DRIZZLE_TYPE_VARCHAR;
 
1829
            $$=MYSQL_TYPE_STRING;
1814
1830
          }
1815
1831
        | char opt_binary
1816
1832
          {
1817
1833
            Lex->length=(char*) "1";
1818
 
            $$=DRIZZLE_TYPE_VARCHAR;
 
1834
            $$=MYSQL_TYPE_STRING;
 
1835
          }
 
1836
        | nchar '(' NUM ')' opt_bin_mod
 
1837
          {
 
1838
            Lex->length=$3.str;
 
1839
            $$=MYSQL_TYPE_STRING;
 
1840
            Lex->charset=national_charset_info;
 
1841
          }
 
1842
        | nchar opt_bin_mod
 
1843
          {
 
1844
            Lex->length=(char*) "1";
 
1845
            $$=MYSQL_TYPE_STRING;
 
1846
            Lex->charset=national_charset_info;
 
1847
          }
 
1848
        | BINARY '(' NUM ')'
 
1849
          {
 
1850
            Lex->length=$3.str;
 
1851
            Lex->charset=&my_charset_bin;
 
1852
            $$=MYSQL_TYPE_STRING;
 
1853
          }
 
1854
        | BINARY
 
1855
          {
 
1856
            Lex->length= (char*) "1";
 
1857
            Lex->charset=&my_charset_bin;
 
1858
            $$=MYSQL_TYPE_STRING;
1819
1859
          }
1820
1860
        | varchar '(' NUM ')' opt_binary
1821
1861
          {
1822
1862
            Lex->length=$3.str;
1823
 
            $$= DRIZZLE_TYPE_VARCHAR;
 
1863
            $$= MYSQL_TYPE_VARCHAR;
 
1864
          }
 
1865
        | nvarchar '(' NUM ')' opt_bin_mod
 
1866
          {
 
1867
            Lex->length=$3.str;
 
1868
            $$= MYSQL_TYPE_VARCHAR;
 
1869
            Lex->charset=national_charset_info;
1824
1870
          }
1825
1871
        | VARBINARY '(' NUM ')'
1826
1872
          {
1827
1873
            Lex->length=$3.str;
1828
1874
            Lex->charset=&my_charset_bin;
1829
 
            $$= DRIZZLE_TYPE_VARCHAR;
 
1875
            $$= MYSQL_TYPE_VARCHAR;
1830
1876
          }
 
1877
        | YEAR_SYM opt_len field_options
 
1878
          { $$=MYSQL_TYPE_YEAR; }
1831
1879
        | DATE_SYM
1832
 
          { $$=DRIZZLE_TYPE_NEWDATE; }
 
1880
          { $$=MYSQL_TYPE_NEWDATE; }
1833
1881
        | TIME_SYM
1834
 
          { $$=DRIZZLE_TYPE_TIME; }
 
1882
          { $$=MYSQL_TYPE_TIME; }
1835
1883
        | TIMESTAMP
1836
1884
          {
1837
1885
            /* Unlike other types TIMESTAMP fields are NOT NULL by default */
1838
1886
            Lex->type|= NOT_NULL_FLAG;
1839
 
            $$=DRIZZLE_TYPE_TIMESTAMP;
 
1887
            $$=MYSQL_TYPE_TIMESTAMP;
1840
1888
          }
1841
1889
        | DATETIME
1842
 
          { $$=DRIZZLE_TYPE_DATETIME; }
1843
 
        | BLOB_SYM
 
1890
          { $$=MYSQL_TYPE_DATETIME; }
 
1891
        | BLOB_SYM opt_len
1844
1892
          {
1845
1893
            Lex->charset=&my_charset_bin;
1846
 
            $$=DRIZZLE_TYPE_BLOB;
1847
 
            Lex->length=(char*) 0; /* use default length */
1848
 
          }
1849
 
        | TEXT_SYM opt_binary
1850
 
          { 
1851
 
            $$=DRIZZLE_TYPE_BLOB; 
1852
 
            Lex->length=(char*) 0; /* use default length */
1853
 
          }
1854
 
        | DECIMAL_SYM float_options
1855
 
          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
1856
 
        | NUMERIC_SYM float_options
1857
 
          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
1858
 
        | FIXED_SYM float_options
1859
 
          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
 
1894
            $$=MYSQL_TYPE_BLOB;
 
1895
          }
 
1896
        | TEXT_SYM opt_len opt_binary
 
1897
          { $$=MYSQL_TYPE_BLOB; }
 
1898
        | DECIMAL_SYM float_options field_options
 
1899
          { $$=MYSQL_TYPE_NEWDECIMAL;}
 
1900
        | NUMERIC_SYM float_options field_options
 
1901
          { $$=MYSQL_TYPE_NEWDECIMAL;}
 
1902
        | FIXED_SYM float_options field_options
 
1903
          { $$=MYSQL_TYPE_NEWDECIMAL;}
1860
1904
        | ENUM
1861
1905
          {Lex->interval_list.empty();}
1862
1906
          '(' string_list ')' opt_binary
1863
 
          { $$=DRIZZLE_TYPE_ENUM; }
 
1907
          { $$=MYSQL_TYPE_ENUM; }
 
1908
        | SET
 
1909
          { Lex->interval_list.empty();}
 
1910
          '(' string_list ')' opt_binary
 
1911
          { $$=MYSQL_TYPE_SET; }
1864
1912
        | SERIAL_SYM
1865
1913
          {
1866
 
            $$=DRIZZLE_TYPE_LONGLONG;
1867
 
            Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
 
1914
            $$=MYSQL_TYPE_LONGLONG;
 
1915
            Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNSIGNED_FLAG |
 
1916
              UNIQUE_FLAG);
1868
1917
          }
1869
1918
        ;
1870
1919
 
1872
1921
          CHAR_SYM {}
1873
1922
        ;
1874
1923
 
 
1924
nchar:
 
1925
          NCHAR_SYM {}
 
1926
        | NATIONAL_SYM CHAR_SYM {}
 
1927
        ;
 
1928
 
1875
1929
varchar:
1876
1930
          char VARYING {}
1877
1931
        | VARCHAR {}
1878
1932
        ;
1879
1933
 
 
1934
nvarchar:
 
1935
          NATIONAL_SYM VARCHAR {}
 
1936
        | NVARCHAR_SYM {}
 
1937
        | NCHAR_SYM VARCHAR {}
 
1938
        | NATIONAL_SYM CHAR_SYM VARYING {}
 
1939
        | NCHAR_SYM VARYING {}
 
1940
        ;
 
1941
 
1880
1942
int_type:
1881
 
          INT_SYM   { $$=DRIZZLE_TYPE_LONG; }
1882
 
        | BIGINT    { $$=DRIZZLE_TYPE_LONGLONG; }
 
1943
          INT_SYM   { $$=MYSQL_TYPE_LONG; }
 
1944
        | TINYINT   { $$=MYSQL_TYPE_TINY; }
 
1945
        | SMALLINT  { $$=MYSQL_TYPE_SHORT; }
 
1946
        | BIGINT    { $$=MYSQL_TYPE_LONGLONG; }
1883
1947
        ;
1884
1948
 
1885
1949
real_type:
1886
1950
          REAL
1887
1951
          {
1888
 
            $$= DRIZZLE_TYPE_DOUBLE;
 
1952
            $$= MYSQL_TYPE_DOUBLE;
1889
1953
          }
1890
1954
        | DOUBLE_SYM
1891
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
1955
          { $$=MYSQL_TYPE_DOUBLE; }
1892
1956
        | DOUBLE_SYM PRECISION
1893
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
1957
          { $$=MYSQL_TYPE_DOUBLE; }
1894
1958
        ;
1895
1959
 
1896
1960
float_options:
1911
1975
          }
1912
1976
        ;
1913
1977
 
 
1978
field_options:
 
1979
          /* empty */ {}
 
1980
        | field_opt_list {}
 
1981
        ;
 
1982
 
 
1983
field_opt_list:
 
1984
          field_opt_list field_option {}
 
1985
        | field_option {}
 
1986
        ;
 
1987
 
 
1988
field_option:
 
1989
          SIGNED_SYM {}
 
1990
        | UNSIGNED { Lex->type|= UNSIGNED_FLAG;}
 
1991
        | ZEROFILL { Lex->type|= UNSIGNED_FLAG | ZEROFILL_FLAG; }
 
1992
        ;
 
1993
 
1914
1994
opt_len:
1915
1995
          /* empty */ { Lex->length=(char*) 0; /* use default length */ }
1916
1996
        | '(' NUM ')' { Lex->length= $2.str; }
1978
2058
            {
1979
2059
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1980
2060
                       $2->name,Lex->charset->csname);
1981
 
              DRIZZLE_YYABORT;
 
2061
              MYSQL_YYABORT;
1982
2062
            }
1983
2063
            else
1984
2064
            {
1999
2079
        | CHARSET {}
2000
2080
        ;
2001
2081
 
 
2082
charset_name:
 
2083
          ident_or_text
 
2084
          {
 
2085
            if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))))
 
2086
            {
 
2087
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str);
 
2088
              MYSQL_YYABORT;
 
2089
            }
 
2090
          }
 
2091
        | BINARY { $$= &my_charset_bin; }
 
2092
        ;
 
2093
 
 
2094
charset_name_or_default:
 
2095
          charset_name { $$=$1;   }
 
2096
        | DEFAULT    { $$=NULL; }
 
2097
        ;
 
2098
 
 
2099
opt_load_data_charset:
 
2100
          /* Empty */ { $$= NULL; }
 
2101
        | charset charset_name_or_default { $$= $2; }
 
2102
        ;
 
2103
 
 
2104
old_or_new_charset_name:
 
2105
          ident_or_text
 
2106
          {
 
2107
            if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) &&
 
2108
                !($$=get_old_charset_by_name($1.str)))
 
2109
            {
 
2110
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str);
 
2111
              MYSQL_YYABORT;
 
2112
            }
 
2113
          }
 
2114
        | BINARY { $$= &my_charset_bin; }
 
2115
        ;
 
2116
 
 
2117
old_or_new_charset_name_or_default:
 
2118
          old_or_new_charset_name { $$=$1;   }
 
2119
        | DEFAULT    { $$=NULL; }
 
2120
        ;
 
2121
 
2002
2122
collation_name:
2003
2123
          ident_or_text
2004
2124
          {
2005
2125
            if (!($$=get_charset_by_name($1.str,MYF(0))))
2006
2126
            {
2007
2127
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str);
2008
 
              DRIZZLE_YYABORT;
 
2128
              MYSQL_YYABORT;
2009
2129
            }
2010
2130
          }
2011
2131
        ;
2012
2132
 
 
2133
opt_collate:
 
2134
          /* empty */ { $$=NULL; }
 
2135
        | COLLATE_SYM collation_name_or_default { $$=$2; }
 
2136
        ;
 
2137
 
2013
2138
collation_name_or_default:
2014
2139
          collation_name { $$=$1; }
2015
2140
        | DEFAULT    { $$=NULL; }
2022
2147
 
2023
2148
opt_binary:
2024
2149
          /* empty */ { Lex->charset=NULL; }
 
2150
        | ASCII_SYM opt_bin_mod { Lex->charset=&my_charset_latin1; }
2025
2151
        | BYTE_SYM { Lex->charset=&my_charset_bin; }
 
2152
        | UNICODE_SYM opt_bin_mod
 
2153
          {
 
2154
            if (!(Lex->charset=get_charset_by_csname("ucs2",
 
2155
                                                     MY_CS_PRIMARY,MYF(0))))
 
2156
            {
 
2157
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2");
 
2158
              MYSQL_YYABORT;
 
2159
            }
 
2160
          }
 
2161
        | charset charset_name opt_bin_mod { Lex->charset=$2; }
 
2162
        | BINARY opt_bin_charset { Lex->type|= BINCMP_FLAG; }
 
2163
        ;
 
2164
 
 
2165
opt_bin_mod:
 
2166
          /* empty */ { }
2026
2167
        | BINARY { Lex->type|= BINCMP_FLAG; }
2027
2168
        ;
2028
2169
 
 
2170
opt_bin_charset:
 
2171
          /* empty */ { Lex->charset= NULL; }
 
2172
        | ASCII_SYM { Lex->charset=&my_charset_latin1; }
 
2173
        | UNICODE_SYM
 
2174
          {
 
2175
            if (!(Lex->charset=get_charset_by_csname("ucs2",
 
2176
                                                     MY_CS_PRIMARY,MYF(0))))
 
2177
            {
 
2178
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2");
 
2179
              MYSQL_YYABORT;
 
2180
            }
 
2181
          }
 
2182
        | charset charset_name { Lex->charset=$2; }
 
2183
        ;
 
2184
 
2029
2185
ws_nweights:
2030
2186
        '(' real_ulong_num
2031
2187
        {
2032
2188
          if ($2 == 0)
2033
2189
          {
2034
2190
            my_parse_error(ER(ER_SYNTAX_ERROR));
2035
 
            DRIZZLE_YYABORT;
 
2191
            MYSQL_YYABORT;
2036
2192
          }
2037
2193
        }
2038
2194
        ')'
2077
2233
ws_level_range:
2078
2234
        ws_level_number '-' ws_level_number
2079
2235
        {
2080
 
          uint32_t start= $1;
2081
 
          uint32_t end= $3;
 
2236
          uint start= $1;
 
2237
          uint end= $3;
2082
2238
          for ($$= 0; start <= end; start++)
2083
2239
            $$|= (1 << start);
2084
2240
        }
2303
2459
            lex->duplicates= DUP_ERROR; 
2304
2460
            if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
2305
2461
                                                   TL_OPTION_UPDATING))
2306
 
              DRIZZLE_YYABORT;
 
2462
              MYSQL_YYABORT;
2307
2463
            lex->alter_info.reset();
2308
2464
            lex->col_list.empty();
2309
2465
            lex->select_lex.init_order();
2310
2466
            lex->select_lex.db=
2311
 
              ((TableList*) lex->select_lex.table_list.first)->db;
2312
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
2467
              ((TABLE_LIST*) lex->select_lex.table_list.first)->db;
 
2468
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
2313
2469
            lex->create_info.db_type= 0;
2314
2470
            lex->create_info.default_table_charset= NULL;
2315
2471
            lex->create_info.row_type= ROW_TYPE_NOT_USED;
2316
2472
            lex->alter_info.reset();
 
2473
            lex->no_write_to_binlog= 0;
2317
2474
            lex->alter_info.build_method= $2;
2318
2475
          }
2319
2476
          alter_commands
2330
2487
            lex->name= $3;
2331
2488
            if (lex->name.str == NULL &&
2332
2489
                lex->copy_db_to(&lex->name.str, &lex->name.length))
2333
 
              DRIZZLE_YYABORT;
 
2490
              MYSQL_YYABORT;
 
2491
          }
 
2492
        | ALTER DATABASE ident UPGRADE_SYM DATA_SYM DIRECTORY_SYM NAME_SYM
 
2493
          {
 
2494
            LEX *lex= Lex;
 
2495
            lex->sql_command= SQLCOM_ALTER_DB_UPGRADE;
 
2496
            lex->name= $3;
2334
2497
          }
2335
2498
        ;
2336
2499
 
2401
2564
            lex->charset= NULL;
2402
2565
            lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2403
2566
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2404
 
            lex->vcol_info= NULL;
2405
2567
          }
2406
 
          field_def
 
2568
          type opt_attribute
2407
2569
          {
2408
2570
            LEX *lex=Lex;
2409
2571
            if (add_field_to_list(lex->thd,&$3,
2412
2574
                                  lex->column_format,
2413
2575
                                  lex->default_value, lex->on_update_value,
2414
2576
                                  &lex->comment,
2415
 
                                  $3.str, &lex->interval_list, lex->charset,
2416
 
                                  lex->vcol_info))
2417
 
              DRIZZLE_YYABORT;
 
2577
                                  $3.str, &lex->interval_list, lex->charset))
 
2578
              MYSQL_YYABORT;
2418
2579
          }
2419
2580
          opt_place
2420
 
        | DROP opt_column field_ident
 
2581
        | DROP opt_column field_ident opt_restrict
2421
2582
          {
2422
2583
            LEX *lex=Lex;
2423
2584
            lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2475
2636
            if (lex->select_lex.db == NULL &&
2476
2637
                lex->copy_db_to(&lex->select_lex.db, &dummy))
2477
2638
            {
2478
 
              DRIZZLE_YYABORT;
 
2639
              MYSQL_YYABORT;
2479
2640
            }
2480
2641
            if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
2481
2642
            {
2482
2643
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
2483
 
              DRIZZLE_YYABORT;
 
2644
              MYSQL_YYABORT;
2484
2645
            }
2485
2646
            lex->name= $3->table;
2486
2647
            lex->alter_info.flags|= ALTER_RENAME;
2487
2648
          }
2488
 
        | CONVERT_SYM TO_SYM collation_name_or_default
 
2649
        | CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
2489
2650
          {
2490
 
            if (!$3)
 
2651
            if (!$4)
2491
2652
            {
2492
2653
              THD *thd= YYTHD;
2493
 
              $3= thd->variables.collation_database;
 
2654
              $4= thd->variables.collation_database;
 
2655
            }
 
2656
            $5= $5 ? $5 : $4;
 
2657
            if (!my_charset_same($4,$5))
 
2658
            {
 
2659
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
 
2660
                       $5->name, $4->csname);
 
2661
              MYSQL_YYABORT;
2494
2662
            }
2495
2663
            LEX *lex= Lex;
2496
2664
            lex->create_info.table_charset=
2497
 
            lex->create_info.default_table_charset= $3;
 
2665
            lex->create_info.default_table_charset= $5;
2498
2666
            lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2499
2667
              HA_CREATE_USED_DEFAULT_CHARSET);
2500
2668
            lex->alter_info.flags|= ALTER_CONVERT;
2525
2693
        | IGNORE_SYM { Lex->ignore= 1;}
2526
2694
        ;
2527
2695
 
 
2696
opt_restrict:
 
2697
          /* empty */ { Lex->drop_mode= DROP_DEFAULT; }
 
2698
        | RESTRICT    { Lex->drop_mode= DROP_RESTRICT; }
 
2699
        | CASCADE     { Lex->drop_mode= DROP_CASCADE; }
 
2700
        ;
 
2701
 
2528
2702
opt_place:
2529
2703
          /* empty */ {}
2530
2704
        | AFTER_SYM ident
2557
2731
            lex->sql_command = SQLCOM_SLAVE_START;
2558
2732
            lex->type = 0;
2559
2733
            /* We'll use mi structure for UNTIL options */
2560
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
2734
            bzero((char*) &lex->mi, sizeof(lex->mi));
2561
2735
            /* If you change this code don't forget to update SLAVE START too */
2562
2736
          }
2563
2737
          slave_until
2575
2749
            lex->sql_command = SQLCOM_SLAVE_START;
2576
2750
            lex->type = 0;
2577
2751
            /* We'll use mi structure for UNTIL options */
2578
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
2752
            bzero((char*) &lex->mi, sizeof(lex->mi));
2579
2753
          }
2580
2754
          slave_until
2581
2755
          {}
2600
2774
          /*empty*/ { $$ = 0; }
2601
2775
        | WITH CONSISTENT_SYM SNAPSHOT_SYM
2602
2776
          {
2603
 
            $$= DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT;
 
2777
            $$= MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT;
2604
2778
          }
2605
2779
        ;
2606
2780
 
2632
2806
            {
2633
2807
               my_message(ER_BAD_SLAVE_UNTIL_COND,
2634
2808
                          ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
2635
 
               DRIZZLE_YYABORT;
 
2809
               MYSQL_YYABORT;
2636
2810
            }
2637
2811
          }
2638
2812
        ;
2659
2833
        ;
2660
2834
 
2661
2835
repair:
2662
 
          REPAIR table_or_tables
 
2836
          REPAIR opt_no_write_to_binlog table_or_tables
2663
2837
          {
2664
2838
            LEX *lex=Lex;
2665
2839
            lex->sql_command = SQLCOM_REPAIR;
 
2840
            lex->no_write_to_binlog= $2;
2666
2841
            lex->check_opt.init();
2667
2842
          }
2668
2843
          table_list opt_mi_repair_type
2686
2861
        ;
2687
2862
 
2688
2863
analyze:
2689
 
          ANALYZE_SYM table_or_tables
 
2864
          ANALYZE_SYM opt_no_write_to_binlog table_or_tables
2690
2865
          {
2691
2866
            LEX *lex=Lex;
2692
2867
            lex->sql_command = SQLCOM_ANALYZE;
 
2868
            lex->no_write_to_binlog= $2;
2693
2869
            lex->check_opt.init();
2694
2870
          }
2695
2871
          table_list
2736
2912
        ;
2737
2913
 
2738
2914
optimize:
2739
 
          OPTIMIZE table_or_tables
 
2915
          OPTIMIZE opt_no_write_to_binlog table_or_tables
2740
2916
          {
2741
2917
            LEX *lex=Lex;
2742
2918
            lex->sql_command = SQLCOM_OPTIMIZE;
 
2919
            lex->no_write_to_binlog= $2;
2743
2920
            lex->check_opt.init();
2744
2921
          }
2745
2922
          table_list
2746
2923
          {}
2747
2924
        ;
2748
2925
 
 
2926
opt_no_write_to_binlog:
 
2927
          /* empty */ { $$= 0; }
 
2928
        | NO_WRITE_TO_BINLOG { $$= 1; }
 
2929
        | LOCAL_SYM { $$= 1; }
 
2930
        ;
 
2931
 
2749
2932
rename:
2750
2933
          RENAME table_or_tables
2751
2934
          {
2769
2952
                                       TL_IGNORE) ||
2770
2953
                !sl->add_table_to_list(lex->thd, $3,NULL,TL_OPTION_UPDATING,
2771
2954
                                       TL_IGNORE))
2772
 
              DRIZZLE_YYABORT;
 
2955
              MYSQL_YYABORT;
2773
2956
          }
2774
2957
        ;
2775
2958
 
2792
2975
          {
2793
2976
            if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ, 
2794
2977
                                           Select->pop_index_hints()))
2795
 
              DRIZZLE_YYABORT;
 
2978
              MYSQL_YYABORT;
2796
2979
          }
2797
2980
        ;
2798
2981
 
2840
3023
          SELECT_SYM select_part2
2841
3024
          {
2842
3025
            if (setup_select_in_parentheses(Lex))
2843
 
              DRIZZLE_YYABORT;
 
3026
              MYSQL_YYABORT;
2844
3027
          }
2845
3028
        | '(' select_paren ')'
2846
3029
        ;
2850
3033
          SELECT_SYM select_part2_derived
2851
3034
          {
2852
3035
            if (setup_select_in_parentheses(Lex))
2853
 
              DRIZZLE_YYABORT;
 
3036
              MYSQL_YYABORT;
2854
3037
          }
2855
3038
        | '(' select_paren_derived ')'
2856
3039
        ;
2863
3046
            if (lex->current_select->set_braces(0))
2864
3047
            {
2865
3048
              my_parse_error(ER(ER_SYNTAX_ERROR));
2866
 
              DRIZZLE_YYABORT;
 
3049
              MYSQL_YYABORT;
2867
3050
            }
2868
3051
            if (sel->linkage == UNION_TYPE &&
2869
3052
                sel->master_unit()->first_select()->braces)
2870
3053
            {
2871
3054
              my_parse_error(ER(ER_SYNTAX_ERROR));
2872
 
              DRIZZLE_YYABORT;
 
3055
              MYSQL_YYABORT;
2873
3056
            }
2874
3057
          }
2875
3058
          union_clause
2904
3087
          {
2905
3088
            Select->context.table_list=
2906
3089
              Select->context.first_name_resolution_table= 
2907
 
                (TableList *) Select->table_list.first;
 
3090
                (TABLE_LIST *) Select->table_list.first;
2908
3091
          }
2909
3092
        ;
2910
3093
 
2915
3098
            if (Select->options & SELECT_DISTINCT && Select->options & SELECT_ALL)
2916
3099
            {
2917
3100
              my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2918
 
              DRIZZLE_YYABORT;
 
3101
              MYSQL_YYABORT;
2919
3102
            }
2920
3103
          }
2921
3104
        ;
2930
3113
        | HIGH_PRIORITY
2931
3114
          {
2932
3115
            if (check_simple_select())
2933
 
              DRIZZLE_YYABORT;
 
3116
              MYSQL_YYABORT;
2934
3117
            Lex->lock_option= TL_READ_HIGH_PRIORITY;
2935
3118
          }
2936
3119
        | DISTINCT         { Select->options|= SELECT_DISTINCT; }
2939
3122
        | SQL_BUFFER_RESULT
2940
3123
          {
2941
3124
            if (check_simple_select())
2942
 
              DRIZZLE_YYABORT;
 
3125
              MYSQL_YYABORT;
2943
3126
            Select->options|= OPTION_BUFFER_RESULT;
2944
3127
          }
2945
3128
        | SQL_CALC_FOUND_ROWS
2946
3129
          {
2947
3130
            if (check_simple_select())
2948
 
              DRIZZLE_YYABORT;
 
3131
              MYSQL_YYABORT;
2949
3132
            Select->options|= OPTION_FOUND_ROWS;
2950
3133
          }
2951
3134
        | ALL { Select->options|= SELECT_ALL; }
2976
3159
                                 new Item_field(&thd->lex->current_select->
2977
3160
                                                context,
2978
3161
                                                NULL, NULL, "*")))
2979
 
              DRIZZLE_YYABORT;
 
3162
              MYSQL_YYABORT;
2980
3163
            (thd->lex->current_select->with_wild)++;
2981
3164
          }
2982
3165
        ;
2987
3170
            THD *thd= YYTHD;
2988
3171
 
2989
3172
            if (add_item_to_list(thd, $2))
2990
 
              DRIZZLE_YYABORT;
 
3173
              MYSQL_YYABORT;
2991
3174
          }
2992
3175
        | remember_name expr remember_end select_alias
2993
3176
          {
2995
3178
            assert($1 < $3);
2996
3179
 
2997
3180
            if (add_item_to_list(thd, $2))
2998
 
              DRIZZLE_YYABORT;
 
3181
              MYSQL_YYABORT;
2999
3182
            if ($4.str)
3000
3183
            {
3001
3184
              $2->is_autogenerated_name= false;
3214
3397
        ;
3215
3398
 
3216
3399
bit_expr:
3217
 
          bit_expr '+' bit_expr %prec '+'
 
3400
          bit_expr '|' bit_expr %prec '|'
 
3401
          { $$= new Item_func_bit_or($1,$3); }
 
3402
        | bit_expr '&' bit_expr %prec '&'
 
3403
          { $$= new Item_func_bit_and($1,$3); }
 
3404
        | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT
 
3405
          { $$= new Item_func_shift_left($1,$3); }
 
3406
        | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT
 
3407
          { $$= new Item_func_shift_right($1,$3); }
 
3408
        | bit_expr '+' bit_expr %prec '+'
3218
3409
          { $$= new Item_func_plus($1,$3); }
3219
3410
        | bit_expr '-' bit_expr %prec '-'
3220
3411
          { $$= new Item_func_minus($1,$3); }
3232
3423
          { $$= new Item_func_int_div($1,$3); }
3233
3424
        | bit_expr MOD_SYM bit_expr %prec MOD_SYM
3234
3425
          { $$= new Item_func_mod($1,$3); }
 
3426
        | bit_expr '^' bit_expr
 
3427
          { $$= new Item_func_bit_xor($1,$3); }
3235
3428
        | simple_expr
3236
3429
        ;
3237
3430
 
3241
3434
 
3242
3435
and:
3243
3436
          AND_SYM
 
3437
       | AND_AND_SYM
3244
3438
       ;
3245
3439
 
3246
3440
not:
3276
3470
            $$= new (thd->mem_root) Item_func_set_collation($1, i1);
3277
3471
          }
3278
3472
        | literal
 
3473
        | param_marker
3279
3474
        | variable
3280
3475
        | sum_expr
3281
3476
        | '+' simple_expr %prec NEG { $$= $2; }
3282
3477
        | '-' simple_expr %prec NEG
3283
3478
          { $$= new (YYTHD->mem_root) Item_func_neg($2); }
 
3479
        | '~' simple_expr %prec NEG
 
3480
          { $$= new (YYTHD->mem_root) Item_func_bit_neg($2); }
3284
3481
        | '(' subselect ')'
3285
3482
          { 
3286
3483
            $$= new (YYTHD->mem_root) Item_singlerow_subselect($2);
3312
3509
            $$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec,
3313
3510
                                 lex->charset);
3314
3511
            if (!$$)
3315
 
              DRIZZLE_YYABORT;
 
3512
              MYSQL_YYABORT;
3316
3513
          }
3317
3514
        | CASE_SYM opt_expr when_list opt_else END
3318
3515
          { $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 ); }
3321
3518
            $$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec,
3322
3519
                                 Lex->charset);
3323
3520
            if (!$$)
3324
 
              DRIZZLE_YYABORT;
 
3521
              MYSQL_YYABORT;
3325
3522
          }
 
3523
        | CONVERT_SYM '(' expr USING charset_name ')'
 
3524
          { $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5); }
3326
3525
        | DEFAULT '(' simple_ident ')'
3327
3526
          {
3328
3527
            $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(),
3347
3546
function_call_keyword:
3348
3547
          CHAR_SYM '(' expr_list ')'
3349
3548
          { $$= new (YYTHD->mem_root) Item_func_char(*$3); }
 
3549
        | CHAR_SYM '(' expr_list USING charset_name ')'
 
3550
          { $$= new (YYTHD->mem_root) Item_func_char(*$3, $5); }
3350
3551
        | CURRENT_USER optional_braces
3351
3552
          {
3352
3553
            $$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context());
3523
3724
function_call_conflict:
3524
3725
          ASCII_SYM '(' expr ')'
3525
3726
          { $$= new (YYTHD->mem_root) Item_func_ascii($3); }
 
3727
        | CHARSET '(' expr ')'
 
3728
          { $$= new (YYTHD->mem_root) Item_func_charset($3); }
3526
3729
        | COALESCE '(' expr_list ')'
3527
3730
          { $$= new (YYTHD->mem_root) Item_func_coalesce(* $3); }
3528
3731
        | COLLATION_SYM '(' expr ')'
3537
3740
          { $$= new (YYTHD->mem_root) Item_func_microsecond($3); }
3538
3741
        | MOD_SYM '(' expr ',' expr ')'
3539
3742
          { $$ = new (YYTHD->mem_root) Item_func_mod( $3, $5); }
 
3743
        | PASSWORD '(' expr ')'
 
3744
          {
 
3745
            THD *thd= YYTHD;
 
3746
            Item* i1;
 
3747
            i1= new (thd->mem_root) Item_func_password($3);
 
3748
            $$= i1;
 
3749
          }
3540
3750
        | QUARTER_SYM '(' expr ')'
3541
3751
          { $$ = new (YYTHD->mem_root) Item_func_quarter($3); }
3542
3752
        | REPEAT_SYM '(' expr ',' expr ')'
3586
3796
          IDENT_sys '('
3587
3797
          {
3588
3798
            udf_func *udf= 0;
3589
 
            udf= find_udf($1.str, $1.length);
3590
 
 
 
3799
            LEX *lex= Lex;
 
3800
            if (using_udf_functions &&
 
3801
                (udf= find_udf($1.str, $1.length)) &&
 
3802
                udf->type == UDFTYPE_AGGREGATE)
 
3803
            {
 
3804
              if (lex->current_select->inc_in_sum_expr())
 
3805
              {
 
3806
                my_parse_error(ER(ER_SYNTAX_ERROR));
 
3807
                MYSQL_YYABORT;
 
3808
              }
 
3809
            }
3591
3810
            /* Temporary placing the result of find_udf in $3 */
3592
3811
            $<udf>$= udf;
3593
3812
          }
3617
3836
              udf_func *udf= $<udf>3;
3618
3837
              if (udf)
3619
3838
              {
 
3839
                if (udf->type == UDFTYPE_AGGREGATE)
 
3840
                {
 
3841
                  Select->in_sum_expr--;
 
3842
                }
 
3843
 
3620
3844
                item= Create_udf_func::s_singleton.create(thd, udf, $4);
3621
 
              } else {
3622
 
                /* fix for bug 250065, from Andrew Garner <muzazzi@gmail.com> */
3623
 
                my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", $1.str);
3624
3845
              }
3625
3846
            }
3626
3847
 
3627
3848
            if (! ($$= item))
3628
3849
            {
3629
 
              DRIZZLE_YYABORT;
 
3850
              MYSQL_YYABORT;
3630
3851
            }
3631
3852
          }
3632
3853
        ;
3674
3895
          { $$=new Item_sum_avg($3); }
3675
3896
        | AVG_SYM '(' DISTINCT in_sum_expr ')'
3676
3897
          { $$=new Item_sum_avg_distinct($4); }
 
3898
        | BIT_AND  '(' in_sum_expr ')'
 
3899
          { $$=new Item_sum_and($3); }
 
3900
        | BIT_OR  '(' in_sum_expr ')'
 
3901
          { $$=new Item_sum_or($3); }
 
3902
        | BIT_XOR  '(' in_sum_expr ')'
 
3903
          { $$=new Item_sum_xor($3); }
3677
3904
        | COUNT_SYM '(' opt_all '*' ')'
3678
 
          { $$=new Item_sum_count(new Item_int((int32_t) 0L,1)); }
 
3905
          { $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
3679
3906
        | COUNT_SYM '(' in_sum_expr ')'
3680
3907
          { $$=new Item_sum_count($3); }
3681
3908
        | COUNT_SYM '(' DISTINCT
3729
3956
            if (! Lex->parsing_options.allows_variable)
3730
3957
            {
3731
3958
              my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
3732
 
              DRIZZLE_YYABORT;
 
3959
              MYSQL_YYABORT;
3733
3960
            }
3734
3961
          }
3735
3962
          variable_aux
3753
3980
            if ($3.str && $4.str && check_reserved_words(&$3))
3754
3981
            {
3755
3982
              my_parse_error(ER(ER_SYNTAX_ERROR));
3756
 
              DRIZZLE_YYABORT;
 
3983
              MYSQL_YYABORT;
3757
3984
            }
3758
3985
            if (!($$= get_system_var(YYTHD, $2, $3, $4)))
3759
 
              DRIZZLE_YYABORT;
 
3986
              MYSQL_YYABORT;
3760
3987
            if (!((Item_func_get_system_var*) $$)->is_written_to_binlog())
3761
3988
              Lex->set_stmt_unsafe();
3762
3989
          }
3770
3997
opt_gconcat_separator:
3771
3998
          /* empty */
3772
3999
            {
3773
 
              $$= new (YYTHD->mem_root) String(",", 1, &my_charset_utf8_general_ci);
 
4000
              $$= new (YYTHD->mem_root) String(",", 1, &my_charset_latin1);
3774
4001
            }
3775
4002
        | SEPARATOR_SYM text_string { $$ = $2; }
3776
4003
        ;
3797
4024
            if (lex->current_select->inc_in_sum_expr())
3798
4025
            {
3799
4026
              my_parse_error(ER(ER_SYNTAX_ERROR));
3800
 
              DRIZZLE_YYABORT;
 
4027
              MYSQL_YYABORT;
3801
4028
            }
3802
4029
          }
3803
4030
          expr
3812
4039
          { $$=ITEM_CAST_CHAR; Lex->charset= &my_charset_bin; Lex->dec= 0; }
3813
4040
        | CHAR_SYM opt_len opt_binary
3814
4041
          { $$=ITEM_CAST_CHAR; Lex->dec= 0; }
 
4042
        | NCHAR_SYM opt_len
 
4043
          { $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; }
 
4044
        | SIGNED_SYM
 
4045
          { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4046
        | SIGNED_SYM INT_SYM
 
4047
          { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4048
        | UNSIGNED
 
4049
          { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4050
        | UNSIGNED INT_SYM
 
4051
          { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3815
4052
        | DATE_SYM
3816
4053
          { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3817
4054
        | TIME_SYM
3868
4105
          {
3869
4106
            LEX *lex= Lex;
3870
4107
            if (!($$= lex->current_select->nest_last_join(lex->thd)))
3871
 
              DRIZZLE_YYABORT;
 
4108
              MYSQL_YYABORT;
3872
4109
          }
3873
4110
        ;
3874
4111
 
3875
4112
join_table_list:
3876
 
          derived_table_list { DRIZZLE_YYABORT_UNLESS($$=$1); }
 
4113
          derived_table_list { MYSQL_YYABORT_UNLESS($$=$1); }
3877
4114
        ;
3878
4115
 
3879
4116
/*
3894
4131
          esc_table_ref { $$=$1; }
3895
4132
        | derived_table_list ',' esc_table_ref
3896
4133
          {
3897
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
 
4134
            MYSQL_YYABORT_UNLESS($1 && ($$=$3));
3898
4135
          }
3899
4136
        ;
3900
4137
 
3913
4150
            left-associative joins.
3914
4151
          */
3915
4152
          table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3916
 
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); }
 
4153
          { MYSQL_YYABORT_UNLESS($1 && ($$=$3)); }
3917
4154
        | table_ref STRAIGHT_JOIN table_factor
3918
 
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
 
4155
          { MYSQL_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
3919
4156
        | table_ref normal_join table_ref
3920
4157
          ON
3921
4158
          {
3922
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4159
            MYSQL_YYABORT_UNLESS($1 && $3);
3923
4160
            /* Change the current name resolution context to a local context. */
3924
4161
            if (push_new_name_resolution_context(YYTHD, $1, $3))
3925
 
              DRIZZLE_YYABORT;
 
4162
              MYSQL_YYABORT;
3926
4163
            Select->parsing_place= IN_ON;
3927
4164
          }
3928
4165
          expr
3934
4171
        | table_ref STRAIGHT_JOIN table_factor
3935
4172
          ON
3936
4173
          {
3937
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4174
            MYSQL_YYABORT_UNLESS($1 && $3);
3938
4175
            /* Change the current name resolution context to a local context. */
3939
4176
            if (push_new_name_resolution_context(YYTHD, $1, $3))
3940
 
              DRIZZLE_YYABORT;
 
4177
              MYSQL_YYABORT;
3941
4178
            Select->parsing_place= IN_ON;
3942
4179
          }
3943
4180
          expr
3950
4187
        | table_ref normal_join table_ref
3951
4188
          USING
3952
4189
          {
3953
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4190
            MYSQL_YYABORT_UNLESS($1 && $3);
3954
4191
          }
3955
4192
          '(' using_list ')'
3956
4193
          { add_join_natural($1,$3,$7,Select); $$=$3; }
3957
4194
        | table_ref NATURAL JOIN_SYM table_factor
3958
4195
          {
3959
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$4));
 
4196
            MYSQL_YYABORT_UNLESS($1 && ($$=$4));
3960
4197
            add_join_natural($1,$4,NULL,Select);
3961
4198
          }
3962
4199
 
3964
4201
        | table_ref LEFT opt_outer JOIN_SYM table_ref
3965
4202
          ON
3966
4203
          {
3967
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4204
            MYSQL_YYABORT_UNLESS($1 && $5);
3968
4205
            /* Change the current name resolution context to a local context. */
3969
4206
            if (push_new_name_resolution_context(YYTHD, $1, $5))
3970
 
              DRIZZLE_YYABORT;
 
4207
              MYSQL_YYABORT;
3971
4208
            Select->parsing_place= IN_ON;
3972
4209
          }
3973
4210
          expr
3980
4217
          }
3981
4218
        | table_ref LEFT opt_outer JOIN_SYM table_factor
3982
4219
          {
3983
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4220
            MYSQL_YYABORT_UNLESS($1 && $5);
3984
4221
          }
3985
4222
          USING '(' using_list ')'
3986
4223
          { 
3990
4227
          }
3991
4228
        | table_ref NATURAL LEFT opt_outer JOIN_SYM table_factor
3992
4229
          {
3993
 
            DRIZZLE_YYABORT_UNLESS($1 && $6);
 
4230
            MYSQL_YYABORT_UNLESS($1 && $6);
3994
4231
            add_join_natural($1,$6,NULL,Select);
3995
4232
            $6->outer_join|=JOIN_TYPE_LEFT;
3996
4233
            $$=$6;
4000
4237
        | table_ref RIGHT opt_outer JOIN_SYM table_ref
4001
4238
          ON
4002
4239
          {
4003
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4240
            MYSQL_YYABORT_UNLESS($1 && $5);
4004
4241
            /* Change the current name resolution context to a local context. */
4005
4242
            if (push_new_name_resolution_context(YYTHD, $1, $5))
4006
 
              DRIZZLE_YYABORT;
 
4243
              MYSQL_YYABORT;
4007
4244
            Select->parsing_place= IN_ON;
4008
4245
          }
4009
4246
          expr
4010
4247
          {
4011
4248
            LEX *lex= Lex;
4012
4249
            if (!($$= lex->current_select->convert_right_join()))
4013
 
              DRIZZLE_YYABORT;
 
4250
              MYSQL_YYABORT;
4014
4251
            add_join_on($$, $8);
4015
4252
            Lex->pop_context();
4016
4253
            Select->parsing_place= NO_MATTER;
4017
4254
          }
4018
4255
        | table_ref RIGHT opt_outer JOIN_SYM table_factor
4019
4256
          {
4020
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4257
            MYSQL_YYABORT_UNLESS($1 && $5);
4021
4258
          }
4022
4259
          USING '(' using_list ')'
4023
4260
          {
4024
4261
            LEX *lex= Lex;
4025
4262
            if (!($$= lex->current_select->convert_right_join()))
4026
 
              DRIZZLE_YYABORT;
 
4263
              MYSQL_YYABORT;
4027
4264
            add_join_natural($$,$5,$9,Select);
4028
4265
          }
4029
4266
        | table_ref NATURAL RIGHT opt_outer JOIN_SYM table_factor
4030
4267
          {
4031
 
            DRIZZLE_YYABORT_UNLESS($1 && $6);
 
4268
            MYSQL_YYABORT_UNLESS($1 && $6);
4032
4269
            add_join_natural($6,$1,NULL,Select);
4033
4270
            LEX *lex= Lex;
4034
4271
            if (!($$= lex->current_select->convert_right_join()))
4035
 
              DRIZZLE_YYABORT;
 
4272
              MYSQL_YYABORT;
4036
4273
          }
4037
4274
        ;
4038
4275
 
4061
4298
                                                Select->get_table_join_options(),
4062
4299
                                                Lex->lock_option,
4063
4300
                                                Select->pop_index_hints())))
4064
 
              DRIZZLE_YYABORT;
 
4301
              MYSQL_YYABORT;
4065
4302
            Select->add_joined_table($$);
4066
4303
          }
4067
4304
        | select_derived_init get_select_lex select_derived2
4073
4310
              if (sel->set_braces(1))
4074
4311
              {
4075
4312
                my_parse_error(ER(ER_SYNTAX_ERROR));
4076
 
                DRIZZLE_YYABORT;
 
4313
                MYSQL_YYABORT;
4077
4314
              }
4078
4315
              /* select in braces, can't contain global parameters */
4079
4316
              if (sel->master_unit()->fake_select_lex)
4081
4318
                   sel->master_unit()->fake_select_lex;
4082
4319
            }
4083
4320
            if ($2->init_nested_join(lex->thd))
4084
 
              DRIZZLE_YYABORT;
 
4321
              MYSQL_YYABORT;
4085
4322
            $$= 0;
4086
4323
            /* incomplete derived tables return NULL, we must be
4087
4324
               nested in select_derived rule to be here. */
4130
4367
                                               new Table_ident(unit), $5, 0,
4131
4368
                                               TL_READ)))
4132
4369
 
4133
 
                DRIZZLE_YYABORT;
 
4370
                MYSQL_YYABORT;
4134
4371
              sel->add_joined_table($$);
4135
4372
              lex->pop_context();
4136
4373
            }
4138
4375
            {
4139
4376
              /* simple nested joins cannot have aliases or unions */
4140
4377
              my_parse_error(ER(ER_SYNTAX_ERROR));
4141
 
              DRIZZLE_YYABORT;
 
4378
              MYSQL_YYABORT;
4142
4379
            }
4143
4380
            else
4144
4381
              $$= $3;
4152
4389
          union_option
4153
4390
          {
4154
4391
            if (add_select_to_union_list(Lex, (bool)$3))
4155
 
              DRIZZLE_YYABORT;
 
4392
              MYSQL_YYABORT;
4156
4393
          }
4157
4394
          query_specification
4158
4395
          {
4174
4411
            if (lex->current_select->set_braces(0))
4175
4412
            {
4176
4413
              my_parse_error(ER(ER_SYNTAX_ERROR));
4177
 
              DRIZZLE_YYABORT;
 
4414
              MYSQL_YYABORT;
4178
4415
            }
4179
4416
            if (sel->linkage == UNION_TYPE &&
4180
4417
                sel->master_unit()->first_select()->braces)
4181
4418
            {
4182
4419
              my_parse_error(ER(ER_SYNTAX_ERROR));
4183
 
              DRIZZLE_YYABORT;
 
4420
              MYSQL_YYABORT;
4184
4421
            }
4185
4422
          }
4186
4423
        ;
4207
4444
          {
4208
4445
            LEX *lex= Lex;
4209
4446
            if ($1->init_nested_join(lex->thd))
4210
 
              DRIZZLE_YYABORT;
 
4447
              MYSQL_YYABORT;
4211
4448
          }
4212
4449
          derived_table_list
4213
4450
          {
4216
4453
               for derived tables, both must equal NULL */
4217
4454
 
4218
4455
            if (!($$= $1->end_nested_join(lex->thd)) && $3)
4219
 
              DRIZZLE_YYABORT;
 
4456
              MYSQL_YYABORT;
4220
4457
            if (!$3 && $$)
4221
4458
            {
4222
4459
              my_parse_error(ER(ER_SYNTAX_ERROR));
4223
 
              DRIZZLE_YYABORT;
 
4460
              MYSQL_YYABORT;
4224
4461
            }
4225
4462
          }
4226
4463
        ;
4233
4470
                lex->sql_command == (int)SQLCOM_PURGE)
4234
4471
            {
4235
4472
              my_parse_error(ER(ER_SYNTAX_ERROR));
4236
 
              DRIZZLE_YYABORT;
 
4473
              MYSQL_YYABORT;
4237
4474
            }
4238
4475
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
4239
4476
                mysql_new_select(lex, 1))
4240
 
              DRIZZLE_YYABORT;
 
4477
              MYSQL_YYABORT;
4241
4478
            mysql_init_select(lex);
4242
4479
            lex->current_select->linkage= DERIVED_TABLE_TYPE;
4243
4480
            lex->current_select->parsing_place= SELECT_LIST;
4261
4498
            if (! lex->parsing_options.allows_derived)
4262
4499
            {
4263
4500
              my_error(ER_VIEW_SELECT_DERIVED, MYF(0));
4264
 
              DRIZZLE_YYABORT;
 
4501
              MYSQL_YYABORT;
4265
4502
            }
4266
4503
 
4267
4504
            SELECT_LEX *sel= lex->current_select;
4268
 
            TableList *embedding;
 
4505
            TABLE_LIST *embedding;
4269
4506
            if (!sel->embedding || sel->end_nested_join(lex->thd))
4270
4507
            {
4271
4508
              /* we are not in parentheses */
4272
4509
              my_parse_error(ER(ER_SYNTAX_ERROR));
4273
 
              DRIZZLE_YYABORT;
 
4510
              MYSQL_YYABORT;
4274
4511
            }
4275
4512
            embedding= Select->embedding;
4276
4513
            $$= embedding &&
4349
4586
          ident
4350
4587
          {
4351
4588
            if (!($$= new List<String>))
4352
 
              DRIZZLE_YYABORT;
 
4589
              MYSQL_YYABORT;
4353
4590
            $$->push_back(new (YYTHD->mem_root)
4354
4591
                              String((const char *) $1.str, $1.length,
4355
4592
                                      system_charset_info));
4410
4647
        ;
4411
4648
 
4412
4649
date_time_type:
4413
 
          DATE_SYM  {$$=DRIZZLE_TIMESTAMP_DATE;}
4414
 
        | TIME_SYM  {$$=DRIZZLE_TIMESTAMP_TIME;}
4415
 
        | DATETIME  {$$=DRIZZLE_TIMESTAMP_DATETIME;}
4416
 
        | TIMESTAMP {$$=DRIZZLE_TIMESTAMP_DATETIME;}
 
4650
          DATE_SYM  {$$=MYSQL_TIMESTAMP_DATE;}
 
4651
        | TIME_SYM  {$$=MYSQL_TIMESTAMP_TIME;}
 
4652
        | DATETIME  {$$=MYSQL_TIMESTAMP_DATETIME;}
 
4653
        | TIMESTAMP {$$=MYSQL_TIMESTAMP_DATETIME;}
4417
4654
        ;
4418
4655
 
4419
4656
table_alias:
4474
4711
        | /* empty */
4475
4712
          {
4476
4713
            Lex->escape_used= false;
4477
 
            $$= new Item_string("\\", 1, &my_charset_utf8_general_ci);
 
4714
            $$= new Item_string("\\", 1, &my_charset_latin1);
4478
4715
          }
4479
4716
        ;
4480
4717
 
4489
4726
 
4490
4727
group_list:
4491
4728
          group_list ',' order_ident order_dir
4492
 
          { if (add_group_to_list(YYTHD, $3,(bool) $4)) DRIZZLE_YYABORT; }
 
4729
          { if (add_group_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
4493
4730
        | order_ident order_dir
4494
 
          { if (add_group_to_list(YYTHD, $1,(bool) $2)) DRIZZLE_YYABORT; }
 
4731
          { if (add_group_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
4495
4732
        ;
4496
4733
 
4497
4734
olap_opt:
4498
4735
          /* empty */ {}
 
4736
        | WITH_CUBE_SYM
 
4737
          {
 
4738
            /*
 
4739
              'WITH CUBE' is reserved in the MySQL syntax, but not implemented,
 
4740
              and cause LALR(2) conflicts.
 
4741
              This syntax is not standard.
 
4742
              MySQL syntax: GROUP BY col1, col2, col3 WITH CUBE
 
4743
              SQL-2003: GROUP BY ... CUBE(col1, col2, col3)
 
4744
            */
 
4745
            LEX *lex=Lex;
 
4746
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
 
4747
            {
 
4748
              my_error(ER_WRONG_USAGE, MYF(0), "WITH CUBE",
 
4749
                       "global union parameters");
 
4750
              MYSQL_YYABORT;
 
4751
            }
 
4752
            lex->current_select->olap= CUBE_TYPE;
 
4753
            my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE");
 
4754
            MYSQL_YYABORT;
 
4755
          }
4499
4756
        | WITH_ROLLUP_SYM
4500
4757
          {
4501
4758
            /*
4510
4767
            {
4511
4768
              my_error(ER_WRONG_USAGE, MYF(0), "WITH ROLLUP",
4512
4769
                       "global union parameters");
4513
 
              DRIZZLE_YYABORT;
 
4770
              MYSQL_YYABORT;
4514
4771
            }
4515
4772
            lex->current_select->olap= ROLLUP_TYPE;
4516
4773
          }
4535
4792
            THD *thd= YYTHD;
4536
4793
            bool ascending= ($2 == 1) ? true : false;
4537
4794
            if (add_order_to_list(thd, $1, ascending))
4538
 
              DRIZZLE_YYABORT;
 
4795
              MYSQL_YYABORT;
4539
4796
          }
4540
4797
        ;
4541
4798
 
4560
4817
            {
4561
4818
              my_error(ER_WRONG_USAGE, MYF(0),
4562
4819
                       "CUBE/ROLLUP", "ORDER BY");
4563
 
              DRIZZLE_YYABORT;
 
4820
              MYSQL_YYABORT;
4564
4821
            }
4565
4822
            if (lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
4566
4823
            {
4577
4834
                  (first_sl->order_list.elements || 
4578
4835
                   first_sl->select_limit) &&            
4579
4836
                  unit->add_fake_select_lex(lex->thd))
4580
 
                DRIZZLE_YYABORT;
 
4837
                MYSQL_YYABORT;
4581
4838
            }
4582
4839
          }
4583
4840
          order_list
4585
4842
 
4586
4843
order_list:
4587
4844
          order_list ',' order_ident order_dir
4588
 
          { if (add_order_to_list(YYTHD, $3,(bool) $4)) DRIZZLE_YYABORT; }
 
4845
          { if (add_order_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
4589
4846
        | order_ident order_dir
4590
 
          { if (add_order_to_list(YYTHD, $1,(bool) $2)) DRIZZLE_YYABORT; }
 
4847
          { if (add_order_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
4591
4848
        ;
4592
4849
 
4593
4850
order_dir:
4641
4898
        ;
4642
4899
 
4643
4900
limit_option:
4644
 
          ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
 
4901
        param_marker
 
4902
        {
 
4903
          ((Item_param *) $1)->limit_clause_param= true;
 
4904
        }
 
4905
        | ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
4645
4906
        | LONG_NUM      { $$= new Item_uint($1.str, $1.length); }
4646
4907
        | NUM           { $$= new Item_uint($1.str, $1.length); }
4647
4908
        ;
4674
4935
        | HEX_NUM       { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4675
4936
        | LONG_NUM      { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4676
4937
        | ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4677
 
        | dec_num_error { DRIZZLE_YYABORT; }
 
4938
        | dec_num_error { MYSQL_YYABORT; }
4678
4939
        ;
4679
4940
 
4680
4941
ulonglong_num:
4704
4965
          {
4705
4966
            LEX *lex=Lex;
4706
4967
            if (!lex->describe && (!(lex->result= new select_dumpvar())))
4707
 
              DRIZZLE_YYABORT;
 
4968
              MYSQL_YYABORT;
4708
4969
          }
4709
4970
          select_var_list
4710
4971
          {}
4736
4997
            if (! Lex->parsing_options.allows_select_into)
4737
4998
            {
4738
4999
              my_error(ER_VIEW_SELECT_CLAUSE, MYF(0), "INTO");
4739
 
              DRIZZLE_YYABORT;
 
5000
              MYSQL_YYABORT;
4740
5001
            }
4741
5002
          }
4742
5003
          into_destination
4748
5009
            LEX *lex= Lex;
4749
5010
            if (!(lex->exchange= new sql_exchange($2.str, 0)) ||
4750
5011
                !(lex->result= new select_export(lex->exchange)))
4751
 
              DRIZZLE_YYABORT;
 
5012
              MYSQL_YYABORT;
4752
5013
          }
4753
5014
          opt_field_term opt_line_term
4754
5015
        | DUMPFILE TEXT_STRING_filesystem
4757
5018
            if (!lex->describe)
4758
5019
            {
4759
5020
              if (!(lex->exchange= new sql_exchange($2.str,1)))
4760
 
                DRIZZLE_YYABORT;
 
5021
                MYSQL_YYABORT;
4761
5022
              if (!(lex->result= new select_dump(lex->exchange)))
4762
 
                DRIZZLE_YYABORT;
 
5023
                MYSQL_YYABORT;
4763
5024
            }
4764
5025
          }
4765
5026
        | select_var_list_init
4771
5032
*/
4772
5033
 
4773
5034
drop:
4774
 
          DROP opt_temporary table_or_tables if_exists table_list
 
5035
          DROP opt_temporary table_or_tables if_exists table_list opt_restrict
4775
5036
          {
4776
5037
            LEX *lex=Lex;
4777
5038
            lex->sql_command = SQLCOM_DROP_TABLE;
4789
5050
                                                               $4.str));
4790
5051
            if (!lex->current_select->add_table_to_list(lex->thd, $6, NULL,
4791
5052
                                                        TL_OPTION_UPDATING))
4792
 
              DRIZZLE_YYABORT;
 
5053
              MYSQL_YYABORT;
4793
5054
          }
4794
5055
        | DROP DATABASE if_exists ident
4795
5056
          {
4807
5068
          table_ident
4808
5069
          {
4809
5070
            if (!Select->add_table_to_list(YYTHD, $1, NULL, TL_OPTION_UPDATING))
4810
 
              DRIZZLE_YYABORT;
 
5071
              MYSQL_YYABORT;
4811
5072
          }
4812
5073
        ;
4813
5074
 
4822
5083
            if (!Select->add_table_to_list(YYTHD, $1, NULL,
4823
5084
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
4824
5085
                                           Lex->lock_option ))
4825
 
              DRIZZLE_YYABORT;
 
5086
              MYSQL_YYABORT;
4826
5087
          }
4827
5088
        ;
4828
5089
 
4914
5175
            LEX *lex=Lex;
4915
5176
            if (!(lex->insert_list = new List_item) ||
4916
5177
                lex->many_values.push_back(lex->insert_list))
4917
 
              DRIZZLE_YYABORT;
 
5178
              MYSQL_YYABORT;
4918
5179
          }
4919
5180
          ident_eq_list
4920
5181
        ;
4951
5212
            LEX *lex=Lex;
4952
5213
            if (lex->field_list.push_back($1) ||
4953
5214
                lex->insert_list->push_back($3))
4954
 
              DRIZZLE_YYABORT;
 
5215
              MYSQL_YYABORT;
4955
5216
          }
4956
5217
        ;
4957
5218
 
4969
5230
          '('
4970
5231
          {
4971
5232
              if (!(Lex->insert_list = new List_item))
4972
 
                DRIZZLE_YYABORT;
 
5233
                MYSQL_YYABORT;
4973
5234
          }
4974
5235
          opt_values ')'
4975
5236
          {
4976
5237
            LEX *lex=Lex;
4977
5238
            if (lex->many_values.push_back(lex->insert_list))
4978
 
              DRIZZLE_YYABORT;
 
5239
              MYSQL_YYABORT;
4979
5240
          }
4980
5241
        ;
4981
5242
 
4988
5249
          values ','  expr_or_default
4989
5250
          {
4990
5251
            if (Lex->insert_list->push_back($3))
4991
 
              DRIZZLE_YYABORT;
 
5252
              MYSQL_YYABORT;
4992
5253
          }
4993
5254
        | expr_or_default
4994
5255
          {
4995
5256
            if (Lex->insert_list->push_back($1))
4996
 
              DRIZZLE_YYABORT;
 
5257
              MYSQL_YYABORT;
4997
5258
          }
4998
5259
        ;
4999
5260
 
5030
5291
              /* it is single table update and it is update of derived table */
5031
5292
              my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
5032
5293
                       lex->select_lex.get_table_list()->alias, "UPDATE");
5033
 
              DRIZZLE_YYABORT;
 
5294
              MYSQL_YYABORT;
5034
5295
            }
5035
5296
            /*
5036
5297
              In case of multi-update setting write lock for all tables may
5051
5312
          simple_ident_nospvar equal expr_or_default
5052
5313
          {
5053
5314
            if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
5054
 
              DRIZZLE_YYABORT;
 
5315
              MYSQL_YYABORT;
5055
5316
          }
5056
5317
        ;
5057
5318
 
5066
5327
          LEX *lex= Lex;
5067
5328
          if (lex->update_list.push_back($1) || 
5068
5329
              lex->value_list.push_back($3))
5069
 
              DRIZZLE_YYABORT;
 
5330
              MYSQL_YYABORT;
5070
5331
          }
5071
5332
        ;
5072
5333
 
5095
5356
          {
5096
5357
            if (!Select->add_table_to_list(YYTHD, $2, NULL, TL_OPTION_UPDATING,
5097
5358
                                           Lex->lock_option))
5098
 
              DRIZZLE_YYABORT;
 
5359
              MYSQL_YYABORT;
5099
5360
          }
5100
5361
          where_clause opt_order_clause
5101
5362
          delete_limit_clause {}
5104
5365
          FROM join_table_list where_clause
5105
5366
          {
5106
5367
            if (multi_delete_set_locks_and_link_aux_tables(Lex))
5107
 
              DRIZZLE_YYABORT;
 
5368
              MYSQL_YYABORT;
5108
5369
          }
5109
5370
        | FROM table_alias_ref_list
5110
5371
          { mysql_init_multi_delete(Lex); }
5111
5372
          USING join_table_list where_clause
5112
5373
          {
5113
5374
            if (multi_delete_set_locks_and_link_aux_tables(Lex))
5114
 
              DRIZZLE_YYABORT;
 
5375
              MYSQL_YYABORT;
5115
5376
          }
5116
5377
        ;
5117
5378
 
5127
5388
                                           NULL,
5128
5389
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5129
5390
                                           Lex->lock_option))
5130
 
              DRIZZLE_YYABORT;
 
5391
              MYSQL_YYABORT;
5131
5392
          }
5132
5393
        | ident '.' ident opt_wild
5133
5394
          {
5136
5397
                                           NULL,
5137
5398
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5138
5399
                                           Lex->lock_option))
5139
 
              DRIZZLE_YYABORT;
 
5400
              MYSQL_YYABORT;
5140
5401
          }
5141
5402
        ;
5142
5403
 
5181
5442
            lex->lock_option= TL_READ;
5182
5443
            mysql_init_select(lex);
5183
5444
            lex->current_select->parsing_place= SELECT_LIST;
5184
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
5445
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
5185
5446
          }
5186
5447
          show_param
5187
5448
          {}
5188
5449
        ;
5189
5450
 
5190
5451
show_param:
5191
 
           DATABASES show_wild
 
5452
           DATABASES wild_and_where
5192
5453
           {
5193
5454
             LEX *lex= Lex;
5194
5455
             lex->sql_command= SQLCOM_SHOW_DATABASES;
5195
5456
             if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
5196
 
               DRIZZLE_YYABORT;
 
5457
               MYSQL_YYABORT;
5197
5458
           }
5198
 
         | opt_full TABLES opt_db show_wild
 
5459
         | opt_full TABLES opt_db wild_and_where
5199
5460
           {
5200
5461
             LEX *lex= Lex;
5201
5462
             lex->sql_command= SQLCOM_SHOW_TABLES;
5202
5463
             lex->select_lex.db= $3;
5203
5464
             if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
5204
 
               DRIZZLE_YYABORT;
 
5465
               MYSQL_YYABORT;
5205
5466
           }
5206
 
         | TABLE_SYM STATUS_SYM opt_db show_wild
 
5467
         | TABLE_SYM STATUS_SYM opt_db wild_and_where
5207
5468
           {
5208
5469
             LEX *lex= Lex;
5209
5470
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
5210
5471
             lex->select_lex.db= $3;
5211
5472
             if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
5212
 
               DRIZZLE_YYABORT;
 
5473
               MYSQL_YYABORT;
5213
5474
           }
5214
 
        | OPEN_SYM TABLES opt_db show_wild
 
5475
        | OPEN_SYM TABLES opt_db wild_and_where
5215
5476
          {
5216
5477
            LEX *lex= Lex;
5217
5478
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
5218
5479
            lex->select_lex.db= $3;
5219
5480
            if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
5220
 
              DRIZZLE_YYABORT;
 
5481
              MYSQL_YYABORT;
5221
5482
          }
5222
5483
        | ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
5223
5484
          { 
5224
5485
            Lex->create_info.db_type= $2; 
5225
5486
            Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
5226
5487
          }
5227
 
        | opt_full COLUMNS from_or_in table_ident opt_db show_wild
 
5488
        | opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
5228
5489
          {
5229
5490
            LEX *lex= Lex;
5230
5491
            lex->sql_command= SQLCOM_SHOW_FIELDS;
5231
5492
            if ($5)
5232
5493
              $4->change_db($5);
5233
5494
            if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
5234
 
              DRIZZLE_YYABORT;
 
5495
              MYSQL_YYABORT;
5235
5496
          }
5236
5497
        | master_or_binary LOGS_SYM
5237
5498
          {
5238
5499
            Lex->sql_command = SQLCOM_SHOW_BINLOGS;
5239
5500
          }
 
5501
        | SLAVE HOSTS_SYM
 
5502
          {
 
5503
            Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
 
5504
          }
 
5505
        | BINLOG_SYM EVENTS_SYM binlog_in binlog_from
 
5506
          {
 
5507
            LEX *lex= Lex;
 
5508
            lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
 
5509
          } opt_limit_clause_init
5240
5510
        | keys_or_index from_or_in table_ident opt_db where_clause
5241
5511
          {
5242
5512
            LEX *lex= Lex;
5244
5514
            if ($4)
5245
5515
              $3->change_db($4);
5246
5516
            if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
5247
 
              DRIZZLE_YYABORT;
 
5517
              MYSQL_YYABORT;
5248
5518
          }
5249
5519
        | COUNT_SYM '(' '*' ')' WARNINGS
5250
5520
          { (void) create_select_for_variable("warning_count"); }
5254
5524
          { Lex->sql_command = SQLCOM_SHOW_WARNS;}
5255
5525
        | ERRORS opt_limit_clause_init
5256
5526
          { Lex->sql_command = SQLCOM_SHOW_ERRORS;}
5257
 
        | opt_var_type STATUS_SYM show_wild
 
5527
        | opt_var_type STATUS_SYM wild_and_where
5258
5528
          {
5259
5529
            LEX *lex= Lex;
5260
5530
            lex->sql_command= SQLCOM_SHOW_STATUS;
5261
5531
            lex->option_type= $1;
5262
5532
            if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
5263
 
              DRIZZLE_YYABORT;
 
5533
              MYSQL_YYABORT;
5264
5534
          }
5265
5535
        | opt_full PROCESSLIST_SYM
5266
5536
          { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
5267
 
        | opt_var_type  VARIABLES show_wild
 
5537
        | opt_var_type  VARIABLES wild_and_where
5268
5538
          {
5269
5539
            LEX *lex= Lex;
5270
5540
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
5271
5541
            lex->option_type= $1;
5272
5542
            if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
5273
 
              DRIZZLE_YYABORT;
 
5543
              MYSQL_YYABORT;
 
5544
          }
 
5545
        | charset wild_and_where
 
5546
          {
 
5547
            LEX *lex= Lex;
 
5548
            lex->sql_command= SQLCOM_SHOW_CHARSETS;
 
5549
            if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
 
5550
              MYSQL_YYABORT;
 
5551
          }
 
5552
        | COLLATION_SYM wild_and_where
 
5553
          {
 
5554
            LEX *lex= Lex;
 
5555
            lex->sql_command= SQLCOM_SHOW_COLLATIONS;
 
5556
            if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS))
 
5557
              MYSQL_YYABORT;
5274
5558
          }
5275
5559
        | CREATE DATABASE opt_if_not_exists ident
5276
5560
          {
5283
5567
            LEX *lex= Lex;
5284
5568
            lex->sql_command = SQLCOM_SHOW_CREATE;
5285
5569
            if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
5286
 
              DRIZZLE_YYABORT;
 
5570
              MYSQL_YYABORT;
5287
5571
          }
5288
5572
        | MASTER_SYM STATUS_SYM
5289
5573
          {
5314
5598
        | IN_SYM
5315
5599
        ;
5316
5600
 
5317
 
show_wild:
 
5601
binlog_in:
 
5602
          /* empty */            { Lex->mi.log_file_name = 0; }
 
5603
        | IN_SYM TEXT_STRING_sys { Lex->mi.log_file_name = $2.str; }
 
5604
        ;
 
5605
 
 
5606
binlog_from:
 
5607
          /* empty */        { Lex->mi.pos = 4; /* skip magic number */ }
 
5608
        | FROM ulonglong_num { Lex->mi.pos = $2; }
 
5609
        ;
 
5610
 
 
5611
wild_and_where:
5318
5612
          /* empty */
5319
5613
        | LIKE TEXT_STRING_sys
5320
5614
          {
5321
5615
            Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length,
5322
5616
                                                    system_charset_info);
5323
5617
          }
 
5618
        | WHERE expr
 
5619
          {
 
5620
            Select->where= $2;
 
5621
            if ($2)
 
5622
              $2->top_level_item();
 
5623
          }
5324
5624
        ;
5325
5625
 
5326
5626
/* A Oracle compatible synonym for show */
5335
5635
            lex->select_lex.db= 0;
5336
5636
            lex->verbose= 0;
5337
5637
            if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS))
5338
 
              DRIZZLE_YYABORT;
 
5638
              MYSQL_YYABORT;
5339
5639
          }
5340
5640
          opt_describe_column {}
5341
5641
        | describe_command opt_extended_describe
5372
5672
/* flush things */
5373
5673
 
5374
5674
flush:
5375
 
          FLUSH_SYM
 
5675
          FLUSH_SYM opt_no_write_to_binlog
5376
5676
          {
5377
5677
            LEX *lex=Lex;
5378
5678
            lex->sql_command= SQLCOM_FLUSH;
5379
5679
            lex->type= 0;
 
5680
            lex->no_write_to_binlog= $2;
5380
5681
          }
5381
5682
          flush_options
5382
5683
          {}
5405
5706
          { Lex->type|= REFRESH_SLAVE; }
5406
5707
        | MASTER_SYM
5407
5708
          { Lex->type|= REFRESH_MASTER; }
 
5709
        | DES_KEY_FILE
 
5710
          { Lex->type|= REFRESH_DES_KEY_FILE; }
5408
5711
        | RESOURCES
5409
5712
          { Lex->type|= REFRESH_USER_RESOURCES; }
5410
5713
        ;
5496
5799
/* import, export of files */
5497
5800
 
5498
5801
load:
5499
 
          LOAD data_file
 
5802
          LOAD data_or_xml
5500
5803
          {
5501
5804
            THD *thd= YYTHD;
5502
5805
            LEX *lex= thd->lex;
5513
5816
            lex->duplicates= DUP_ERROR;
5514
5817
            lex->ignore= 0;
5515
5818
            if (!(lex->exchange= new sql_exchange($7.str, 0, $2)))
5516
 
              DRIZZLE_YYABORT;
 
5819
              MYSQL_YYABORT;
5517
5820
          }
5518
5821
          opt_duplicate INTO
5519
5822
          {
5527
5830
            LEX *lex=Lex;
5528
5831
            if (!Select->add_table_to_list(YYTHD, $13, NULL, TL_OPTION_UPDATING,
5529
5832
                                           lex->lock_option))
5530
 
              DRIZZLE_YYABORT;
 
5833
              MYSQL_YYABORT;
5531
5834
            lex->field_list.empty();
5532
5835
            lex->update_list.empty();
5533
5836
            lex->value_list.empty();
5534
5837
          }
 
5838
          opt_load_data_charset
 
5839
          { Lex->exchange->cs= $15; }
 
5840
          opt_xml_rows_identified_by
5535
5841
          opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5536
5842
          opt_load_data_set_spec
5537
5843
          {}
5538
5844
        ;
5539
5845
 
5540
 
data_file:
5541
 
        DATA_SYM  { $$= FILETYPE_CSV; };
 
5846
data_or_xml:
 
5847
        DATA_SYM  { $$= FILETYPE_CSV; }
 
5848
        | XML_SYM { $$= FILETYPE_XML; }
 
5849
        ;
5542
5850
 
5543
5851
opt_local:
5544
5852
          /* empty */ { $$=0;}
5618
5926
          }
5619
5927
        ;
5620
5928
 
 
5929
opt_xml_rows_identified_by:
 
5930
        /* empty */ { }
 
5931
        | ROWS_SYM IDENTIFIED_SYM BY text_string
 
5932
          { Lex->exchange->line_term = $4; };
 
5933
 
5621
5934
opt_ignore_lines:
5622
5935
          /* empty */
5623
5936
        | IGNORE_SYM NUM lines_or_rows
5663
5976
          {
5664
5977
            LEX_STRING tmp;
5665
5978
            THD *thd= YYTHD;
5666
 
            const CHARSET_INFO * const cs_con= thd->variables.collation_connection;
5667
 
            const CHARSET_INFO * const cs_cli= thd->variables.character_set_client;
5668
 
            uint32_t repertoire= thd->lex->text_string_is_7bit &&
 
5979
            CHARSET_INFO *cs_con= thd->variables.collation_connection;
 
5980
            CHARSET_INFO *cs_cli= thd->variables.character_set_client;
 
5981
            uint repertoire= thd->lex->text_string_is_7bit &&
5669
5982
                             my_charset_is_ascii_based(cs_cli) ?
5670
5983
                             MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5671
5984
            if (thd->charset_is_collation_connection ||
5677
5990
            $$= new Item_string(tmp.str, tmp.length, cs_con,
5678
5991
                                DERIVATION_COERCIBLE, repertoire);
5679
5992
          }
 
5993
        | NCHAR_STRING
 
5994
          {
 
5995
            uint repertoire= Lex->text_string_is_7bit ?
 
5996
                             MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
 
5997
            assert(my_charset_is_ascii_based(national_charset_info));
 
5998
            $$= new Item_string($1.str, $1.length, national_charset_info,
 
5999
                                DERIVATION_COERCIBLE, repertoire);
 
6000
          }
5680
6001
        | UNDERSCORE_CHARSET TEXT_STRING
5681
6002
          {
5682
6003
            Item_string *str= new Item_string($2.str, $2.length, $1);
5695
6016
                 If the string has been pure ASCII so far,
5696
6017
                 check the new part.
5697
6018
              */
5698
 
              const CHARSET_INFO * const cs= YYTHD->variables.collation_connection;
 
6019
              CHARSET_INFO *cs= YYTHD->variables.collation_connection;
5699
6020
              item->collation.repertoire|= my_string_repertoire(cs,
5700
6021
                                                                $2.str,
5701
6022
                                                                $2.length);
5733
6054
          }
5734
6055
        ;
5735
6056
 
 
6057
param_marker:
 
6058
          PARAM_MARKER
 
6059
          {
 
6060
            THD *thd= YYTHD;
 
6061
            LEX *lex= thd->lex;
 
6062
            Lex_input_stream *lip= thd->m_lip;
 
6063
            Item_param *item;
 
6064
            if (! lex->parsing_options.allows_variable)
 
6065
            {
 
6066
              my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
 
6067
              MYSQL_YYABORT;
 
6068
            }
 
6069
            item= new Item_param((uint) (lip->get_tok_start() - thd->query));
 
6070
            if (!($$= item) || lex->param_list.push_back(item))
 
6071
            {
 
6072
              my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
 
6073
              MYSQL_YYABORT;
 
6074
            }
 
6075
          }
 
6076
        ;
 
6077
 
5736
6078
signed_literal:
5737
6079
          literal { $$ = $1; }
5738
6080
        | '+' NUM_literal { $$ = $2; }
5774
6116
            if (!item_str ||
5775
6117
                !item_str->check_well_formed_result(&item_str->str_value, true))
5776
6118
            {
5777
 
              DRIZZLE_YYABORT;
 
6119
              MYSQL_YYABORT;
5778
6120
            }
5779
6121
 
5780
6122
            item_str->set_repertoire_from_value();
5801
6143
            if (!item_str ||
5802
6144
                !item_str->check_well_formed_result(&item_str->str_value, true))
5803
6145
            {
5804
 
              DRIZZLE_YYABORT;
 
6146
              MYSQL_YYABORT;
5805
6147
            }
5806
6148
 
5807
6149
            item_str->set_cs_specified(true);
5831
6173
            $$= new Item_decimal($1.str, $1.length, YYTHD->charset());
5832
6174
            if (YYTHD->is_error())
5833
6175
            {
5834
 
              DRIZZLE_YYABORT;
 
6176
              MYSQL_YYABORT;
5835
6177
            }
5836
6178
          }
5837
6179
        | FLOAT_NUM
5839
6181
            $$ = new Item_float($1.str, $1.length);
5840
6182
            if (YYTHD->is_error())
5841
6183
            {
5842
 
              DRIZZLE_YYABORT;
 
6184
              MYSQL_YYABORT;
5843
6185
            }
5844
6186
          }
5845
6187
        ;
5857
6199
          ident '.' '*'
5858
6200
          {
5859
6201
            SELECT_LEX *sel= Select;
5860
 
            $$ = new Item_field(Lex->current_context(), NULL, $1.str, "*");
 
6202
            $$ = new Item_field(Lex->current_context(), NullS, $1.str, "*");
5861
6203
            sel->with_wild++;
5862
6204
          }
5863
6205
        | ident '.' ident '.' '*'
5864
6206
          {
5865
6207
            SELECT_LEX *sel= Select;
5866
6208
            $$ = new Item_field(Lex->current_context(), (YYTHD->client_capabilities &
5867
 
                                CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6209
                                CLIENT_NO_SCHEMA ? NullS : $1.str),
5868
6210
                                $3.str,"*");
5869
6211
            sel->with_wild++;
5870
6212
          }
5881
6223
              SELECT_LEX *sel=Select;
5882
6224
              $$= (sel->parsing_place != IN_HAVING ||
5883
6225
                  sel->get_in_sum_expr() > 0) ?
5884
 
                  (Item*) new Item_field(Lex->current_context(),
5885
 
                                         (const char *)NULL, NULL, $1.str) :
5886
 
                  (Item*) new Item_ref(Lex->current_context(),
5887
 
                                       (const char *)NULL, NULL, $1.str);
 
6226
                  (Item*) new Item_field(Lex->current_context(), NullS, NullS, $1.str) :
 
6227
                  (Item*) new Item_ref(Lex->current_context(), NullS, NullS, $1.str);
5888
6228
            }
5889
6229
          }
5890
6230
        | simple_ident_q { $$= $1; }
5896
6236
            SELECT_LEX *sel=Select;
5897
6237
            $$= (sel->parsing_place != IN_HAVING ||
5898
6238
                sel->get_in_sum_expr() > 0) ?
5899
 
                (Item*) new Item_field(Lex->current_context(),
5900
 
                                       (const char *)NULL, NULL, $1.str) :
5901
 
                (Item*) new Item_ref(Lex->current_context(),
5902
 
                                     (const char *)NULL, NULL, $1.str);
 
6239
                (Item*) new Item_field(Lex->current_context(), NullS, NullS, $1.str) :
 
6240
                (Item*) new Item_ref(Lex->current_context(), NullS, NullS, $1.str);
5903
6241
          }
5904
6242
        | simple_ident_q { $$= $1; }
5905
6243
        ;
5919
6257
              }
5920
6258
              $$= (sel->parsing_place != IN_HAVING ||
5921
6259
                  sel->get_in_sum_expr() > 0) ?
5922
 
                  (Item*) new Item_field(Lex->current_context(),
5923
 
                                         (const char *)NULL, $1.str, $3.str) :
5924
 
                  (Item*) new Item_ref(Lex->current_context(),
5925
 
                                       (const char *)NULL, $1.str, $3.str);
 
6260
                  (Item*) new Item_field(Lex->current_context(), NullS, $1.str, $3.str) :
 
6261
                  (Item*) new Item_ref(Lex->current_context(), NullS, $1.str, $3.str);
5926
6262
            }
5927
6263
          }
5928
6264
        | '.' ident '.' ident
5937
6273
            }
5938
6274
            $$= (sel->parsing_place != IN_HAVING ||
5939
6275
                sel->get_in_sum_expr() > 0) ?
5940
 
                (Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5941
 
                (Item*) new Item_ref(Lex->current_context(),
5942
 
                                     (const char *)NULL, $2.str, $4.str);
 
6276
                (Item*) new Item_field(Lex->current_context(), NullS, $2.str, $4.str) :
 
6277
                (Item*) new Item_ref(Lex->current_context(), NullS, $2.str, $4.str);
5943
6278
          }
5944
6279
        | ident '.' ident '.' ident
5945
6280
          {
5955
6290
                sel->get_in_sum_expr() > 0) ?
5956
6291
                (Item*) new Item_field(Lex->current_context(),
5957
6292
                                       (YYTHD->client_capabilities &
5958
 
                                       CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6293
                                       CLIENT_NO_SCHEMA ? NullS : $1.str),
5959
6294
                                       $3.str, $5.str) :
5960
6295
                (Item*) new Item_ref(Lex->current_context(),
5961
6296
                                     (YYTHD->client_capabilities &
5962
 
                                     CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6297
                                     CLIENT_NO_SCHEMA ? NullS : $1.str),
5963
6298
                                     $3.str, $5.str);
5964
6299
          }
5965
6300
        ;
5968
6303
          ident { $$=$1;}
5969
6304
        | ident '.' ident '.' ident
5970
6305
          {
5971
 
            TableList *table= (TableList*) Select->table_list.first;
 
6306
            TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
5972
6307
            if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5973
6308
            {
5974
6309
              my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5975
 
              DRIZZLE_YYABORT;
 
6310
              MYSQL_YYABORT;
5976
6311
            }
5977
6312
            if (my_strcasecmp(table_alias_charset, $3.str,
5978
6313
                              table->table_name))
5979
6314
            {
5980
6315
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
5981
 
              DRIZZLE_YYABORT;
 
6316
              MYSQL_YYABORT;
5982
6317
            }
5983
6318
            $$=$5;
5984
6319
          }
5985
6320
        | ident '.' ident
5986
6321
          {
5987
 
            TableList *table= (TableList*) Select->table_list.first;
 
6322
            TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
5988
6323
            if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5989
6324
            {
5990
6325
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
5991
 
              DRIZZLE_YYABORT;
 
6326
              MYSQL_YYABORT;
5992
6327
            }
5993
6328
            $$=$3;
5994
6329
          }
6009
6344
 
6010
6345
            if (thd->charset_is_system_charset)
6011
6346
            {
6012
 
              const CHARSET_INFO * const cs= system_charset_info;
 
6347
              CHARSET_INFO *cs= system_charset_info;
6013
6348
              int dummy_error;
6014
 
              uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
 
6349
              uint wlen= cs->cset->well_formed_len(cs, $1.str,
6015
6350
                                                   $1.str+$1.length,
6016
6351
                                                   $1.length, &dummy_error);
6017
6352
              if (wlen < $1.length)
6018
6353
              {
6019
6354
                my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
6020
6355
                         cs->csname, $1.str + wlen);
6021
 
                DRIZZLE_YYABORT;
 
6356
                MYSQL_YYABORT;
6022
6357
              }
6023
6358
              $$= $1;
6024
6359
            }
6113
6448
        | SAVEPOINT_SYM         {}
6114
6449
        | SECURITY_SYM          {}
6115
6450
        | SERVER_SYM            {}
 
6451
        | SIGNED_SYM            {}
6116
6452
        | SOCKET_SYM            {}
6117
6453
        | SLAVE                 {}
6118
6454
        | SONAME_SYM            {}
6119
6455
        | START_SYM             {}
6120
6456
        | STOP_SYM              {}
6121
6457
        | TRUNCATE_SYM          {}
 
6458
        | UNICODE_SYM           {}
 
6459
        | UNINSTALL_SYM         {}
 
6460
        | WRAPPER_SYM           {}
6122
6461
        | UPGRADE_SYM           {}
6123
6462
        ;
6124
6463
 
6143
6482
        | AVG_SYM                  {}
6144
6483
        | BINLOG_SYM               {}
6145
6484
        | BIT_SYM                  {}
6146
 
        | BLOCK_SIZE_SYM           {}
6147
6485
        | BLOCK_SYM                {}
6148
6486
        | BOOL_SYM                 {}
6149
6487
        | BOOLEAN_SYM              {}
6151
6489
        | CASCADED                 {}
6152
6490
        | CHAIN_SYM                {}
6153
6491
        | CHANGED                  {}
 
6492
        | CIPHER_SYM               {}
 
6493
        | CLIENT_SYM               {}
6154
6494
        | COALESCE                 {}
 
6495
        | CODE_SYM                 {}
6155
6496
        | COLLATION_SYM            {}
6156
6497
        | COLUMN_FORMAT_SYM        {}
6157
6498
        | COLUMNS                  {}
6163
6504
        | CONNECTION_SYM           {}
6164
6505
        | CONSISTENT_SYM           {}
6165
6506
        | CONTEXT_SYM              {}
 
6507
        | CONTRIBUTORS_SYM         {}
 
6508
        | CPU_SYM                  {}
6166
6509
        | CUBE_SYM                 {}
6167
6510
        | DATA_SYM                 {}
6168
6511
        | DATAFILE_SYM             {}
6169
6512
        | DATETIME                 {}
6170
6513
        | DATE_SYM                 {}
6171
6514
        | DAY_SYM                  {}
 
6515
        | DEFINER_SYM              {}
6172
6516
        | DELAY_KEY_WRITE_SYM      {}
 
6517
        | DES_KEY_FILE             {}
6173
6518
        | DIRECTORY_SYM            {}
6174
6519
        | DISABLE_SYM              {}
6175
6520
        | DISCARD                  {}
6179
6524
        | ENDS_SYM                 {}
6180
6525
        | ENUM                     {}
6181
6526
        | ENGINE_SYM               {}
 
6527
        | ENGINES_SYM              {}
6182
6528
        | ERRORS                   {}
6183
6529
        | ESCAPE_SYM               {}
 
6530
        | EVENTS_SYM               {}
 
6531
        | EVERY_SYM                {}
6184
6532
        | EXCLUSIVE_SYM            {}
6185
6533
        | EXTENDED_SYM             {}
6186
6534
        | EXTENT_SIZE_SYM          {}
6202
6550
        | IMPORT                   {}
6203
6551
        | INDEXES                  {}
6204
6552
        | INITIAL_SIZE_SYM         {}
 
6553
        | IO_SYM                   {}
 
6554
        | IPC_SYM                  {}
6205
6555
        | ISOLATION                {}
 
6556
        | ISSUER_SYM               {}
6206
6557
        | INSERT_METHOD            {}
6207
6558
        | KEY_BLOCK_SIZE           {}
6208
6559
        | LAST_SYM                 {}
6242
6593
        | NAME_SYM                 {}
6243
6594
        | NAMES_SYM                {}
6244
6595
        | NATIONAL_SYM             {}
 
6596
        | NCHAR_SYM                {}
6245
6597
        | NEXT_SYM                 {}
6246
6598
        | NEW_SYM                  {}
6247
6599
        | NO_WAIT_SYM              {}
6248
6600
        | NODEGROUP_SYM            {}
6249
6601
        | NONE_SYM                 {}
6250
6602
        | NOWAIT_SYM               {}
 
6603
        | NVARCHAR_SYM             {}
6251
6604
        | OFFLINE_SYM              {}
6252
6605
        | OFFSET_SYM               {}
6253
6606
        | ONE_SHOT_SYM             {}
6257
6610
        | PAGE_SYM                 {}
6258
6611
        | PAGE_CHECKSUM_SYM        {}
6259
6612
        | PARTIAL                  {}
 
6613
        | PASSWORD                 {}
6260
6614
        | PHASE_SYM                {}
6261
6615
        | PLUGIN_SYM               {}
6262
6616
        | PLUGINS_SYM              {}
6264
6618
        | PREV_SYM                 {}
6265
6619
        | PROCESS                  {}
6266
6620
        | PROCESSLIST_SYM          {}
 
6621
        | PROFILE_SYM              {}
 
6622
        | PROFILES_SYM             {}
6267
6623
        | QUARTER_SYM              {}
6268
6624
        | QUERY_SYM                {}
6269
6625
        | QUICK                    {}
6339
6695
        | WEEK_SYM                 {}
6340
6696
        | WEIGHT_STRING_SYM        {}
6341
6697
        | WORK_SYM                 {}
 
6698
        | XML_SYM                  {}
6342
6699
        | YEAR_SYM                 {}
6343
6700
        ;
6344
6701
 
6428
6785
            lex->var_list.push_back(new set_var(lex->option_type,
6429
6786
                                                find_sys_var(YYTHD, "tx_isolation"),
6430
6787
                                                &null_lex_str,
6431
 
                                                new Item_int((int32_t) $5)));
 
6788
                                                new Item_int((int32) $5)));
6432
6789
          }
6433
6790
        ;
6434
6791
 
6442
6799
            LEX *lex=Lex;
6443
6800
            lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
6444
6801
          }
6445
 
        | NAMES_SYM COLLATE_SYM collation_name_or_default
 
6802
        | charset old_or_new_charset_name_or_default
 
6803
          {
 
6804
            THD *thd= YYTHD;
 
6805
            LEX *lex= thd->lex;
 
6806
            $2= $2 ? $2: global_system_variables.character_set_client;
 
6807
            lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
 
6808
          }
 
6809
        | NAMES_SYM charset_name_or_default opt_collate
6446
6810
          {
6447
6811
            LEX *lex= Lex;
6448
 
            $3= $3 ? $3 : global_system_variables.character_set_client;
 
6812
            $2= $2 ? $2 : global_system_variables.character_set_client;
 
6813
            $3= $3 ? $3 : $2;
 
6814
            if (!my_charset_same($2,$3))
 
6815
            {
 
6816
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
 
6817
                       $3->name, $2->csname);
 
6818
              MYSQL_YYABORT;
 
6819
            }
6449
6820
            lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
6450
6821
          }
6451
6822
        ;
6460
6831
              /* Not an SP local variable */
6461
6832
              sys_var *tmp=find_sys_var(thd, $1.str, $1.length);
6462
6833
              if (!tmp)
6463
 
                DRIZZLE_YYABORT;
 
6834
                MYSQL_YYABORT;
6464
6835
              $$.var= tmp;
6465
6836
              $$.base_name= null_lex_str;
6466
6837
            }
6470
6841
            if (check_reserved_words(&$1))
6471
6842
            {
6472
6843
              my_parse_error(ER(ER_SYNTAX_ERROR));
6473
 
              DRIZZLE_YYABORT;
 
6844
              MYSQL_YYABORT;
6474
6845
            }
6475
6846
            {
6476
6847
              sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6477
6848
              if (!tmp)
6478
 
                DRIZZLE_YYABORT;
 
6849
                MYSQL_YYABORT;
6479
6850
              if (!tmp->is_struct())
6480
6851
                my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6481
6852
              $$.var= tmp;
6486
6857
          {
6487
6858
            sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6488
6859
            if (!tmp)
6489
 
              DRIZZLE_YYABORT;
 
6860
              MYSQL_YYABORT;
6490
6861
            if (!tmp->is_struct())
6491
6862
              my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6492
6863
            $$.var= tmp;
6547
6918
table_lock:
6548
6919
        table_ident opt_table_alias table_lock_info
6549
6920
        {
6550
 
          TableList *tlist;
 
6921
          TABLE_LIST *tlist;
6551
6922
          if (!(tlist= Select->add_table_to_list(YYTHD, $1, $2, 0,
6552
6923
                                                 $3.lock_type)))
6553
 
            DRIZZLE_YYABORT; /* purecov: inspected */
 
6924
            MYSQL_YYABORT; /* purecov: inspected */
6554
6925
          tlist->lock_timeout= $3.lock_timeout;
6555
6926
          /* Store the requested lock method for later warning. */
6556
6927
          tlist->lock_transactional= $3.lock_transactional;
6716
7087
          UNION_SYM union_option
6717
7088
          {
6718
7089
            if (add_select_to_union_list(Lex, (bool)$2))
6719
 
              DRIZZLE_YYABORT;
 
7090
              MYSQL_YYABORT;
6720
7091
          }
6721
7092
          select_init
6722
7093
          {
6786
7157
          UNION_SYM union_option 
6787
7158
          {
6788
7159
            if (add_select_to_union_list(Lex, (bool)$3))
6789
 
              DRIZZLE_YYABORT;
 
7160
              MYSQL_YYABORT;
6790
7161
          }
6791
7162
          query_specification
6792
7163
          {
6810
7181
               lex->sql_command == (int)SQLCOM_PURGE)
6811
7182
            {
6812
7183
              my_parse_error(ER(ER_SYNTAX_ERROR));
6813
 
              DRIZZLE_YYABORT;
 
7184
              MYSQL_YYABORT;
6814
7185
            }
6815
7186
            /* 
6816
7187
              we are making a "derived table" for the parenthesis
6820
7191
              SELECT * FROM ((SELECT ...) UNION ...)
6821
7192
            */
6822
7193
            if (mysql_new_select(Lex, 1))
6823
 
              DRIZZLE_YYABORT;
 
7194
              MYSQL_YYABORT;
6824
7195
          }
6825
7196
        ;
6826
7197