~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2008-07-14 22:40:46 UTC
  • Revision ID: brian@tangent.org-20080714224046-x183907w9wp1txwv
Removed sql_manager. Ever heard of just setting up the OS to sync when you
want it to?

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