~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_yacc.yy

  • Committer: Monty Taylor
  • Date: 2008-07-05 23:05:08 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: monty@inaugust.com-20080705230508-9txkg702oln6hxjl
First large swath at getting handler stuff clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#define YYLEX_PARAM yythd
30
30
#define YYTHD ((THD *)yythd)
31
31
 
32
 
#define YYENABLE_NLS 0
33
 
#define YYLTYPE_IS_TRIVIAL 0
34
 
 
35
 
#define DRIZZLE_YACC
 
32
#define MYSQL_YACC
36
33
#define YYINITDEPTH 100
37
34
#define YYMAXDEPTH 3200                        /* Because of 64K stack */
38
35
#define Lex (YYTHD->lex)
39
36
#define Select Lex->current_select
40
 
#include <drizzled/server_includes.h>
 
37
#include "mysql_priv.h"
 
38
#include "slave.h"
41
39
#include "lex_symbol.h"
42
 
#include <storage/myisam/myisam.h>
43
 
#include <drizzled/drizzled_error_messages.h>
 
40
#include "item_create.h"
 
41
#include <myisam.h>
44
42
 
45
43
int yylex(void *yylval, void *yythd);
46
44
 
58
56
    }                                         \
59
57
  }
60
58
 
61
 
#define DRIZZLE_YYABORT                         \
 
59
#define MYSQL_YYABORT                         \
62
60
  do                                          \
63
61
  {                                           \
64
62
    LEX::cleanup_lex_after_parse_error(YYTHD);\
65
63
    YYABORT;                                  \
66
64
  } while (0)
67
65
 
68
 
#define DRIZZLE_YYABORT_UNLESS(A)         \
 
66
#define MYSQL_YYABORT_UNLESS(A)         \
69
67
  if (!(A))                             \
70
68
  {                                     \
71
69
    my_parse_error(ER(ER_SYNTAX_ERROR));\
72
 
    DRIZZLE_YYABORT;                      \
 
70
    MYSQL_YYABORT;                      \
73
71
  }
74
72
 
75
73
/*
94
92
#define __attribute__(X)
95
93
#endif
96
94
 
 
95
 
 
96
#ifndef DBUG_OFF
 
97
#define YYDEBUG 1
 
98
#else
97
99
#define YYDEBUG 0
 
100
#endif
98
101
 
99
102
/**
100
103
  @brief Push an error message into MySQL error stack with line
127
130
  condition occurs. This function is not invoked when the
128
131
  parser is requested to abort by semantic action code
129
132
  by means of YYABORT or YYACCEPT macros. This is why these
130
 
  macros should not be used (use DRIZZLE_YYABORT/DRIZZLE_YYACCEPT
 
133
  macros should not be used (use MYSQL_YYABORT/MYSQL_YYACCEPT
131
134
  instead).
132
135
 
133
136
  The parser will abort immediately after invoking this callback.
135
138
  This function is not for use in semantic actions and is internal to
136
139
  the parser, as it performs some pre-return cleanup. 
137
140
  In semantic actions, please use my_parse_error or my_error to
138
 
  push an error into the error stack and DRIZZLE_YYABORT
 
141
  push an error into the error stack and MYSQL_YYABORT
139
142
  to abort from the parser.
140
143
*/
141
144
 
156
159
  my_parse_error(s);
157
160
}
158
161
 
 
162
 
 
163
#ifndef DBUG_OFF
 
164
void turn_parser_debug_on()
 
165
{
 
166
  /*
 
167
     MYSQLdebug is in sql/sql_yacc.cc, in bison generated code.
 
168
     Turning this option on is **VERY** verbose, and should be
 
169
     used when investigating a syntax error problem only.
 
170
 
 
171
     The syntax to run with bison traces is as follows :
 
172
     - Starting a server manually :
 
173
       mysqld --debug="d,parser_debug" ...
 
174
     - Running a test :
 
175
       mysql-test-run.pl --mysqld="--debug=d,parser_debug" ...
 
176
 
 
177
     The result will be in the process stderr (var/log/master.err)
 
178
   */
 
179
 
 
180
  extern int yydebug;
 
181
  yydebug= 1;
 
182
}
 
183
#endif
 
184
 
159
185
/**
160
186
  Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
161
187
  See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
194
220
 
195
221
  Item *result;
196
222
 
 
223
  DBUG_ENTER("handle_sql2003_note184_exception");
 
224
 
197
225
  if (expr->type() == Item::SUBSELECT_ITEM)
198
226
  {
199
227
    Item_subselect *expr2 = (Item_subselect*) expr;
217
245
      if (! equal)
218
246
        result = negate_expression(thd, result);
219
247
 
220
 
      return(result);
 
248
      DBUG_RETURN(result);
221
249
    }
222
250
  }
223
251
 
226
254
  else
227
255
    result= new (thd->mem_root) Item_func_ne(left, expr);
228
256
 
229
 
  return(result);
 
257
  DBUG_RETURN(result);
230
258
}
231
259
 
232
260
/**
250
278
  {
251
279
    /* Only the last SELECT can have  INTO...... */
252
280
    my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
253
 
    return true;
 
281
    return TRUE;
254
282
  }
255
283
  if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
256
284
  {
257
285
    my_parse_error(ER(ER_SYNTAX_ERROR));
258
 
    return true;
 
286
    return TRUE;
259
287
  }
260
288
  /* This counter shouldn't be incremented for UNION parts */
261
289
  lex->nest_level--;
262
290
  if (mysql_new_select(lex, 0))
263
 
    return true;
 
291
    return TRUE;
264
292
  mysql_init_select(lex);
265
293
  lex->current_select->linkage=UNION_TYPE;
266
294
  if (is_union_distinct) /* UNION DISTINCT - remember position */
267
295
    lex->current_select->master_unit()->union_distinct=
268
296
      lex->current_select;
269
 
  return false;
 
297
  return FALSE;
270
298
}
271
299
 
272
300
/**
282
310
  if (sel->set_braces(1))
283
311
  {
284
312
    my_parse_error(ER(ER_SYNTAX_ERROR));
285
 
    return true;
 
313
    return TRUE;
286
314
  }
287
315
  if (sel->linkage == UNION_TYPE &&
288
316
      !sel->master_unit()->first_select()->braces &&
290
318
      UNION_TYPE)
291
319
  {
292
320
    my_parse_error(ER(ER_SYNTAX_ERROR));
293
 
    return true;
 
321
    return TRUE;
294
322
  }
295
323
  if (sel->linkage == UNION_TYPE &&
296
324
      sel->olap != UNSPECIFIED_OLAP_TYPE &&
297
325
      sel->master_unit()->fake_select_lex)
298
326
  {
299
327
    my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
300
 
    return true;
 
328
    return TRUE;
301
329
  }
302
330
  /* select in braces, can't contain global parameters */
303
331
  if (sel->master_unit()->fake_select_lex)
304
332
    sel->master_unit()->global_parameters=
305
333
      sel->master_unit()->fake_select_lex;
306
 
  return false;
 
334
  return FALSE;
307
335
}
308
336
 
309
337
%}
310
338
%union {
311
339
  int  num;
312
340
  ulong ulong_num;
313
 
  uint64_t ulonglong_number;
314
 
  int64_t longlong_number;
 
341
  ulonglong ulonglong_number;
 
342
  longlong longlong_number;
315
343
  LEX_STRING lex_str;
316
344
  LEX_STRING *lex_str_ptr;
317
345
  LEX_SYMBOL symbol;
323
351
  List<String> *string_list;
324
352
  String *string;
325
353
  Key_part_spec *key_part;
326
 
  TableList *table_list;
 
354
  TABLE_LIST *table_list;
327
355
  udf_func *udf;
328
356
  LEX_USER *lex_user;
329
357
  struct sys_var_with_base variable;
337
365
  enum enum_tx_isolation tx_isolation;
338
366
  enum Cast_target cast_type;
339
367
  enum ha_choice choice;
340
 
  const CHARSET_INFO *charset;
 
368
  CHARSET_INFO *charset;
341
369
  thr_lock_type lock_type;
342
370
  struct st_table_lock_info table_lock_info;
343
371
  interval_type interval, interval_time_st;
344
 
  enum enum_drizzle_timestamp_type date_time_type;
 
372
  timestamp_type date_time_type;
345
373
  st_select_lex *select_lex;
346
374
  chooser_compare_func_creator boolfunc2creator;
347
375
  struct sp_cond_type *spcondtype;
360
388
 
361
389
%pure_parser                                    /* We have threads */
362
390
/*
363
 
  Currently there are 93 shift/reduce conflicts.
 
391
  Currently there are 100 shift/reduce conflicts.
364
392
  We should not introduce new conflicts any more.
365
393
*/
366
 
%expect 93
 
394
%expect 100
367
395
 
368
396
/*
369
397
   Comments for TOKENS.
393
421
%token  ALL                           /* SQL-2003-R */
394
422
%token  ALTER                         /* SQL-2003-R */
395
423
%token  ANALYZE_SYM
 
424
%token  AND_AND_SYM                   /* OPERATOR */
396
425
%token  AND_SYM                       /* SQL-2003-R */
397
426
%token  ANY_SYM                       /* SQL-2003-R */
398
427
%token  AS                            /* SQL-2003-R */
412
441
%token  BINARY                        /* SQL-2003-R */
413
442
%token  BINLOG_SYM
414
443
%token  BIN_NUM
 
444
%token  BIT_AND                       /* MYSQL-FUNC */
 
445
%token  BIT_OR                        /* MYSQL-FUNC */
415
446
%token  BIT_SYM                       /* MYSQL-FUNC */
 
447
%token  BIT_XOR                       /* MYSQL-FUNC */
416
448
%token  BLOB_SYM                      /* SQL-2003-R */
417
 
%token  BLOCK_SIZE_SYM
418
449
%token  BLOCK_SYM
419
450
%token  BOOLEAN_SYM                   /* SQL-2003-R */
420
451
%token  BOOL_SYM
435
466
%token  CHAR_SYM                      /* SQL-2003-R */
436
467
%token  CHECKSUM_SYM
437
468
%token  CHECK_SYM                     /* SQL-2003-R */
 
469
%token  CIPHER_SYM
 
470
%token  CLIENT_SYM
438
471
%token  CLOSE_SYM                     /* SQL-2003-R */
439
472
%token  COALESCE                      /* SQL-2003-N */
 
473
%token  CODE_SYM
440
474
%token  COLLATE_SYM                   /* SQL-2003-R */
441
475
%token  COLLATION_SYM                 /* SQL-2003-N */
442
476
%token  COLUMNS
455
489
%token  CONTAINS_SYM                  /* SQL-2003-N */
456
490
%token  CONTEXT_SYM
457
491
%token  CONTINUE_SYM                  /* SQL-2003-R */
 
492
%token  CONTRIBUTORS_SYM
458
493
%token  CONVERT_SYM                   /* SQL-2003-N */
459
494
%token  COUNT_SYM                     /* SQL-2003-N */
 
495
%token  CPU_SYM
460
496
%token  CREATE                        /* SQL-2003-R */
461
497
%token  CROSS                         /* SQL-2003-R */
462
498
%token  CUBE_SYM                      /* SQL-2003-R */
482
518
%token  DECIMAL_SYM                   /* SQL-2003-R */
483
519
%token  DECLARE_SYM                   /* SQL-2003-R */
484
520
%token  DEFAULT                       /* SQL-2003-R */
 
521
%token  DEFINER_SYM
485
522
%token  DELAYED_SYM
486
523
%token  DELAY_KEY_WRITE_SYM
487
524
%token  DELETE_SYM                    /* SQL-2003-R */
488
525
%token  DESC                          /* SQL-2003-N */
489
526
%token  DESCRIBE                      /* SQL-2003-R */
 
527
%token  DES_KEY_FILE
490
528
%token  DETERMINISTIC_SYM             /* SQL-2003-R */
491
529
%token  DIRECTORY_SYM
492
530
%token  DISABLE_SYM
493
531
%token  DISCARD
 
532
%token  DISK_SYM
494
533
%token  DISTINCT                      /* SQL-2003-R */
495
534
%token  DIV_SYM
496
535
%token  DOUBLE_SYM                    /* SQL-2003-R */
506
545
%token  END                           /* SQL-2003-R */
507
546
%token  ENDS_SYM
508
547
%token  END_OF_INPUT                  /* INTERNAL */
 
548
%token  ENGINES_SYM
509
549
%token  ENGINE_SYM
510
550
%token  ENUM
511
551
%token  EQ                            /* OPERATOR */
513
553
%token  ERRORS
514
554
%token  ESCAPED
515
555
%token  ESCAPE_SYM                    /* SQL-2003-R */
 
556
%token  EVENTS_SYM
 
557
%token  EVERY_SYM                     /* SQL-2003-N */
516
558
%token  EXCLUSIVE_SYM
517
559
%token  EXISTS                        /* SQL-2003-R */
518
560
%token  EXIT_SYM
528
570
%token  FIRST_SYM                     /* SQL-2003-N */
529
571
%token  FIXED_SYM
530
572
%token  FLOAT_NUM
 
573
%token  FLOAT_SYM                     /* SQL-2003-R */
531
574
%token  FLUSH_SYM
532
575
%token  FORCE_SYM
533
576
%token  FOREIGN                       /* SQL-2003-R */
573
616
%token  INTO                          /* SQL-2003-R */
574
617
%token  INT_SYM                       /* SQL-2003-R */
575
618
%token  IN_SYM                        /* SQL-2003-R */
 
619
%token  IO_SYM
 
620
%token  IPC_SYM
576
621
%token  IS                            /* SQL-2003-R */
577
622
%token  ISOLATION                     /* SQL-2003-R */
 
623
%token  ISSUER_SYM
578
624
%token  ITERATE_SYM
579
625
%token  JOIN_SYM                      /* SQL-2003-R */
580
626
%token  KEYS
601
647
%token  LOCK_SYM
602
648
%token  LOGFILE_SYM
603
649
%token  LOGS_SYM
 
650
%token  LONGBLOB
 
651
%token  LONGTEXT
604
652
%token  LONG_NUM
605
653
%token  LONG_SYM
606
654
%token  LOOP_SYM
625
673
%token  MAX_UPDATES_PER_HOUR
626
674
%token  MAX_USER_CONNECTIONS_SYM
627
675
%token  MAX_VALUE_SYM                 /* SQL-2003-N */
 
676
%token  MEDIUMBLOB
 
677
%token  MEDIUMINT
 
678
%token  MEDIUMTEXT
628
679
%token  MEDIUM_SYM
 
680
%token  MEMORY_SYM
629
681
%token  MERGE_SYM                     /* SQL-2003-R */
630
682
%token  MICROSECOND_SYM               /* MYSQL-FUNC */
631
683
%token  MIGRATE_SYM
643
695
%token  NAME_SYM                      /* SQL-2003-N */
644
696
%token  NATIONAL_SYM                  /* SQL-2003-R */
645
697
%token  NATURAL                       /* SQL-2003-R */
 
698
%token  NCHAR_STRING
 
699
%token  NCHAR_SYM                     /* SQL-2003-R */
646
700
%token  NE                            /* OPERATOR */
647
701
%token  NEG
648
702
%token  NEW_SYM                       /* SQL-2003-R */
658
712
%token  NULL_SYM                      /* SQL-2003-R */
659
713
%token  NUM
660
714
%token  NUMERIC_SYM                   /* SQL-2003-R */
 
715
%token  NVARCHAR_SYM
661
716
%token  OFFLINE_SYM
662
717
%token  OFFSET_SYM
 
718
%token  OLD_PASSWORD
663
719
%token  ON                            /* SQL-2003-R */
664
720
%token  ONE_SHOT_SYM
665
721
%token  ONE_SYM
678
734
%token  PAGE_SYM
679
735
%token  PAGE_CHECKSUM_SYM
680
736
%token  PARAM_MARKER
681
 
%token  PARSE_VCOL_EXPR_SYM
682
737
%token  PARTIAL                       /* SQL-2003-N */
 
738
%token  PASSWORD
683
739
%token  PHASE_SYM
684
740
%token  PLUGINS_SYM
685
741
%token  PLUGIN_SYM
686
742
%token  POINT_SYM
 
743
%token  POLYGON
687
744
%token  PORT_SYM
688
745
%token  POSITION_SYM                  /* SQL-2003-N */
689
746
%token  PRECISION                     /* SQL-2003-R */
691
748
%token  PRIMARY_SYM                   /* SQL-2003-R */
692
749
%token  PROCESS
693
750
%token  PROCESSLIST_SYM
 
751
%token  PROFILE_SYM
 
752
%token  PROFILES_SYM
694
753
%token  PURGE
695
754
%token  QUARTER_SYM
696
755
%token  QUERY_SYM
751
810
%token  SET                           /* SQL-2003-R */
752
811
%token  SET_VAR
753
812
%token  SHARE_SYM
 
813
%token  SHIFT_LEFT                    /* OPERATOR */
 
814
%token  SHIFT_RIGHT                   /* OPERATOR */
754
815
%token  SHOW
755
816
%token  SHUTDOWN
 
817
%token  SIGNED_SYM
756
818
%token  SIMPLE_SYM                    /* SQL-2003-N */
757
819
%token  SLAVE
 
820
%token  SMALLINT                      /* SQL-2003-R */
758
821
%token  SNAPSHOT_SYM
759
822
%token  SOCKET_SYM
760
823
%token  SONAME_SYM
777
840
%token  STD_SYM
778
841
%token  STOP_SYM
779
842
%token  STORAGE_SYM
780
 
%token  STORED_SYM
781
843
%token  STRAIGHT_JOIN
782
844
%token  STRING_SYM
783
845
%token  SUBDATE_SYM
805
867
%token  TIMESTAMP_ADD
806
868
%token  TIMESTAMP_DIFF
807
869
%token  TIME_SYM                      /* SQL-2003-R */
 
870
%token  TINYBLOB
 
871
%token  TINYINT
 
872
%token  TINYTEXT
808
873
%token  TO_SYM                        /* SQL-2003-R */
809
874
%token  TRAILING                      /* SQL-2003-R */
810
875
%token  TRANSACTION_SYM
820
885
%token  UNDERSCORE_CHARSET
821
886
%token  UNDOFILE_SYM
822
887
%token  UNDO_SYM                      /* FUTURE-USE */
 
888
%token  UNICODE_SYM
 
889
%token  UNINSTALL_SYM
823
890
%token  UNION_SYM                     /* SQL-2003-R */
824
891
%token  UNIQUE_SYM
825
892
%token  UNKNOWN_SYM                   /* SQL-2003-R */
826
893
%token  UNLOCK_SYM
 
894
%token  UNSIGNED
827
895
%token  UNTIL_SYM
828
896
%token  UPDATE_SYM                    /* SQL-2003-R */
829
897
%token  UPGRADE_SYM
843
911
%token  VARIANCE_SYM
844
912
%token  VARYING                       /* SQL-2003-R */
845
913
%token  VAR_SAMP_SYM
846
 
%token  VIRTUAL_SYM
847
914
%token  WAIT_SYM
848
915
%token  WARNINGS
849
916
%token  WEEK_SYM
851
918
%token  WHEN_SYM                      /* SQL-2003-R */
852
919
%token  WHERE                         /* SQL-2003-R */
853
920
%token  WITH                          /* SQL-2003-R */
 
921
%token  WITH_CUBE_SYM                 /* INTERNAL */
854
922
%token  WITH_ROLLUP_SYM               /* INTERNAL */
855
923
%token  WORK_SYM                      /* SQL-2003-N */
 
924
%token  WRAPPER_SYM
856
925
%token  WRITE_SYM                     /* SQL-2003-N */
 
926
%token  XML_SYM
857
927
%token  XOR
858
928
%token  YEAR_MONTH_SYM
859
929
%token  YEAR_SYM                      /* SQL-2003-R */
 
930
%token  ZEROFILL
860
931
 
861
932
%left   JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT
862
933
/* A dummy token to force the priority of table_ref production in a join. */
864
935
%left   SET_VAR
865
936
%left   OR_SYM
866
937
%left   XOR
867
 
%left   AND_SYM
 
938
%left   AND_SYM AND_AND_SYM
868
939
%left   BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
869
940
%left   EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE IN_SYM
 
941
%left   '|'
 
942
%left   '&'
 
943
%left   SHIFT_LEFT SHIFT_RIGHT
870
944
%left   '-' '+'
871
945
%left   '*' '/' '%' DIV_SYM MOD_SYM
872
 
%left   NEG
 
946
%left   '^'
 
947
%left   NEG '~'
873
948
%right  NOT_SYM
874
949
%right  BINARY COLLATE_SYM
875
950
%left  INTERVAL_SYM
878
953
        IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
879
954
        LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text
880
955
        IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
881
 
        opt_component key_cache_name
 
956
        NCHAR_STRING opt_component key_cache_name
882
957
        BIN_NUM TEXT_STRING_filesystem ident_or_empty
883
958
        opt_constraint constraint opt_ident
884
959
 
895
970
        text_string opt_gconcat_separator
896
971
 
897
972
%type <num>
898
 
        type int_type real_type order_dir field_def
 
973
        type int_type real_type order_dir
899
974
        if_exists opt_local opt_table_options table_options
900
 
        table_option opt_if_not_exists
 
975
        table_option opt_if_not_exists opt_no_write_to_binlog
901
976
        opt_temporary all_or_any opt_distinct
902
977
        union_option
903
978
        start_transaction_opts opt_chain opt_release
934
1009
        predicate bit_expr
935
1010
        table_wild simple_expr udf_expr
936
1011
        expr_or_default set_expr_or_default
 
1012
        param_marker 
937
1013
        signed_literal now_or_signed_literal opt_escape
938
1014
        simple_ident_nospvar simple_ident_q
939
1015
        field_or_var limit_option
989
1065
%type <symbol> keyword keyword_sp
990
1066
 
991
1067
%type <charset>
 
1068
        opt_collate
 
1069
        charset_name
 
1070
        charset_name_or_default
 
1071
        old_or_new_charset_name
 
1072
        old_or_new_charset_name_or_default
992
1073
        collation_name
993
1074
        collation_name_or_default
 
1075
        opt_load_data_charset
994
1076
        UNDERSCORE_CHARSET
995
1077
 
996
1078
%type <variable> internal_variable_name
1014
1096
        keycache_list assign_to_keycache
1015
1097
        select_item_list select_item values_list no_braces
1016
1098
        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
 
1099
        opt_precision opt_ignore opt_column opt_restrict
 
1100
        set lock unlock string_list field_options field_option
 
1101
        field_opt_list opt_binary table_lock_list table_lock
1020
1102
        ref_list opt_match_clause opt_on_update_delete use
1021
 
        opt_delete_options opt_delete_option varchar
 
1103
        opt_delete_options opt_delete_option varchar nchar nvarchar
1022
1104
        opt_outer table_list table_name table_alias_ref_list table_alias_ref
1023
1105
        opt_option opt_place
1024
1106
        opt_attribute opt_attribute_list attribute
1035
1117
        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
1036
1118
        binlog_base64_event
1037
1119
        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
1120
END_OF_INPUT
1041
1121
 
1042
1122
%type <index_hint> index_hint_type
1043
1123
%type <num> index_hint_clause
1044
 
%type <filetype> data_file
 
1124
%type <filetype> data_or_xml
1045
1125
 
1046
1126
%type <NONE>
1047
1127
        '-' '+' '*' '/' '%' '(' ')'
1048
 
        ',' '!' '{' '}' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
1049
 
        THEN_SYM WHEN_SYM DIV_SYM MOD_SYM DELETE_SYM
 
1128
        ',' '!' '{' '}' '&' '|' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
 
1129
        THEN_SYM WHEN_SYM DIV_SYM MOD_SYM AND_AND_SYM DELETE_SYM
1050
1130
%%
1051
1131
 
1052
1132
/*
1074
1154
          END_OF_INPUT
1075
1155
          {
1076
1156
            THD *thd= YYTHD;
1077
 
            if (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))
 
1157
            if (!thd->bootstrap &&
 
1158
              (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
1078
1159
            {
1079
1160
              my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
1080
 
              DRIZZLE_YYABORT;
 
1161
              MYSQL_YYABORT;
1081
1162
            }
1082
1163
            else
1083
1164
            {
1112
1193
        | lock
1113
1194
        | optimize
1114
1195
        | keycache
1115
 
        | parse_vcol_expr
1116
1196
        | purge
1117
1197
        | release
1118
1198
        | rename
1140
1220
          {
1141
1221
            LEX *lex = Lex;
1142
1222
            lex->sql_command = SQLCOM_CHANGE_MASTER;
1143
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
1223
            bzero((char*) &lex->mi, sizeof(lex->mi));
1144
1224
          }
1145
1225
          master_defs
1146
1226
          {}
1179
1259
                Lex->mi.heartbeat_period < 0.0)
1180
1260
            {
1181
1261
              char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1182
 
              sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
 
1262
              my_sprintf(buf, (buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD));
1183
1263
              my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1184
1264
                       MYF(0),
1185
1265
                       " is negative or exceeds the maximum ",
1186
1266
                       buf); 
1187
 
              DRIZZLE_YYABORT;
 
1267
              MYSQL_YYABORT;
1188
1268
            }
1189
1269
            if (Lex->mi.heartbeat_period > slave_net_timeout)
1190
1270
            {
1191
 
              push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1271
              push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1192
1272
                                  ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1193
1273
                                  ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1194
1274
                                  " exceeds the value of `slave_net_timeout' sec.",
1199
1279
            {
1200
1280
              if (Lex->mi.heartbeat_period != 0.0)
1201
1281
              {
1202
 
                push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1282
                push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1203
1283
                                    ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1204
1284
                                    ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1205
1285
                                    " is less than 1 msec.",
1234
1314
               from 0" (4 in fact), unspecified means "don't change the position
1235
1315
               (keep the preceding value)").
1236
1316
            */
1237
 
            Lex->mi.pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
 
1317
            Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1238
1318
          }
1239
1319
        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1240
1320
          {
1244
1324
          {
1245
1325
            Lex->mi.relay_log_pos = $3;
1246
1326
            /* 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);
 
1327
            Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
1248
1328
          }
1249
1329
        ;
1250
1330
 
1259
1339
            if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
1260
1340
                                                   TL_OPTION_UPDATING,
1261
1341
                                                   TL_WRITE))
1262
 
              DRIZZLE_YYABORT;
 
1342
              MYSQL_YYABORT;
1263
1343
            lex->alter_info.reset();
1264
1344
            lex->col_list.empty();
1265
 
            lex->change=NULL;
1266
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
1345
            lex->change=NullS;
 
1346
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
1267
1347
            lex->create_info.options=$2 | $4;
1268
1348
            lex->create_info.db_type= ha_default_handlerton(thd);
1269
1349
            lex->create_info.default_table_charset= NULL;
1277
1357
            if (!lex->create_info.db_type)
1278
1358
            {
1279
1359
              lex->create_info.db_type= ha_default_handlerton(YYTHD);
1280
 
              push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1360
              push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
1281
1361
                                  ER_WARN_USING_OTHER_HANDLER,
1282
1362
                                  ER(ER_WARN_USING_OTHER_HANDLER),
1283
1363
                                  ha_resolve_storage_engine_name(lex->create_info.db_type),
1292
1372
            if (!lex->current_select->add_table_to_list(lex->thd, $8,
1293
1373
                                                        NULL,
1294
1374
                                                        TL_OPTION_UPDATING))
1295
 
              DRIZZLE_YYABORT;
 
1375
              MYSQL_YYABORT;
1296
1376
            lex->alter_info.reset();
1297
1377
            lex->alter_info.flags= ALTER_ADD_INDEX;
1298
1378
            lex->alter_info.build_method= $2;
1299
1379
            lex->col_list.empty();
1300
 
            lex->change=NULL;
 
1380
            lex->change=NullS;
1301
1381
          }
1302
1382
          '(' key_list ')' key_options
1303
1383
          {
1322
1402
          }
1323
1403
        ;
1324
1404
 
 
1405
 
 
1406
/*
 
1407
  End tablespace part
 
1408
*/
 
1409
 
1325
1410
create2:
1326
1411
          '(' create2a {}
1327
1412
        | opt_create_table_options
1333
1418
 
1334
1419
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1335
1420
            if (!lex->select_lex.add_table_to_list(thd, $2, NULL, 0, TL_READ))
1336
 
              DRIZZLE_YYABORT;
 
1421
              MYSQL_YYABORT;
1337
1422
          }
1338
1423
        | '(' LIKE table_ident ')'
1339
1424
          {
1342
1427
 
1343
1428
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1344
1429
            if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0, TL_READ))
1345
 
              DRIZZLE_YYABORT;
 
1430
              MYSQL_YYABORT;
1346
1431
          }
1347
1432
        ;
1348
1433
 
1412
1497
 
1413
1498
create_database_option:
1414
1499
          default_collation {}
 
1500
        | default_charset {}
1415
1501
        ;
1416
1502
 
1417
1503
opt_table_options:
1470
1556
            Lex->create_info.avg_row_length=$3;
1471
1557
            Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1472
1558
          }
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;
 
1559
        | PASSWORD opt_equal TEXT_STRING_sys
 
1560
          {
 
1561
            Lex->create_info.password=$3.str;
 
1562
            Lex->create_info.used_fields|= HA_CREATE_USED_PASSWORD;
1477
1563
          }
1478
1564
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1479
1565
          {
1496
1582
                break;
1497
1583
            default:
1498
1584
                my_parse_error(ER(ER_SYNTAX_ERROR));
1499
 
                DRIZZLE_YYABORT;
 
1585
                MYSQL_YYABORT;
1500
1586
            }
1501
1587
            Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1502
1588
          }
1532
1618
            Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1533
1619
            Lex->alter_info.flags|= ALTER_ROW_FORMAT;
1534
1620
          }
 
1621
        | UNION_SYM opt_equal '(' opt_table_list ')'
 
1622
          {
 
1623
            /* Move the union list to the merge_list */
 
1624
            LEX *lex=Lex;
 
1625
            TABLE_LIST *table_list= lex->select_lex.get_table_list();
 
1626
            lex->create_info.merge_list= lex->select_lex.table_list;
 
1627
            lex->create_info.merge_list.elements--;
 
1628
            lex->create_info.merge_list.first=
 
1629
              (uchar*) (table_list->next_local);
 
1630
            lex->select_lex.table_list.elements=1;
 
1631
            lex->select_lex.table_list.next=
 
1632
              (uchar**) &(table_list->next_local);
 
1633
            table_list->next_local= 0;
 
1634
            lex->create_info.used_fields|= HA_CREATE_USED_UNION;
 
1635
          }
 
1636
        | default_charset
1535
1637
        | default_collation
1536
1638
        | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1537
1639
          {
1554
1656
            Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1555
1657
            Lex->create_info.key_block_size= $3;
1556
1658
          }
 
1659
        | TRANSACTIONAL_SYM opt_equal choice
 
1660
          {
 
1661
            Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL;
 
1662
            Lex->create_info.transactional= $3;
 
1663
          }
 
1664
        ;
 
1665
 
 
1666
default_charset:
 
1667
          opt_default charset opt_equal charset_name_or_default
 
1668
          {
 
1669
            HA_CREATE_INFO *cinfo= &Lex->create_info;
 
1670
            if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
 
1671
                 cinfo->default_table_charset && $4 &&
 
1672
                 !my_charset_same(cinfo->default_table_charset,$4))
 
1673
            {
 
1674
              my_error(ER_CONFLICTING_DECLARATIONS, MYF(0),
 
1675
                       "CHARACTER SET ", cinfo->default_table_charset->csname,
 
1676
                       "CHARACTER SET ", $4->csname);
 
1677
              MYSQL_YYABORT;
 
1678
            }
 
1679
            Lex->create_info.default_table_charset= $4;
 
1680
            Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
 
1681
          }
1557
1682
        ;
1558
1683
 
1559
1684
default_collation:
1566
1691
              {
1567
1692
                my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1568
1693
                         $4->name, cinfo->default_table_charset->csname);
1569
 
                DRIZZLE_YYABORT;
 
1694
                MYSQL_YYABORT;
1570
1695
              }
1571
1696
              Lex->create_info.default_table_charset= $4;
1572
1697
              Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1583
1708
            else
1584
1709
            {
1585
1710
              my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1586
 
              DRIZZLE_YYABORT;
 
1711
              MYSQL_YYABORT;
1587
1712
            }
1588
1713
          }
1589
1714
        ;
1597
1722
            else
1598
1723
            {
1599
1724
              my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1600
 
              DRIZZLE_YYABORT;
 
1725
              MYSQL_YYABORT;
1601
1726
            }
1602
1727
          }
1603
1728
        ;
1713
1838
            lex->default_value= lex->on_update_value= 0;
1714
1839
            lex->comment=null_lex_str;
1715
1840
            lex->charset=NULL;
 
1841
            lex->storage_type= HA_SM_DEFAULT;
1716
1842
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1717
 
            lex->vcol_info= NULL;
1718
1843
          }
1719
 
          field_def
 
1844
          type opt_attribute
1720
1845
          {
1721
1846
            LEX *lex=Lex;
1722
1847
            if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3,
1723
1848
                                  lex->length,lex->dec,lex->type,
1724
 
                                  lex->column_format,
 
1849
                                  lex->storage_type, lex->column_format,
1725
1850
                                  lex->default_value, lex->on_update_value, 
1726
1851
                                  &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;
 
1852
                                  lex->change,&lex->interval_list,lex->charset))
 
1853
              MYSQL_YYABORT;
1800
1854
          }
1801
1855
        ;
1802
1856
 
1803
1857
type:
1804
 
        int_type
1805
 
        { 
1806
 
          $$=$1; 
1807
 
          Lex->length=(char*) 0; /* use default length */
1808
 
        }
1809
 
        | real_type opt_precision { $$=$1; }
 
1858
          int_type opt_len field_options { $$=$1; }
 
1859
        | real_type opt_precision field_options { $$=$1; }
 
1860
        | FLOAT_SYM float_options field_options { $$=MYSQL_TYPE_FLOAT; }
 
1861
        | BIT_SYM
 
1862
          {
 
1863
            Lex->length= (char*) "1";
 
1864
            $$=MYSQL_TYPE_BIT;
 
1865
          }
 
1866
        | BIT_SYM '(' NUM ')'
 
1867
          {
 
1868
            Lex->length= $3.str;
 
1869
            $$=MYSQL_TYPE_BIT;
 
1870
          }
 
1871
        | BOOL_SYM
 
1872
          {
 
1873
            Lex->length=(char*) "1";
 
1874
            $$=MYSQL_TYPE_TINY;
 
1875
          }
 
1876
        | BOOLEAN_SYM
 
1877
          {
 
1878
            Lex->length=(char*) "1";
 
1879
            $$=MYSQL_TYPE_TINY;
 
1880
          }
1810
1881
        | char '(' NUM ')' opt_binary
1811
1882
          {
1812
1883
            Lex->length=$3.str;
1813
 
            $$=DRIZZLE_TYPE_VARCHAR;
 
1884
            $$=MYSQL_TYPE_STRING;
1814
1885
          }
1815
1886
        | char opt_binary
1816
1887
          {
1817
1888
            Lex->length=(char*) "1";
1818
 
            $$=DRIZZLE_TYPE_VARCHAR;
 
1889
            $$=MYSQL_TYPE_STRING;
 
1890
          }
 
1891
        | nchar '(' NUM ')' opt_bin_mod
 
1892
          {
 
1893
            Lex->length=$3.str;
 
1894
            $$=MYSQL_TYPE_STRING;
 
1895
            Lex->charset=national_charset_info;
 
1896
          }
 
1897
        | nchar opt_bin_mod
 
1898
          {
 
1899
            Lex->length=(char*) "1";
 
1900
            $$=MYSQL_TYPE_STRING;
 
1901
            Lex->charset=national_charset_info;
 
1902
          }
 
1903
        | BINARY '(' NUM ')'
 
1904
          {
 
1905
            Lex->length=$3.str;
 
1906
            Lex->charset=&my_charset_bin;
 
1907
            $$=MYSQL_TYPE_STRING;
 
1908
          }
 
1909
        | BINARY
 
1910
          {
 
1911
            Lex->length= (char*) "1";
 
1912
            Lex->charset=&my_charset_bin;
 
1913
            $$=MYSQL_TYPE_STRING;
1819
1914
          }
1820
1915
        | varchar '(' NUM ')' opt_binary
1821
1916
          {
1822
1917
            Lex->length=$3.str;
1823
 
            $$= DRIZZLE_TYPE_VARCHAR;
 
1918
            $$= MYSQL_TYPE_VARCHAR;
 
1919
          }
 
1920
        | nvarchar '(' NUM ')' opt_bin_mod
 
1921
          {
 
1922
            Lex->length=$3.str;
 
1923
            $$= MYSQL_TYPE_VARCHAR;
 
1924
            Lex->charset=national_charset_info;
1824
1925
          }
1825
1926
        | VARBINARY '(' NUM ')'
1826
1927
          {
1827
1928
            Lex->length=$3.str;
1828
1929
            Lex->charset=&my_charset_bin;
1829
 
            $$= DRIZZLE_TYPE_VARCHAR;
 
1930
            $$= MYSQL_TYPE_VARCHAR;
1830
1931
          }
 
1932
        | YEAR_SYM opt_len field_options
 
1933
          { $$=MYSQL_TYPE_YEAR; }
1831
1934
        | DATE_SYM
1832
 
          { $$=DRIZZLE_TYPE_NEWDATE; }
 
1935
          { $$=MYSQL_TYPE_DATE; }
1833
1936
        | TIME_SYM
1834
 
          { $$=DRIZZLE_TYPE_TIME; }
 
1937
          { $$=MYSQL_TYPE_TIME; }
1835
1938
        | TIMESTAMP
1836
1939
          {
1837
1940
            /* Unlike other types TIMESTAMP fields are NOT NULL by default */
1838
1941
            Lex->type|= NOT_NULL_FLAG;
1839
 
            $$=DRIZZLE_TYPE_TIMESTAMP;
 
1942
            $$=MYSQL_TYPE_TIMESTAMP;
1840
1943
          }
1841
1944
        | DATETIME
1842
 
          { $$=DRIZZLE_TYPE_DATETIME; }
1843
 
        | BLOB_SYM
1844
 
          {
1845
 
            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;}
 
1945
          { $$=MYSQL_TYPE_DATETIME; }
 
1946
        | TINYBLOB
 
1947
          {
 
1948
            Lex->charset=&my_charset_bin;
 
1949
            $$=MYSQL_TYPE_TINY_BLOB;
 
1950
          }
 
1951
        | BLOB_SYM opt_len
 
1952
          {
 
1953
            Lex->charset=&my_charset_bin;
 
1954
            $$=MYSQL_TYPE_BLOB;
 
1955
          }
 
1956
        | MEDIUMBLOB
 
1957
          {
 
1958
            Lex->charset=&my_charset_bin;
 
1959
            $$=MYSQL_TYPE_MEDIUM_BLOB;
 
1960
          }
 
1961
        | LONGBLOB
 
1962
          {
 
1963
            Lex->charset=&my_charset_bin;
 
1964
            $$=MYSQL_TYPE_LONG_BLOB;
 
1965
          }
 
1966
        | LONG_SYM VARBINARY
 
1967
          {
 
1968
            Lex->charset=&my_charset_bin;
 
1969
            $$=MYSQL_TYPE_MEDIUM_BLOB;
 
1970
          }
 
1971
        | LONG_SYM varchar opt_binary
 
1972
          { $$=MYSQL_TYPE_MEDIUM_BLOB; }
 
1973
        | TINYTEXT opt_binary
 
1974
          { $$=MYSQL_TYPE_TINY_BLOB; }
 
1975
        | TEXT_SYM opt_len opt_binary
 
1976
          { $$=MYSQL_TYPE_BLOB; }
 
1977
        | MEDIUMTEXT opt_binary
 
1978
          { $$=MYSQL_TYPE_MEDIUM_BLOB; }
 
1979
        | LONGTEXT opt_binary
 
1980
          { $$=MYSQL_TYPE_LONG_BLOB; }
 
1981
        | DECIMAL_SYM float_options field_options
 
1982
          { $$=MYSQL_TYPE_NEWDECIMAL;}
 
1983
        | NUMERIC_SYM float_options field_options
 
1984
          { $$=MYSQL_TYPE_NEWDECIMAL;}
 
1985
        | FIXED_SYM float_options field_options
 
1986
          { $$=MYSQL_TYPE_NEWDECIMAL;}
1860
1987
        | ENUM
1861
1988
          {Lex->interval_list.empty();}
1862
1989
          '(' string_list ')' opt_binary
1863
 
          { $$=DRIZZLE_TYPE_ENUM; }
 
1990
          { $$=MYSQL_TYPE_ENUM; }
 
1991
        | SET
 
1992
          { Lex->interval_list.empty();}
 
1993
          '(' string_list ')' opt_binary
 
1994
          { $$=MYSQL_TYPE_SET; }
 
1995
        | LONG_SYM opt_binary
 
1996
          { $$=MYSQL_TYPE_MEDIUM_BLOB; }
1864
1997
        | SERIAL_SYM
1865
1998
          {
1866
 
            $$=DRIZZLE_TYPE_LONGLONG;
1867
 
            Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
 
1999
            $$=MYSQL_TYPE_LONGLONG;
 
2000
            Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNSIGNED_FLAG |
 
2001
              UNIQUE_FLAG);
1868
2002
          }
1869
2003
        ;
1870
2004
 
1872
2006
          CHAR_SYM {}
1873
2007
        ;
1874
2008
 
 
2009
nchar:
 
2010
          NCHAR_SYM {}
 
2011
        | NATIONAL_SYM CHAR_SYM {}
 
2012
        ;
 
2013
 
1875
2014
varchar:
1876
2015
          char VARYING {}
1877
2016
        | VARCHAR {}
1878
2017
        ;
1879
2018
 
 
2019
nvarchar:
 
2020
          NATIONAL_SYM VARCHAR {}
 
2021
        | NVARCHAR_SYM {}
 
2022
        | NCHAR_SYM VARCHAR {}
 
2023
        | NATIONAL_SYM CHAR_SYM VARYING {}
 
2024
        | NCHAR_SYM VARYING {}
 
2025
        ;
 
2026
 
1880
2027
int_type:
1881
 
          INT_SYM   { $$=DRIZZLE_TYPE_LONG; }
1882
 
        | BIGINT    { $$=DRIZZLE_TYPE_LONGLONG; }
 
2028
          INT_SYM   { $$=MYSQL_TYPE_LONG; }
 
2029
        | TINYINT   { $$=MYSQL_TYPE_TINY; }
 
2030
        | SMALLINT  { $$=MYSQL_TYPE_SHORT; }
 
2031
        | MEDIUMINT { $$=MYSQL_TYPE_INT24; }
 
2032
        | BIGINT    { $$=MYSQL_TYPE_LONGLONG; }
1883
2033
        ;
1884
2034
 
1885
2035
real_type:
1886
2036
          REAL
1887
2037
          {
1888
 
            $$= DRIZZLE_TYPE_DOUBLE;
 
2038
            $$= MYSQL_TYPE_DOUBLE;
1889
2039
          }
1890
2040
        | DOUBLE_SYM
1891
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
2041
          { $$=MYSQL_TYPE_DOUBLE; }
1892
2042
        | DOUBLE_SYM PRECISION
1893
 
          { $$=DRIZZLE_TYPE_DOUBLE; }
 
2043
          { $$=MYSQL_TYPE_DOUBLE; }
1894
2044
        ;
1895
2045
 
1896
2046
float_options:
1911
2061
          }
1912
2062
        ;
1913
2063
 
 
2064
field_options:
 
2065
          /* empty */ {}
 
2066
        | field_opt_list {}
 
2067
        ;
 
2068
 
 
2069
field_opt_list:
 
2070
          field_opt_list field_option {}
 
2071
        | field_option {}
 
2072
        ;
 
2073
 
 
2074
field_option:
 
2075
          SIGNED_SYM {}
 
2076
        | UNSIGNED { Lex->type|= UNSIGNED_FLAG;}
 
2077
        | ZEROFILL { Lex->type|= UNSIGNED_FLAG | ZEROFILL_FLAG; }
 
2078
        ;
 
2079
 
1914
2080
opt_len:
1915
2081
          /* empty */ { Lex->length=(char*) 0; /* use default length */ }
1916
2082
        | '(' NUM ')' { Lex->length= $2.str; }
1933
2099
 
1934
2100
attribute:
1935
2101
          NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
 
2102
        | STORAGE_SYM DEFAULT
 
2103
          {
 
2104
            Lex->storage_type= HA_SM_DEFAULT;
 
2105
            Lex->alter_info.flags|= ALTER_COLUMN_STORAGE;
 
2106
          }
 
2107
        | STORAGE_SYM DISK_SYM
 
2108
          {
 
2109
            Lex->storage_type= HA_SM_DISK;
 
2110
            Lex->alter_info.flags|= ALTER_COLUMN_STORAGE;
 
2111
          }
 
2112
        | STORAGE_SYM MEMORY_SYM
 
2113
          {
 
2114
            Lex->storage_type= HA_SM_MEMORY;
 
2115
            Lex->alter_info.flags|= ALTER_COLUMN_STORAGE;
 
2116
          }
1936
2117
        | COLUMN_FORMAT_SYM column_format_types
1937
2118
          {
1938
2119
            Lex->column_format= $2;
1978
2159
            {
1979
2160
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1980
2161
                       $2->name,Lex->charset->csname);
1981
 
              DRIZZLE_YYABORT;
 
2162
              MYSQL_YYABORT;
1982
2163
            }
1983
2164
            else
1984
2165
            {
1999
2180
        | CHARSET {}
2000
2181
        ;
2001
2182
 
 
2183
charset_name:
 
2184
          ident_or_text
 
2185
          {
 
2186
            if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))))
 
2187
            {
 
2188
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str);
 
2189
              MYSQL_YYABORT;
 
2190
            }
 
2191
          }
 
2192
        | BINARY { $$= &my_charset_bin; }
 
2193
        ;
 
2194
 
 
2195
charset_name_or_default:
 
2196
          charset_name { $$=$1;   }
 
2197
        | DEFAULT    { $$=NULL; }
 
2198
        ;
 
2199
 
 
2200
opt_load_data_charset:
 
2201
          /* Empty */ { $$= NULL; }
 
2202
        | charset charset_name_or_default { $$= $2; }
 
2203
        ;
 
2204
 
 
2205
old_or_new_charset_name:
 
2206
          ident_or_text
 
2207
          {
 
2208
            if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) &&
 
2209
                !($$=get_old_charset_by_name($1.str)))
 
2210
            {
 
2211
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str);
 
2212
              MYSQL_YYABORT;
 
2213
            }
 
2214
          }
 
2215
        | BINARY { $$= &my_charset_bin; }
 
2216
        ;
 
2217
 
 
2218
old_or_new_charset_name_or_default:
 
2219
          old_or_new_charset_name { $$=$1;   }
 
2220
        | DEFAULT    { $$=NULL; }
 
2221
        ;
 
2222
 
2002
2223
collation_name:
2003
2224
          ident_or_text
2004
2225
          {
2005
2226
            if (!($$=get_charset_by_name($1.str,MYF(0))))
2006
2227
            {
2007
2228
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str);
2008
 
              DRIZZLE_YYABORT;
 
2229
              MYSQL_YYABORT;
2009
2230
            }
2010
2231
          }
2011
2232
        ;
2012
2233
 
 
2234
opt_collate:
 
2235
          /* empty */ { $$=NULL; }
 
2236
        | COLLATE_SYM collation_name_or_default { $$=$2; }
 
2237
        ;
 
2238
 
2013
2239
collation_name_or_default:
2014
2240
          collation_name { $$=$1; }
2015
2241
        | DEFAULT    { $$=NULL; }
2022
2248
 
2023
2249
opt_binary:
2024
2250
          /* empty */ { Lex->charset=NULL; }
 
2251
        | ASCII_SYM opt_bin_mod { Lex->charset=&my_charset_latin1; }
2025
2252
        | BYTE_SYM { Lex->charset=&my_charset_bin; }
 
2253
        | UNICODE_SYM opt_bin_mod
 
2254
          {
 
2255
            if (!(Lex->charset=get_charset_by_csname("ucs2",
 
2256
                                                     MY_CS_PRIMARY,MYF(0))))
 
2257
            {
 
2258
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2");
 
2259
              MYSQL_YYABORT;
 
2260
            }
 
2261
          }
 
2262
        | charset charset_name opt_bin_mod { Lex->charset=$2; }
 
2263
        | BINARY opt_bin_charset { Lex->type|= BINCMP_FLAG; }
 
2264
        ;
 
2265
 
 
2266
opt_bin_mod:
 
2267
          /* empty */ { }
2026
2268
        | BINARY { Lex->type|= BINCMP_FLAG; }
2027
2269
        ;
2028
2270
 
 
2271
opt_bin_charset:
 
2272
          /* empty */ { Lex->charset= NULL; }
 
2273
        | ASCII_SYM { Lex->charset=&my_charset_latin1; }
 
2274
        | UNICODE_SYM
 
2275
          {
 
2276
            if (!(Lex->charset=get_charset_by_csname("ucs2",
 
2277
                                                     MY_CS_PRIMARY,MYF(0))))
 
2278
            {
 
2279
              my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2");
 
2280
              MYSQL_YYABORT;
 
2281
            }
 
2282
          }
 
2283
        | charset charset_name { Lex->charset=$2; }
 
2284
        ;
 
2285
 
2029
2286
ws_nweights:
2030
2287
        '(' real_ulong_num
2031
2288
        {
2032
2289
          if ($2 == 0)
2033
2290
          {
2034
2291
            my_parse_error(ER(ER_SYNTAX_ERROR));
2035
 
            DRIZZLE_YYABORT;
 
2292
            MYSQL_YYABORT;
2036
2293
          }
2037
2294
        }
2038
2295
        ')'
2077
2334
ws_level_range:
2078
2335
        ws_level_number '-' ws_level_number
2079
2336
        {
2080
 
          uint32_t start= $1;
2081
 
          uint32_t end= $3;
 
2337
          uint start= $1;
 
2338
          uint end= $3;
2082
2339
          for ($$= 0; start <= end; start++)
2083
2340
            $$|= (1 << start);
2084
2341
        }
2303
2560
            lex->duplicates= DUP_ERROR; 
2304
2561
            if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
2305
2562
                                                   TL_OPTION_UPDATING))
2306
 
              DRIZZLE_YYABORT;
 
2563
              MYSQL_YYABORT;
2307
2564
            lex->alter_info.reset();
2308
2565
            lex->col_list.empty();
2309
2566
            lex->select_lex.init_order();
2310
2567
            lex->select_lex.db=
2311
 
              ((TableList*) lex->select_lex.table_list.first)->db;
2312
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
2568
              ((TABLE_LIST*) lex->select_lex.table_list.first)->db;
 
2569
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
2313
2570
            lex->create_info.db_type= 0;
2314
2571
            lex->create_info.default_table_charset= NULL;
2315
2572
            lex->create_info.row_type= ROW_TYPE_NOT_USED;
2316
2573
            lex->alter_info.reset();
 
2574
            lex->no_write_to_binlog= 0;
 
2575
            lex->create_info.default_storage_media= HA_SM_DEFAULT;
2317
2576
            lex->alter_info.build_method= $2;
2318
2577
          }
2319
2578
          alter_commands
2330
2589
            lex->name= $3;
2331
2590
            if (lex->name.str == NULL &&
2332
2591
                lex->copy_db_to(&lex->name.str, &lex->name.length))
2333
 
              DRIZZLE_YYABORT;
 
2592
              MYSQL_YYABORT;
 
2593
          }
 
2594
        | ALTER DATABASE ident UPGRADE_SYM DATA_SYM DIRECTORY_SYM NAME_SYM
 
2595
          {
 
2596
            LEX *lex= Lex;
 
2597
            lex->sql_command= SQLCOM_ALTER_DB_UPGRADE;
 
2598
            lex->name= $3;
2334
2599
          }
2335
2600
        ;
2336
2601
 
2400
2665
            lex->comment=null_lex_str;
2401
2666
            lex->charset= NULL;
2402
2667
            lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
 
2668
            lex->storage_type= HA_SM_DEFAULT;
2403
2669
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2404
 
            lex->vcol_info= NULL;
2405
2670
          }
2406
 
          field_def
 
2671
          type opt_attribute
2407
2672
          {
2408
2673
            LEX *lex=Lex;
2409
2674
            if (add_field_to_list(lex->thd,&$3,
2410
2675
                                  (enum enum_field_types) $5,
2411
2676
                                  lex->length,lex->dec,lex->type,
2412
 
                                  lex->column_format,
 
2677
                                  lex->storage_type, lex->column_format,
2413
2678
                                  lex->default_value, lex->on_update_value,
2414
2679
                                  &lex->comment,
2415
 
                                  $3.str, &lex->interval_list, lex->charset,
2416
 
                                  lex->vcol_info))
2417
 
              DRIZZLE_YYABORT;
 
2680
                                  $3.str, &lex->interval_list, lex->charset))
 
2681
              MYSQL_YYABORT;
2418
2682
          }
2419
2683
          opt_place
2420
 
        | DROP opt_column field_ident
 
2684
        | DROP opt_column field_ident opt_restrict
2421
2685
          {
2422
2686
            LEX *lex=Lex;
2423
2687
            lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2475
2739
            if (lex->select_lex.db == NULL &&
2476
2740
                lex->copy_db_to(&lex->select_lex.db, &dummy))
2477
2741
            {
2478
 
              DRIZZLE_YYABORT;
 
2742
              MYSQL_YYABORT;
2479
2743
            }
2480
2744
            if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
2481
2745
            {
2482
2746
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
2483
 
              DRIZZLE_YYABORT;
 
2747
              MYSQL_YYABORT;
2484
2748
            }
2485
2749
            lex->name= $3->table;
2486
2750
            lex->alter_info.flags|= ALTER_RENAME;
2487
2751
          }
2488
 
        | CONVERT_SYM TO_SYM collation_name_or_default
 
2752
        | CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
2489
2753
          {
2490
 
            if (!$3)
 
2754
            if (!$4)
2491
2755
            {
2492
2756
              THD *thd= YYTHD;
2493
 
              $3= thd->variables.collation_database;
 
2757
              $4= thd->variables.collation_database;
 
2758
            }
 
2759
            $5= $5 ? $5 : $4;
 
2760
            if (!my_charset_same($4,$5))
 
2761
            {
 
2762
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
 
2763
                       $5->name, $4->csname);
 
2764
              MYSQL_YYABORT;
2494
2765
            }
2495
2766
            LEX *lex= Lex;
2496
2767
            lex->create_info.table_charset=
2497
 
            lex->create_info.default_table_charset= $3;
 
2768
            lex->create_info.default_table_charset= $5;
2498
2769
            lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2499
2770
              HA_CREATE_USED_DEFAULT_CHARSET);
2500
2771
            lex->alter_info.flags|= ALTER_CONVERT;
2525
2796
        | IGNORE_SYM { Lex->ignore= 1;}
2526
2797
        ;
2527
2798
 
 
2799
opt_restrict:
 
2800
          /* empty */ { Lex->drop_mode= DROP_DEFAULT; }
 
2801
        | RESTRICT    { Lex->drop_mode= DROP_RESTRICT; }
 
2802
        | CASCADE     { Lex->drop_mode= DROP_CASCADE; }
 
2803
        ;
 
2804
 
2528
2805
opt_place:
2529
2806
          /* empty */ {}
2530
2807
        | AFTER_SYM ident
2557
2834
            lex->sql_command = SQLCOM_SLAVE_START;
2558
2835
            lex->type = 0;
2559
2836
            /* We'll use mi structure for UNTIL options */
2560
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
2837
            bzero((char*) &lex->mi, sizeof(lex->mi));
2561
2838
            /* If you change this code don't forget to update SLAVE START too */
2562
2839
          }
2563
2840
          slave_until
2575
2852
            lex->sql_command = SQLCOM_SLAVE_START;
2576
2853
            lex->type = 0;
2577
2854
            /* We'll use mi structure for UNTIL options */
2578
 
            memset(&lex->mi, 0, sizeof(lex->mi));
 
2855
            bzero((char*) &lex->mi, sizeof(lex->mi));
2579
2856
          }
2580
2857
          slave_until
2581
2858
          {}
2600
2877
          /*empty*/ { $$ = 0; }
2601
2878
        | WITH CONSISTENT_SYM SNAPSHOT_SYM
2602
2879
          {
2603
 
            $$= DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT;
 
2880
            $$= MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT;
2604
2881
          }
2605
2882
        ;
2606
2883
 
2632
2909
            {
2633
2910
               my_message(ER_BAD_SLAVE_UNTIL_COND,
2634
2911
                          ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
2635
 
               DRIZZLE_YYABORT;
 
2912
               MYSQL_YYABORT;
2636
2913
            }
2637
2914
          }
2638
2915
        ;
2659
2936
        ;
2660
2937
 
2661
2938
repair:
2662
 
          REPAIR table_or_tables
 
2939
          REPAIR opt_no_write_to_binlog table_or_tables
2663
2940
          {
2664
2941
            LEX *lex=Lex;
2665
2942
            lex->sql_command = SQLCOM_REPAIR;
 
2943
            lex->no_write_to_binlog= $2;
2666
2944
            lex->check_opt.init();
2667
2945
          }
2668
2946
          table_list opt_mi_repair_type
2686
2964
        ;
2687
2965
 
2688
2966
analyze:
2689
 
          ANALYZE_SYM table_or_tables
 
2967
          ANALYZE_SYM opt_no_write_to_binlog table_or_tables
2690
2968
          {
2691
2969
            LEX *lex=Lex;
2692
2970
            lex->sql_command = SQLCOM_ANALYZE;
 
2971
            lex->no_write_to_binlog= $2;
2693
2972
            lex->check_opt.init();
2694
2973
          }
2695
2974
          table_list
2736
3015
        ;
2737
3016
 
2738
3017
optimize:
2739
 
          OPTIMIZE table_or_tables
 
3018
          OPTIMIZE opt_no_write_to_binlog table_or_tables
2740
3019
          {
2741
3020
            LEX *lex=Lex;
2742
3021
            lex->sql_command = SQLCOM_OPTIMIZE;
 
3022
            lex->no_write_to_binlog= $2;
2743
3023
            lex->check_opt.init();
2744
3024
          }
2745
3025
          table_list
2746
3026
          {}
2747
3027
        ;
2748
3028
 
 
3029
opt_no_write_to_binlog:
 
3030
          /* empty */ { $$= 0; }
 
3031
        | NO_WRITE_TO_BINLOG { $$= 1; }
 
3032
        | LOCAL_SYM { $$= 1; }
 
3033
        ;
 
3034
 
2749
3035
rename:
2750
3036
          RENAME table_or_tables
2751
3037
          {
2769
3055
                                       TL_IGNORE) ||
2770
3056
                !sl->add_table_to_list(lex->thd, $3,NULL,TL_OPTION_UPDATING,
2771
3057
                                       TL_IGNORE))
2772
 
              DRIZZLE_YYABORT;
 
3058
              MYSQL_YYABORT;
2773
3059
          }
2774
3060
        ;
2775
3061
 
2792
3078
          {
2793
3079
            if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ, 
2794
3080
                                           Select->pop_index_hints()))
2795
 
              DRIZZLE_YYABORT;
 
3081
              MYSQL_YYABORT;
2796
3082
          }
2797
3083
        ;
2798
3084
 
2840
3126
          SELECT_SYM select_part2
2841
3127
          {
2842
3128
            if (setup_select_in_parentheses(Lex))
2843
 
              DRIZZLE_YYABORT;
 
3129
              MYSQL_YYABORT;
2844
3130
          }
2845
3131
        | '(' select_paren ')'
2846
3132
        ;
2850
3136
          SELECT_SYM select_part2_derived
2851
3137
          {
2852
3138
            if (setup_select_in_parentheses(Lex))
2853
 
              DRIZZLE_YYABORT;
 
3139
              MYSQL_YYABORT;
2854
3140
          }
2855
3141
        | '(' select_paren_derived ')'
2856
3142
        ;
2863
3149
            if (lex->current_select->set_braces(0))
2864
3150
            {
2865
3151
              my_parse_error(ER(ER_SYNTAX_ERROR));
2866
 
              DRIZZLE_YYABORT;
 
3152
              MYSQL_YYABORT;
2867
3153
            }
2868
3154
            if (sel->linkage == UNION_TYPE &&
2869
3155
                sel->master_unit()->first_select()->braces)
2870
3156
            {
2871
3157
              my_parse_error(ER(ER_SYNTAX_ERROR));
2872
 
              DRIZZLE_YYABORT;
 
3158
              MYSQL_YYABORT;
2873
3159
            }
2874
3160
          }
2875
3161
          union_clause
2904
3190
          {
2905
3191
            Select->context.table_list=
2906
3192
              Select->context.first_name_resolution_table= 
2907
 
                (TableList *) Select->table_list.first;
 
3193
                (TABLE_LIST *) Select->table_list.first;
2908
3194
          }
2909
3195
        ;
2910
3196
 
2915
3201
            if (Select->options & SELECT_DISTINCT && Select->options & SELECT_ALL)
2916
3202
            {
2917
3203
              my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2918
 
              DRIZZLE_YYABORT;
 
3204
              MYSQL_YYABORT;
2919
3205
            }
2920
3206
          }
2921
3207
        ;
2930
3216
        | HIGH_PRIORITY
2931
3217
          {
2932
3218
            if (check_simple_select())
2933
 
              DRIZZLE_YYABORT;
 
3219
              MYSQL_YYABORT;
2934
3220
            Lex->lock_option= TL_READ_HIGH_PRIORITY;
2935
3221
          }
2936
3222
        | DISTINCT         { Select->options|= SELECT_DISTINCT; }
2939
3225
        | SQL_BUFFER_RESULT
2940
3226
          {
2941
3227
            if (check_simple_select())
2942
 
              DRIZZLE_YYABORT;
 
3228
              MYSQL_YYABORT;
2943
3229
            Select->options|= OPTION_BUFFER_RESULT;
2944
3230
          }
2945
3231
        | SQL_CALC_FOUND_ROWS
2946
3232
          {
2947
3233
            if (check_simple_select())
2948
 
              DRIZZLE_YYABORT;
 
3234
              MYSQL_YYABORT;
2949
3235
            Select->options|= OPTION_FOUND_ROWS;
2950
3236
          }
2951
3237
        | ALL { Select->options|= SELECT_ALL; }
2976
3262
                                 new Item_field(&thd->lex->current_select->
2977
3263
                                                context,
2978
3264
                                                NULL, NULL, "*")))
2979
 
              DRIZZLE_YYABORT;
 
3265
              MYSQL_YYABORT;
2980
3266
            (thd->lex->current_select->with_wild)++;
2981
3267
          }
2982
3268
        ;
2987
3273
            THD *thd= YYTHD;
2988
3274
 
2989
3275
            if (add_item_to_list(thd, $2))
2990
 
              DRIZZLE_YYABORT;
 
3276
              MYSQL_YYABORT;
2991
3277
          }
2992
3278
        | remember_name expr remember_end select_alias
2993
3279
          {
2994
3280
            THD *thd= YYTHD;
2995
 
            assert($1 < $3);
 
3281
            DBUG_ASSERT($1 < $3);
2996
3282
 
2997
3283
            if (add_item_to_list(thd, $2))
2998
 
              DRIZZLE_YYABORT;
 
3284
              MYSQL_YYABORT;
2999
3285
            if ($4.str)
3000
3286
            {
3001
 
              $2->is_autogenerated_name= false;
 
3287
              $2->is_autogenerated_name= FALSE;
3002
3288
              $2->set_name($4.str, $4.length, system_charset_info);
3003
3289
            }
3004
3290
            else if (!$2->name)
3214
3500
        ;
3215
3501
 
3216
3502
bit_expr:
3217
 
          bit_expr '+' bit_expr %prec '+'
 
3503
          bit_expr '|' bit_expr %prec '|'
 
3504
          { $$= new Item_func_bit_or($1,$3); }
 
3505
        | bit_expr '&' bit_expr %prec '&'
 
3506
          { $$= new Item_func_bit_and($1,$3); }
 
3507
        | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT
 
3508
          { $$= new Item_func_shift_left($1,$3); }
 
3509
        | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT
 
3510
          { $$= new Item_func_shift_right($1,$3); }
 
3511
        | bit_expr '+' bit_expr %prec '+'
3218
3512
          { $$= new Item_func_plus($1,$3); }
3219
3513
        | bit_expr '-' bit_expr %prec '-'
3220
3514
          { $$= new Item_func_minus($1,$3); }
3232
3526
          { $$= new Item_func_int_div($1,$3); }
3233
3527
        | bit_expr MOD_SYM bit_expr %prec MOD_SYM
3234
3528
          { $$= new Item_func_mod($1,$3); }
 
3529
        | bit_expr '^' bit_expr
 
3530
          { $$= new Item_func_bit_xor($1,$3); }
3235
3531
        | simple_expr
3236
3532
        ;
3237
3533
 
3241
3537
 
3242
3538
and:
3243
3539
          AND_SYM
 
3540
       | AND_AND_SYM
3244
3541
       ;
3245
3542
 
3246
3543
not:
3276
3573
            $$= new (thd->mem_root) Item_func_set_collation($1, i1);
3277
3574
          }
3278
3575
        | literal
 
3576
        | param_marker
3279
3577
        | variable
3280
3578
        | sum_expr
3281
3579
        | '+' simple_expr %prec NEG { $$= $2; }
3282
3580
        | '-' simple_expr %prec NEG
3283
3581
          { $$= new (YYTHD->mem_root) Item_func_neg($2); }
 
3582
        | '~' simple_expr %prec NEG
 
3583
          { $$= new (YYTHD->mem_root) Item_func_bit_neg($2); }
3284
3584
        | '(' subselect ')'
3285
3585
          { 
3286
3586
            $$= new (YYTHD->mem_root) Item_singlerow_subselect($2);
3312
3612
            $$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec,
3313
3613
                                 lex->charset);
3314
3614
            if (!$$)
3315
 
              DRIZZLE_YYABORT;
 
3615
              MYSQL_YYABORT;
3316
3616
          }
3317
3617
        | CASE_SYM opt_expr when_list opt_else END
3318
3618
          { $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 ); }
3321
3621
            $$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec,
3322
3622
                                 Lex->charset);
3323
3623
            if (!$$)
3324
 
              DRIZZLE_YYABORT;
 
3624
              MYSQL_YYABORT;
3325
3625
          }
 
3626
        | CONVERT_SYM '(' expr USING charset_name ')'
 
3627
          { $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5); }
3326
3628
        | DEFAULT '(' simple_ident ')'
3327
3629
          {
3328
3630
            $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(),
3347
3649
function_call_keyword:
3348
3650
          CHAR_SYM '(' expr_list ')'
3349
3651
          { $$= new (YYTHD->mem_root) Item_func_char(*$3); }
 
3652
        | CHAR_SYM '(' expr_list USING charset_name ')'
 
3653
          { $$= new (YYTHD->mem_root) Item_func_char(*$3, $5); }
3350
3654
        | CURRENT_USER optional_braces
3351
3655
          {
3352
3656
            $$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context());
3523
3827
function_call_conflict:
3524
3828
          ASCII_SYM '(' expr ')'
3525
3829
          { $$= new (YYTHD->mem_root) Item_func_ascii($3); }
 
3830
        | CHARSET '(' expr ')'
 
3831
          { $$= new (YYTHD->mem_root) Item_func_charset($3); }
3526
3832
        | COALESCE '(' expr_list ')'
3527
3833
          { $$= new (YYTHD->mem_root) Item_func_coalesce(* $3); }
3528
3834
        | COLLATION_SYM '(' expr ')'
3537
3843
          { $$= new (YYTHD->mem_root) Item_func_microsecond($3); }
3538
3844
        | MOD_SYM '(' expr ',' expr ')'
3539
3845
          { $$ = new (YYTHD->mem_root) Item_func_mod( $3, $5); }
 
3846
        | OLD_PASSWORD '(' expr ')'
 
3847
          { $$=  new (YYTHD->mem_root) Item_func_old_password($3); }
 
3848
        | PASSWORD '(' expr ')'
 
3849
          {
 
3850
            THD *thd= YYTHD;
 
3851
            Item* i1;
 
3852
            if (thd->variables.old_passwords)
 
3853
              i1= new (thd->mem_root) Item_func_old_password($3);
 
3854
            else
 
3855
              i1= new (thd->mem_root) Item_func_password($3);
 
3856
            $$= i1;
 
3857
          }
3540
3858
        | QUARTER_SYM '(' expr ')'
3541
3859
          { $$ = new (YYTHD->mem_root) Item_func_quarter($3); }
3542
3860
        | REPEAT_SYM '(' expr ',' expr ')'
3585
3903
function_call_generic:
3586
3904
          IDENT_sys '('
3587
3905
          {
 
3906
#ifdef HAVE_DLOPEN
3588
3907
            udf_func *udf= 0;
3589
 
            udf= find_udf($1.str, $1.length);
3590
 
 
 
3908
            LEX *lex= Lex;
 
3909
            if (using_udf_functions &&
 
3910
                (udf= find_udf($1.str, $1.length)) &&
 
3911
                udf->type == UDFTYPE_AGGREGATE)
 
3912
            {
 
3913
              if (lex->current_select->inc_in_sum_expr())
 
3914
              {
 
3915
                my_parse_error(ER(ER_SYNTAX_ERROR));
 
3916
                MYSQL_YYABORT;
 
3917
              }
 
3918
            }
3591
3919
            /* Temporary placing the result of find_udf in $3 */
3592
3920
            $<udf>$= udf;
 
3921
#endif
3593
3922
          }
3594
3923
          opt_udf_expr_list ')'
3595
3924
          {
3613
3942
            }
3614
3943
            else
3615
3944
            {
 
3945
#ifdef HAVE_DLOPEN
3616
3946
              /* Retrieving the result of find_udf */
3617
3947
              udf_func *udf= $<udf>3;
3618
 
              if (udf)
 
3948
 
3619
3949
              {
 
3950
                if (udf->type == UDFTYPE_AGGREGATE)
 
3951
                {
 
3952
                  Select->in_sum_expr--;
 
3953
                }
 
3954
 
3620
3955
                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
3956
              }
 
3957
#endif
3625
3958
            }
3626
3959
 
3627
3960
            if (! ($$= item))
3628
3961
            {
3629
 
              DRIZZLE_YYABORT;
 
3962
              MYSQL_YYABORT;
3630
3963
            }
3631
3964
          }
3632
3965
        ;
3660
3993
            */
3661
3994
            if ($4.str)
3662
3995
            {
3663
 
              $2->is_autogenerated_name= false;
 
3996
              $2->is_autogenerated_name= FALSE;
3664
3997
              $2->set_name($4.str, $4.length, system_charset_info);
3665
3998
            }
3666
3999
            else
3674
4007
          { $$=new Item_sum_avg($3); }
3675
4008
        | AVG_SYM '(' DISTINCT in_sum_expr ')'
3676
4009
          { $$=new Item_sum_avg_distinct($4); }
 
4010
        | BIT_AND  '(' in_sum_expr ')'
 
4011
          { $$=new Item_sum_and($3); }
 
4012
        | BIT_OR  '(' in_sum_expr ')'
 
4013
          { $$=new Item_sum_or($3); }
 
4014
        | BIT_XOR  '(' in_sum_expr ')'
 
4015
          { $$=new Item_sum_xor($3); }
3677
4016
        | COUNT_SYM '(' opt_all '*' ')'
3678
 
          { $$=new Item_sum_count(new Item_int((int32_t) 0L,1)); }
 
4017
          { $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
3679
4018
        | COUNT_SYM '(' in_sum_expr ')'
3680
4019
          { $$=new Item_sum_count($3); }
3681
4020
        | COUNT_SYM '(' DISTINCT
3729
4068
            if (! Lex->parsing_options.allows_variable)
3730
4069
            {
3731
4070
              my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
3732
 
              DRIZZLE_YYABORT;
 
4071
              MYSQL_YYABORT;
3733
4072
            }
3734
4073
          }
3735
4074
          variable_aux
3753
4092
            if ($3.str && $4.str && check_reserved_words(&$3))
3754
4093
            {
3755
4094
              my_parse_error(ER(ER_SYNTAX_ERROR));
3756
 
              DRIZZLE_YYABORT;
 
4095
              MYSQL_YYABORT;
3757
4096
            }
3758
4097
            if (!($$= get_system_var(YYTHD, $2, $3, $4)))
3759
 
              DRIZZLE_YYABORT;
 
4098
              MYSQL_YYABORT;
3760
4099
            if (!((Item_func_get_system_var*) $$)->is_written_to_binlog())
3761
4100
              Lex->set_stmt_unsafe();
3762
4101
          }
3770
4109
opt_gconcat_separator:
3771
4110
          /* empty */
3772
4111
            {
3773
 
              $$= new (YYTHD->mem_root) String(",", 1, &my_charset_utf8_general_ci);
 
4112
              $$= new (YYTHD->mem_root) String(",", 1, &my_charset_latin1);
3774
4113
            }
3775
4114
        | SEPARATOR_SYM text_string { $$ = $2; }
3776
4115
        ;
3797
4136
            if (lex->current_select->inc_in_sum_expr())
3798
4137
            {
3799
4138
              my_parse_error(ER(ER_SYNTAX_ERROR));
3800
 
              DRIZZLE_YYABORT;
 
4139
              MYSQL_YYABORT;
3801
4140
            }
3802
4141
          }
3803
4142
          expr
3812
4151
          { $$=ITEM_CAST_CHAR; Lex->charset= &my_charset_bin; Lex->dec= 0; }
3813
4152
        | CHAR_SYM opt_len opt_binary
3814
4153
          { $$=ITEM_CAST_CHAR; Lex->dec= 0; }
 
4154
        | NCHAR_SYM opt_len
 
4155
          { $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; }
 
4156
        | SIGNED_SYM
 
4157
          { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4158
        | SIGNED_SYM INT_SYM
 
4159
          { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4160
        | UNSIGNED
 
4161
          { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
4162
        | UNSIGNED INT_SYM
 
4163
          { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3815
4164
        | DATE_SYM
3816
4165
          { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
3817
4166
        | TIME_SYM
3868
4217
          {
3869
4218
            LEX *lex= Lex;
3870
4219
            if (!($$= lex->current_select->nest_last_join(lex->thd)))
3871
 
              DRIZZLE_YYABORT;
 
4220
              MYSQL_YYABORT;
3872
4221
          }
3873
4222
        ;
3874
4223
 
3875
4224
join_table_list:
3876
 
          derived_table_list { DRIZZLE_YYABORT_UNLESS($$=$1); }
 
4225
          derived_table_list { MYSQL_YYABORT_UNLESS($$=$1); }
3877
4226
        ;
3878
4227
 
3879
4228
/*
3894
4243
          esc_table_ref { $$=$1; }
3895
4244
        | derived_table_list ',' esc_table_ref
3896
4245
          {
3897
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
 
4246
            MYSQL_YYABORT_UNLESS($1 && ($$=$3));
3898
4247
          }
3899
4248
        ;
3900
4249
 
3913
4262
            left-associative joins.
3914
4263
          */
3915
4264
          table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3916
 
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); }
 
4265
          { MYSQL_YYABORT_UNLESS($1 && ($$=$3)); }
3917
4266
        | table_ref STRAIGHT_JOIN table_factor
3918
 
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
 
4267
          { MYSQL_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
3919
4268
        | table_ref normal_join table_ref
3920
4269
          ON
3921
4270
          {
3922
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4271
            MYSQL_YYABORT_UNLESS($1 && $3);
3923
4272
            /* Change the current name resolution context to a local context. */
3924
4273
            if (push_new_name_resolution_context(YYTHD, $1, $3))
3925
 
              DRIZZLE_YYABORT;
 
4274
              MYSQL_YYABORT;
3926
4275
            Select->parsing_place= IN_ON;
3927
4276
          }
3928
4277
          expr
3934
4283
        | table_ref STRAIGHT_JOIN table_factor
3935
4284
          ON
3936
4285
          {
3937
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4286
            MYSQL_YYABORT_UNLESS($1 && $3);
3938
4287
            /* Change the current name resolution context to a local context. */
3939
4288
            if (push_new_name_resolution_context(YYTHD, $1, $3))
3940
 
              DRIZZLE_YYABORT;
 
4289
              MYSQL_YYABORT;
3941
4290
            Select->parsing_place= IN_ON;
3942
4291
          }
3943
4292
          expr
3950
4299
        | table_ref normal_join table_ref
3951
4300
          USING
3952
4301
          {
3953
 
            DRIZZLE_YYABORT_UNLESS($1 && $3);
 
4302
            MYSQL_YYABORT_UNLESS($1 && $3);
3954
4303
          }
3955
4304
          '(' using_list ')'
3956
4305
          { add_join_natural($1,$3,$7,Select); $$=$3; }
3957
4306
        | table_ref NATURAL JOIN_SYM table_factor
3958
4307
          {
3959
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$4));
 
4308
            MYSQL_YYABORT_UNLESS($1 && ($$=$4));
3960
4309
            add_join_natural($1,$4,NULL,Select);
3961
4310
          }
3962
4311
 
3964
4313
        | table_ref LEFT opt_outer JOIN_SYM table_ref
3965
4314
          ON
3966
4315
          {
3967
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4316
            MYSQL_YYABORT_UNLESS($1 && $5);
3968
4317
            /* Change the current name resolution context to a local context. */
3969
4318
            if (push_new_name_resolution_context(YYTHD, $1, $5))
3970
 
              DRIZZLE_YYABORT;
 
4319
              MYSQL_YYABORT;
3971
4320
            Select->parsing_place= IN_ON;
3972
4321
          }
3973
4322
          expr
3980
4329
          }
3981
4330
        | table_ref LEFT opt_outer JOIN_SYM table_factor
3982
4331
          {
3983
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4332
            MYSQL_YYABORT_UNLESS($1 && $5);
3984
4333
          }
3985
4334
          USING '(' using_list ')'
3986
4335
          { 
3990
4339
          }
3991
4340
        | table_ref NATURAL LEFT opt_outer JOIN_SYM table_factor
3992
4341
          {
3993
 
            DRIZZLE_YYABORT_UNLESS($1 && $6);
 
4342
            MYSQL_YYABORT_UNLESS($1 && $6);
3994
4343
            add_join_natural($1,$6,NULL,Select);
3995
4344
            $6->outer_join|=JOIN_TYPE_LEFT;
3996
4345
            $$=$6;
4000
4349
        | table_ref RIGHT opt_outer JOIN_SYM table_ref
4001
4350
          ON
4002
4351
          {
4003
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4352
            MYSQL_YYABORT_UNLESS($1 && $5);
4004
4353
            /* Change the current name resolution context to a local context. */
4005
4354
            if (push_new_name_resolution_context(YYTHD, $1, $5))
4006
 
              DRIZZLE_YYABORT;
 
4355
              MYSQL_YYABORT;
4007
4356
            Select->parsing_place= IN_ON;
4008
4357
          }
4009
4358
          expr
4010
4359
          {
4011
4360
            LEX *lex= Lex;
4012
4361
            if (!($$= lex->current_select->convert_right_join()))
4013
 
              DRIZZLE_YYABORT;
 
4362
              MYSQL_YYABORT;
4014
4363
            add_join_on($$, $8);
4015
4364
            Lex->pop_context();
4016
4365
            Select->parsing_place= NO_MATTER;
4017
4366
          }
4018
4367
        | table_ref RIGHT opt_outer JOIN_SYM table_factor
4019
4368
          {
4020
 
            DRIZZLE_YYABORT_UNLESS($1 && $5);
 
4369
            MYSQL_YYABORT_UNLESS($1 && $5);
4021
4370
          }
4022
4371
          USING '(' using_list ')'
4023
4372
          {
4024
4373
            LEX *lex= Lex;
4025
4374
            if (!($$= lex->current_select->convert_right_join()))
4026
 
              DRIZZLE_YYABORT;
 
4375
              MYSQL_YYABORT;
4027
4376
            add_join_natural($$,$5,$9,Select);
4028
4377
          }
4029
4378
        | table_ref NATURAL RIGHT opt_outer JOIN_SYM table_factor
4030
4379
          {
4031
 
            DRIZZLE_YYABORT_UNLESS($1 && $6);
 
4380
            MYSQL_YYABORT_UNLESS($1 && $6);
4032
4381
            add_join_natural($6,$1,NULL,Select);
4033
4382
            LEX *lex= Lex;
4034
4383
            if (!($$= lex->current_select->convert_right_join()))
4035
 
              DRIZZLE_YYABORT;
 
4384
              MYSQL_YYABORT;
4036
4385
          }
4037
4386
        ;
4038
4387
 
4061
4410
                                                Select->get_table_join_options(),
4062
4411
                                                Lex->lock_option,
4063
4412
                                                Select->pop_index_hints())))
4064
 
              DRIZZLE_YYABORT;
 
4413
              MYSQL_YYABORT;
4065
4414
            Select->add_joined_table($$);
4066
4415
          }
4067
4416
        | select_derived_init get_select_lex select_derived2
4073
4422
              if (sel->set_braces(1))
4074
4423
              {
4075
4424
                my_parse_error(ER(ER_SYNTAX_ERROR));
4076
 
                DRIZZLE_YYABORT;
 
4425
                MYSQL_YYABORT;
4077
4426
              }
4078
4427
              /* select in braces, can't contain global parameters */
4079
4428
              if (sel->master_unit()->fake_select_lex)
4081
4430
                   sel->master_unit()->fake_select_lex;
4082
4431
            }
4083
4432
            if ($2->init_nested_join(lex->thd))
4084
 
              DRIZZLE_YYABORT;
 
4433
              MYSQL_YYABORT;
4085
4434
            $$= 0;
4086
4435
            /* incomplete derived tables return NULL, we must be
4087
4436
               nested in select_derived rule to be here. */
4130
4479
                                               new Table_ident(unit), $5, 0,
4131
4480
                                               TL_READ)))
4132
4481
 
4133
 
                DRIZZLE_YYABORT;
 
4482
                MYSQL_YYABORT;
4134
4483
              sel->add_joined_table($$);
4135
4484
              lex->pop_context();
4136
4485
            }
4138
4487
            {
4139
4488
              /* simple nested joins cannot have aliases or unions */
4140
4489
              my_parse_error(ER(ER_SYNTAX_ERROR));
4141
 
              DRIZZLE_YYABORT;
 
4490
              MYSQL_YYABORT;
4142
4491
            }
4143
4492
            else
4144
4493
              $$= $3;
4152
4501
          union_option
4153
4502
          {
4154
4503
            if (add_select_to_union_list(Lex, (bool)$3))
4155
 
              DRIZZLE_YYABORT;
 
4504
              MYSQL_YYABORT;
4156
4505
          }
4157
4506
          query_specification
4158
4507
          {
4174
4523
            if (lex->current_select->set_braces(0))
4175
4524
            {
4176
4525
              my_parse_error(ER(ER_SYNTAX_ERROR));
4177
 
              DRIZZLE_YYABORT;
 
4526
              MYSQL_YYABORT;
4178
4527
            }
4179
4528
            if (sel->linkage == UNION_TYPE &&
4180
4529
                sel->master_unit()->first_select()->braces)
4181
4530
            {
4182
4531
              my_parse_error(ER(ER_SYNTAX_ERROR));
4183
 
              DRIZZLE_YYABORT;
 
4532
              MYSQL_YYABORT;
4184
4533
            }
4185
4534
          }
4186
4535
        ;
4207
4556
          {
4208
4557
            LEX *lex= Lex;
4209
4558
            if ($1->init_nested_join(lex->thd))
4210
 
              DRIZZLE_YYABORT;
 
4559
              MYSQL_YYABORT;
4211
4560
          }
4212
4561
          derived_table_list
4213
4562
          {
4216
4565
               for derived tables, both must equal NULL */
4217
4566
 
4218
4567
            if (!($$= $1->end_nested_join(lex->thd)) && $3)
4219
 
              DRIZZLE_YYABORT;
 
4568
              MYSQL_YYABORT;
4220
4569
            if (!$3 && $$)
4221
4570
            {
4222
4571
              my_parse_error(ER(ER_SYNTAX_ERROR));
4223
 
              DRIZZLE_YYABORT;
 
4572
              MYSQL_YYABORT;
4224
4573
            }
4225
4574
          }
4226
4575
        ;
4233
4582
                lex->sql_command == (int)SQLCOM_PURGE)
4234
4583
            {
4235
4584
              my_parse_error(ER(ER_SYNTAX_ERROR));
4236
 
              DRIZZLE_YYABORT;
 
4585
              MYSQL_YYABORT;
4237
4586
            }
4238
4587
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
4239
4588
                mysql_new_select(lex, 1))
4240
 
              DRIZZLE_YYABORT;
 
4589
              MYSQL_YYABORT;
4241
4590
            mysql_init_select(lex);
4242
4591
            lex->current_select->linkage= DERIVED_TABLE_TYPE;
4243
4592
            lex->current_select->parsing_place= SELECT_LIST;
4261
4610
            if (! lex->parsing_options.allows_derived)
4262
4611
            {
4263
4612
              my_error(ER_VIEW_SELECT_DERIVED, MYF(0));
4264
 
              DRIZZLE_YYABORT;
 
4613
              MYSQL_YYABORT;
4265
4614
            }
4266
4615
 
4267
4616
            SELECT_LEX *sel= lex->current_select;
4268
 
            TableList *embedding;
 
4617
            TABLE_LIST *embedding;
4269
4618
            if (!sel->embedding || sel->end_nested_join(lex->thd))
4270
4619
            {
4271
4620
              /* we are not in parentheses */
4272
4621
              my_parse_error(ER(ER_SYNTAX_ERROR));
4273
 
              DRIZZLE_YYABORT;
 
4622
              MYSQL_YYABORT;
4274
4623
            }
4275
4624
            embedding= Select->embedding;
4276
4625
            $$= embedding &&
4349
4698
          ident
4350
4699
          {
4351
4700
            if (!($$= new List<String>))
4352
 
              DRIZZLE_YYABORT;
 
4701
              MYSQL_YYABORT;
4353
4702
            $$->push_back(new (YYTHD->mem_root)
4354
4703
                              String((const char *) $1.str, $1.length,
4355
4704
                                      system_charset_info));
4410
4759
        ;
4411
4760
 
4412
4761
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;}
 
4762
          DATE_SYM  {$$=MYSQL_TIMESTAMP_DATE;}
 
4763
        | TIME_SYM  {$$=MYSQL_TIMESTAMP_TIME;}
 
4764
        | DATETIME  {$$=MYSQL_TIMESTAMP_DATETIME;}
 
4765
        | TIMESTAMP {$$=MYSQL_TIMESTAMP_DATETIME;}
4417
4766
        ;
4418
4767
 
4419
4768
table_alias:
4468
4817
opt_escape:
4469
4818
          ESCAPE_SYM simple_expr 
4470
4819
          {
4471
 
            Lex->escape_used= true;
 
4820
            Lex->escape_used= TRUE;
4472
4821
            $$= $2;
4473
4822
          }
4474
4823
        | /* empty */
4475
4824
          {
4476
 
            Lex->escape_used= false;
4477
 
            $$= new Item_string("\\", 1, &my_charset_utf8_general_ci);
 
4825
            Lex->escape_used= FALSE;
 
4826
            $$= new Item_string("\\", 1, &my_charset_latin1);
4478
4827
          }
4479
4828
        ;
4480
4829
 
4489
4838
 
4490
4839
group_list:
4491
4840
          group_list ',' order_ident order_dir
4492
 
          { if (add_group_to_list(YYTHD, $3,(bool) $4)) DRIZZLE_YYABORT; }
 
4841
          { if (add_group_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
4493
4842
        | order_ident order_dir
4494
 
          { if (add_group_to_list(YYTHD, $1,(bool) $2)) DRIZZLE_YYABORT; }
 
4843
          { if (add_group_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
4495
4844
        ;
4496
4845
 
4497
4846
olap_opt:
4498
4847
          /* empty */ {}
 
4848
        | WITH_CUBE_SYM
 
4849
          {
 
4850
            /*
 
4851
              'WITH CUBE' is reserved in the MySQL syntax, but not implemented,
 
4852
              and cause LALR(2) conflicts.
 
4853
              This syntax is not standard.
 
4854
              MySQL syntax: GROUP BY col1, col2, col3 WITH CUBE
 
4855
              SQL-2003: GROUP BY ... CUBE(col1, col2, col3)
 
4856
            */
 
4857
            LEX *lex=Lex;
 
4858
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
 
4859
            {
 
4860
              my_error(ER_WRONG_USAGE, MYF(0), "WITH CUBE",
 
4861
                       "global union parameters");
 
4862
              MYSQL_YYABORT;
 
4863
            }
 
4864
            lex->current_select->olap= CUBE_TYPE;
 
4865
            my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE");
 
4866
            MYSQL_YYABORT;
 
4867
          }
4499
4868
        | WITH_ROLLUP_SYM
4500
4869
          {
4501
4870
            /*
4510
4879
            {
4511
4880
              my_error(ER_WRONG_USAGE, MYF(0), "WITH ROLLUP",
4512
4881
                       "global union parameters");
4513
 
              DRIZZLE_YYABORT;
 
4882
              MYSQL_YYABORT;
4514
4883
            }
4515
4884
            lex->current_select->olap= ROLLUP_TYPE;
4516
4885
          }
4535
4904
            THD *thd= YYTHD;
4536
4905
            bool ascending= ($2 == 1) ? true : false;
4537
4906
            if (add_order_to_list(thd, $1, ascending))
4538
 
              DRIZZLE_YYABORT;
 
4907
              MYSQL_YYABORT;
4539
4908
          }
4540
4909
        ;
4541
4910
 
4560
4929
            {
4561
4930
              my_error(ER_WRONG_USAGE, MYF(0),
4562
4931
                       "CUBE/ROLLUP", "ORDER BY");
4563
 
              DRIZZLE_YYABORT;
 
4932
              MYSQL_YYABORT;
4564
4933
            }
4565
4934
            if (lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
4566
4935
            {
4577
4946
                  (first_sl->order_list.elements || 
4578
4947
                   first_sl->select_limit) &&            
4579
4948
                  unit->add_fake_select_lex(lex->thd))
4580
 
                DRIZZLE_YYABORT;
 
4949
                MYSQL_YYABORT;
4581
4950
            }
4582
4951
          }
4583
4952
          order_list
4585
4954
 
4586
4955
order_list:
4587
4956
          order_list ',' order_ident order_dir
4588
 
          { if (add_order_to_list(YYTHD, $3,(bool) $4)) DRIZZLE_YYABORT; }
 
4957
          { if (add_order_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
4589
4958
        | order_ident order_dir
4590
 
          { if (add_order_to_list(YYTHD, $1,(bool) $2)) DRIZZLE_YYABORT; }
 
4959
          { if (add_order_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
4591
4960
        ;
4592
4961
 
4593
4962
order_dir:
4641
5010
        ;
4642
5011
 
4643
5012
limit_option:
4644
 
          ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
 
5013
        param_marker
 
5014
        {
 
5015
          ((Item_param *) $1)->limit_clause_param= TRUE;
 
5016
        }
 
5017
        | ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
4645
5018
        | LONG_NUM      { $$= new Item_uint($1.str, $1.length); }
4646
5019
        | NUM           { $$= new Item_uint($1.str, $1.length); }
4647
5020
        ;
4674
5047
        | HEX_NUM       { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4675
5048
        | LONG_NUM      { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4676
5049
        | ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4677
 
        | dec_num_error { DRIZZLE_YYABORT; }
 
5050
        | dec_num_error { MYSQL_YYABORT; }
4678
5051
        ;
4679
5052
 
4680
5053
ulonglong_num:
4681
 
          NUM           { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4682
 
        | ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4683
 
        | LONG_NUM      { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4684
 
        | DECIMAL_NUM   { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4685
 
        | FLOAT_NUM     { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
 
5054
          NUM           { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
 
5055
        | ULONGLONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
 
5056
        | LONG_NUM      { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
 
5057
        | DECIMAL_NUM   { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
 
5058
        | FLOAT_NUM     { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); }
4686
5059
        ;
4687
5060
 
4688
5061
dec_num_error:
4704
5077
          {
4705
5078
            LEX *lex=Lex;
4706
5079
            if (!lex->describe && (!(lex->result= new select_dumpvar())))
4707
 
              DRIZZLE_YYABORT;
 
5080
              MYSQL_YYABORT;
4708
5081
          }
4709
5082
          select_var_list
4710
5083
          {}
4726
5099
                The parser won't create select_result instance only
4727
5100
                if it's an EXPLAIN.
4728
5101
              */
4729
 
              assert(lex->describe);
 
5102
              DBUG_ASSERT(lex->describe);
4730
5103
          }
4731
5104
        ;
4732
5105
 
4736
5109
            if (! Lex->parsing_options.allows_select_into)
4737
5110
            {
4738
5111
              my_error(ER_VIEW_SELECT_CLAUSE, MYF(0), "INTO");
4739
 
              DRIZZLE_YYABORT;
 
5112
              MYSQL_YYABORT;
4740
5113
            }
4741
5114
          }
4742
5115
          into_destination
4748
5121
            LEX *lex= Lex;
4749
5122
            if (!(lex->exchange= new sql_exchange($2.str, 0)) ||
4750
5123
                !(lex->result= new select_export(lex->exchange)))
4751
 
              DRIZZLE_YYABORT;
 
5124
              MYSQL_YYABORT;
4752
5125
          }
4753
5126
          opt_field_term opt_line_term
4754
5127
        | DUMPFILE TEXT_STRING_filesystem
4757
5130
            if (!lex->describe)
4758
5131
            {
4759
5132
              if (!(lex->exchange= new sql_exchange($2.str,1)))
4760
 
                DRIZZLE_YYABORT;
 
5133
                MYSQL_YYABORT;
4761
5134
              if (!(lex->result= new select_dump(lex->exchange)))
4762
 
                DRIZZLE_YYABORT;
 
5135
                MYSQL_YYABORT;
4763
5136
            }
4764
5137
          }
4765
5138
        | select_var_list_init
4771
5144
*/
4772
5145
 
4773
5146
drop:
4774
 
          DROP opt_temporary table_or_tables if_exists table_list
 
5147
          DROP opt_temporary table_or_tables if_exists table_list opt_restrict
4775
5148
          {
4776
5149
            LEX *lex=Lex;
4777
5150
            lex->sql_command = SQLCOM_DROP_TABLE;
4789
5162
                                                               $4.str));
4790
5163
            if (!lex->current_select->add_table_to_list(lex->thd, $6, NULL,
4791
5164
                                                        TL_OPTION_UPDATING))
4792
 
              DRIZZLE_YYABORT;
 
5165
              MYSQL_YYABORT;
4793
5166
          }
4794
5167
        | DROP DATABASE if_exists ident
4795
5168
          {
4807
5180
          table_ident
4808
5181
          {
4809
5182
            if (!Select->add_table_to_list(YYTHD, $1, NULL, TL_OPTION_UPDATING))
4810
 
              DRIZZLE_YYABORT;
 
5183
              MYSQL_YYABORT;
4811
5184
          }
4812
5185
        ;
4813
5186
 
4822
5195
            if (!Select->add_table_to_list(YYTHD, $1, NULL,
4823
5196
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
4824
5197
                                           Lex->lock_option ))
4825
 
              DRIZZLE_YYABORT;
 
5198
              MYSQL_YYABORT;
4826
5199
          }
4827
5200
        ;
4828
5201
 
4914
5287
            LEX *lex=Lex;
4915
5288
            if (!(lex->insert_list = new List_item) ||
4916
5289
                lex->many_values.push_back(lex->insert_list))
4917
 
              DRIZZLE_YYABORT;
 
5290
              MYSQL_YYABORT;
4918
5291
          }
4919
5292
          ident_eq_list
4920
5293
        ;
4951
5324
            LEX *lex=Lex;
4952
5325
            if (lex->field_list.push_back($1) ||
4953
5326
                lex->insert_list->push_back($3))
4954
 
              DRIZZLE_YYABORT;
 
5327
              MYSQL_YYABORT;
4955
5328
          }
4956
5329
        ;
4957
5330
 
4969
5342
          '('
4970
5343
          {
4971
5344
              if (!(Lex->insert_list = new List_item))
4972
 
                DRIZZLE_YYABORT;
 
5345
                MYSQL_YYABORT;
4973
5346
          }
4974
5347
          opt_values ')'
4975
5348
          {
4976
5349
            LEX *lex=Lex;
4977
5350
            if (lex->many_values.push_back(lex->insert_list))
4978
 
              DRIZZLE_YYABORT;
 
5351
              MYSQL_YYABORT;
4979
5352
          }
4980
5353
        ;
4981
5354
 
4988
5361
          values ','  expr_or_default
4989
5362
          {
4990
5363
            if (Lex->insert_list->push_back($3))
4991
 
              DRIZZLE_YYABORT;
 
5364
              MYSQL_YYABORT;
4992
5365
          }
4993
5366
        | expr_or_default
4994
5367
          {
4995
5368
            if (Lex->insert_list->push_back($1))
4996
 
              DRIZZLE_YYABORT;
 
5369
              MYSQL_YYABORT;
4997
5370
          }
4998
5371
        ;
4999
5372
 
5030
5403
              /* it is single table update and it is update of derived table */
5031
5404
              my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
5032
5405
                       lex->select_lex.get_table_list()->alias, "UPDATE");
5033
 
              DRIZZLE_YYABORT;
 
5406
              MYSQL_YYABORT;
5034
5407
            }
5035
5408
            /*
5036
5409
              In case of multi-update setting write lock for all tables may
5051
5424
          simple_ident_nospvar equal expr_or_default
5052
5425
          {
5053
5426
            if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
5054
 
              DRIZZLE_YYABORT;
 
5427
              MYSQL_YYABORT;
5055
5428
          }
5056
5429
        ;
5057
5430
 
5066
5439
          LEX *lex= Lex;
5067
5440
          if (lex->update_list.push_back($1) || 
5068
5441
              lex->value_list.push_back($3))
5069
 
              DRIZZLE_YYABORT;
 
5442
              MYSQL_YYABORT;
5070
5443
          }
5071
5444
        ;
5072
5445
 
5095
5468
          {
5096
5469
            if (!Select->add_table_to_list(YYTHD, $2, NULL, TL_OPTION_UPDATING,
5097
5470
                                           Lex->lock_option))
5098
 
              DRIZZLE_YYABORT;
 
5471
              MYSQL_YYABORT;
5099
5472
          }
5100
5473
          where_clause opt_order_clause
5101
5474
          delete_limit_clause {}
5104
5477
          FROM join_table_list where_clause
5105
5478
          {
5106
5479
            if (multi_delete_set_locks_and_link_aux_tables(Lex))
5107
 
              DRIZZLE_YYABORT;
 
5480
              MYSQL_YYABORT;
5108
5481
          }
5109
5482
        | FROM table_alias_ref_list
5110
5483
          { mysql_init_multi_delete(Lex); }
5111
5484
          USING join_table_list where_clause
5112
5485
          {
5113
5486
            if (multi_delete_set_locks_and_link_aux_tables(Lex))
5114
 
              DRIZZLE_YYABORT;
 
5487
              MYSQL_YYABORT;
5115
5488
          }
5116
5489
        ;
5117
5490
 
5127
5500
                                           NULL,
5128
5501
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5129
5502
                                           Lex->lock_option))
5130
 
              DRIZZLE_YYABORT;
 
5503
              MYSQL_YYABORT;
5131
5504
          }
5132
5505
        | ident '.' ident opt_wild
5133
5506
          {
5136
5509
                                           NULL,
5137
5510
                                           TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5138
5511
                                           Lex->lock_option))
5139
 
              DRIZZLE_YYABORT;
 
5512
              MYSQL_YYABORT;
5140
5513
          }
5141
5514
        ;
5142
5515
 
5181
5554
            lex->lock_option= TL_READ;
5182
5555
            mysql_init_select(lex);
5183
5556
            lex->current_select->parsing_place= SELECT_LIST;
5184
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
 
5557
            bzero((char*) &lex->create_info,sizeof(lex->create_info));
5185
5558
          }
5186
5559
          show_param
5187
5560
          {}
5188
5561
        ;
5189
5562
 
5190
5563
show_param:
5191
 
           DATABASES show_wild
 
5564
           DATABASES wild_and_where
5192
5565
           {
5193
5566
             LEX *lex= Lex;
5194
5567
             lex->sql_command= SQLCOM_SHOW_DATABASES;
5195
5568
             if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
5196
 
               DRIZZLE_YYABORT;
 
5569
               MYSQL_YYABORT;
5197
5570
           }
5198
 
         | opt_full TABLES opt_db show_wild
 
5571
         | opt_full TABLES opt_db wild_and_where
5199
5572
           {
5200
5573
             LEX *lex= Lex;
5201
5574
             lex->sql_command= SQLCOM_SHOW_TABLES;
5202
5575
             lex->select_lex.db= $3;
5203
5576
             if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
5204
 
               DRIZZLE_YYABORT;
 
5577
               MYSQL_YYABORT;
5205
5578
           }
5206
 
         | TABLE_SYM STATUS_SYM opt_db show_wild
 
5579
         | TABLE_SYM STATUS_SYM opt_db wild_and_where
5207
5580
           {
5208
5581
             LEX *lex= Lex;
5209
5582
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
5210
5583
             lex->select_lex.db= $3;
5211
5584
             if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
5212
 
               DRIZZLE_YYABORT;
 
5585
               MYSQL_YYABORT;
5213
5586
           }
5214
 
        | OPEN_SYM TABLES opt_db show_wild
 
5587
        | OPEN_SYM TABLES opt_db wild_and_where
5215
5588
          {
5216
5589
            LEX *lex= Lex;
5217
5590
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
5218
5591
            lex->select_lex.db= $3;
5219
5592
            if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
5220
 
              DRIZZLE_YYABORT;
 
5593
              MYSQL_YYABORT;
5221
5594
          }
5222
5595
        | ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
5223
5596
          { 
5224
5597
            Lex->create_info.db_type= $2; 
5225
5598
            Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
5226
5599
          }
5227
 
        | opt_full COLUMNS from_or_in table_ident opt_db show_wild
 
5600
        | opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
5228
5601
          {
5229
5602
            LEX *lex= Lex;
5230
5603
            lex->sql_command= SQLCOM_SHOW_FIELDS;
5231
5604
            if ($5)
5232
5605
              $4->change_db($5);
5233
5606
            if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
5234
 
              DRIZZLE_YYABORT;
 
5607
              MYSQL_YYABORT;
5235
5608
          }
5236
5609
        | master_or_binary LOGS_SYM
5237
5610
          {
5238
5611
            Lex->sql_command = SQLCOM_SHOW_BINLOGS;
5239
5612
          }
 
5613
        | SLAVE HOSTS_SYM
 
5614
          {
 
5615
            Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
 
5616
          }
 
5617
        | BINLOG_SYM EVENTS_SYM binlog_in binlog_from
 
5618
          {
 
5619
            LEX *lex= Lex;
 
5620
            lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
 
5621
          } opt_limit_clause_init
5240
5622
        | keys_or_index from_or_in table_ident opt_db where_clause
5241
5623
          {
5242
5624
            LEX *lex= Lex;
5244
5626
            if ($4)
5245
5627
              $3->change_db($4);
5246
5628
            if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
5247
 
              DRIZZLE_YYABORT;
 
5629
              MYSQL_YYABORT;
5248
5630
          }
5249
5631
        | COUNT_SYM '(' '*' ')' WARNINGS
5250
5632
          { (void) create_select_for_variable("warning_count"); }
5254
5636
          { Lex->sql_command = SQLCOM_SHOW_WARNS;}
5255
5637
        | ERRORS opt_limit_clause_init
5256
5638
          { Lex->sql_command = SQLCOM_SHOW_ERRORS;}
5257
 
        | opt_var_type STATUS_SYM show_wild
 
5639
        | opt_var_type STATUS_SYM wild_and_where
5258
5640
          {
5259
5641
            LEX *lex= Lex;
5260
5642
            lex->sql_command= SQLCOM_SHOW_STATUS;
5261
5643
            lex->option_type= $1;
5262
5644
            if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
5263
 
              DRIZZLE_YYABORT;
 
5645
              MYSQL_YYABORT;
5264
5646
          }
5265
5647
        | opt_full PROCESSLIST_SYM
5266
5648
          { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
5267
 
        | opt_var_type  VARIABLES show_wild
 
5649
        | opt_var_type  VARIABLES wild_and_where
5268
5650
          {
5269
5651
            LEX *lex= Lex;
5270
5652
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
5271
5653
            lex->option_type= $1;
5272
5654
            if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
5273
 
              DRIZZLE_YYABORT;
 
5655
              MYSQL_YYABORT;
 
5656
          }
 
5657
        | charset wild_and_where
 
5658
          {
 
5659
            LEX *lex= Lex;
 
5660
            lex->sql_command= SQLCOM_SHOW_CHARSETS;
 
5661
            if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
 
5662
              MYSQL_YYABORT;
 
5663
          }
 
5664
        | COLLATION_SYM wild_and_where
 
5665
          {
 
5666
            LEX *lex= Lex;
 
5667
            lex->sql_command= SQLCOM_SHOW_COLLATIONS;
 
5668
            if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS))
 
5669
              MYSQL_YYABORT;
5274
5670
          }
5275
5671
        | CREATE DATABASE opt_if_not_exists ident
5276
5672
          {
5283
5679
            LEX *lex= Lex;
5284
5680
            lex->sql_command = SQLCOM_SHOW_CREATE;
5285
5681
            if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
5286
 
              DRIZZLE_YYABORT;
 
5682
              MYSQL_YYABORT;
 
5683
            lex->create_info.default_storage_media= HA_SM_DEFAULT;
5287
5684
          }
5288
5685
        | MASTER_SYM STATUS_SYM
5289
5686
          {
5314
5711
        | IN_SYM
5315
5712
        ;
5316
5713
 
5317
 
show_wild:
 
5714
binlog_in:
 
5715
          /* empty */            { Lex->mi.log_file_name = 0; }
 
5716
        | IN_SYM TEXT_STRING_sys { Lex->mi.log_file_name = $2.str; }
 
5717
        ;
 
5718
 
 
5719
binlog_from:
 
5720
          /* empty */        { Lex->mi.pos = 4; /* skip magic number */ }
 
5721
        | FROM ulonglong_num { Lex->mi.pos = $2; }
 
5722
        ;
 
5723
 
 
5724
wild_and_where:
5318
5725
          /* empty */
5319
5726
        | LIKE TEXT_STRING_sys
5320
5727
          {
5321
5728
            Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length,
5322
5729
                                                    system_charset_info);
5323
5730
          }
 
5731
        | WHERE expr
 
5732
          {
 
5733
            Select->where= $2;
 
5734
            if ($2)
 
5735
              $2->top_level_item();
 
5736
          }
5324
5737
        ;
5325
5738
 
5326
5739
/* A Oracle compatible synonym for show */
5335
5748
            lex->select_lex.db= 0;
5336
5749
            lex->verbose= 0;
5337
5750
            if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS))
5338
 
              DRIZZLE_YYABORT;
 
5751
              MYSQL_YYABORT;
5339
5752
          }
5340
5753
          opt_describe_column {}
5341
5754
        | describe_command opt_extended_describe
5372
5785
/* flush things */
5373
5786
 
5374
5787
flush:
5375
 
          FLUSH_SYM
 
5788
          FLUSH_SYM opt_no_write_to_binlog
5376
5789
          {
5377
5790
            LEX *lex=Lex;
5378
5791
            lex->sql_command= SQLCOM_FLUSH;
5379
5792
            lex->type= 0;
 
5793
            lex->no_write_to_binlog= $2;
5380
5794
          }
5381
5795
          flush_options
5382
5796
          {}
5405
5819
          { Lex->type|= REFRESH_SLAVE; }
5406
5820
        | MASTER_SYM
5407
5821
          { Lex->type|= REFRESH_MASTER; }
 
5822
        | DES_KEY_FILE
 
5823
          { Lex->type|= REFRESH_DES_KEY_FILE; }
5408
5824
        | RESOURCES
5409
5825
          { Lex->type|= REFRESH_USER_RESOURCES; }
5410
5826
        ;
5496
5912
/* import, export of files */
5497
5913
 
5498
5914
load:
5499
 
          LOAD data_file
 
5915
          LOAD data_or_xml
5500
5916
          {
5501
5917
            THD *thd= YYTHD;
5502
5918
            LEX *lex= thd->lex;
5513
5929
            lex->duplicates= DUP_ERROR;
5514
5930
            lex->ignore= 0;
5515
5931
            if (!(lex->exchange= new sql_exchange($7.str, 0, $2)))
5516
 
              DRIZZLE_YYABORT;
 
5932
              MYSQL_YYABORT;
5517
5933
          }
5518
5934
          opt_duplicate INTO
5519
5935
          {
5527
5943
            LEX *lex=Lex;
5528
5944
            if (!Select->add_table_to_list(YYTHD, $13, NULL, TL_OPTION_UPDATING,
5529
5945
                                           lex->lock_option))
5530
 
              DRIZZLE_YYABORT;
 
5946
              MYSQL_YYABORT;
5531
5947
            lex->field_list.empty();
5532
5948
            lex->update_list.empty();
5533
5949
            lex->value_list.empty();
5534
5950
          }
 
5951
          opt_load_data_charset
 
5952
          { Lex->exchange->cs= $15; }
 
5953
          opt_xml_rows_identified_by
5535
5954
          opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5536
5955
          opt_load_data_set_spec
5537
5956
          {}
5538
5957
        ;
5539
5958
 
5540
 
data_file:
5541
 
        DATA_SYM  { $$= FILETYPE_CSV; };
 
5959
data_or_xml:
 
5960
        DATA_SYM  { $$= FILETYPE_CSV; }
 
5961
        | XML_SYM { $$= FILETYPE_XML; }
 
5962
        ;
5542
5963
 
5543
5964
opt_local:
5544
5965
          /* empty */ { $$=0;}
5573
5994
field_term:
5574
5995
          TERMINATED BY text_string 
5575
5996
          {
5576
 
            assert(Lex->exchange != 0);
 
5997
            DBUG_ASSERT(Lex->exchange != 0);
5577
5998
            Lex->exchange->field_term= $3;
5578
5999
          }
5579
6000
        | OPTIONALLY ENCLOSED BY text_string
5580
6001
          {
5581
6002
            LEX *lex= Lex;
5582
 
            assert(lex->exchange != 0);
 
6003
            DBUG_ASSERT(lex->exchange != 0);
5583
6004
            lex->exchange->enclosed= $4;
5584
6005
            lex->exchange->opt_enclosed= 1;
5585
6006
          }
5586
6007
        | ENCLOSED BY text_string
5587
6008
          {
5588
 
            assert(Lex->exchange != 0);
 
6009
            DBUG_ASSERT(Lex->exchange != 0);
5589
6010
            Lex->exchange->enclosed= $3;
5590
6011
          }
5591
6012
        | ESCAPED BY text_string
5592
6013
          {
5593
 
            assert(Lex->exchange != 0);
 
6014
            DBUG_ASSERT(Lex->exchange != 0);
5594
6015
            Lex->exchange->escaped= $3;
5595
6016
          }
5596
6017
        ;
5608
6029
line_term:
5609
6030
          TERMINATED BY text_string
5610
6031
          {
5611
 
            assert(Lex->exchange != 0);
 
6032
            DBUG_ASSERT(Lex->exchange != 0);
5612
6033
            Lex->exchange->line_term= $3;
5613
6034
          }
5614
6035
        | STARTING BY text_string
5615
6036
          {
5616
 
            assert(Lex->exchange != 0);
 
6037
            DBUG_ASSERT(Lex->exchange != 0);
5617
6038
            Lex->exchange->line_start= $3;
5618
6039
          }
5619
6040
        ;
5620
6041
 
 
6042
opt_xml_rows_identified_by:
 
6043
        /* empty */ { }
 
6044
        | ROWS_SYM IDENTIFIED_SYM BY text_string
 
6045
          { Lex->exchange->line_term = $4; };
 
6046
 
5621
6047
opt_ignore_lines:
5622
6048
          /* empty */
5623
6049
        | IGNORE_SYM NUM lines_or_rows
5624
6050
          {
5625
 
            assert(Lex->exchange != 0);
 
6051
            DBUG_ASSERT(Lex->exchange != 0);
5626
6052
            Lex->exchange->skip_lines= atol($2.str);
5627
6053
          }
5628
6054
        ;
5663
6089
          {
5664
6090
            LEX_STRING tmp;
5665
6091
            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 &&
 
6092
            CHARSET_INFO *cs_con= thd->variables.collation_connection;
 
6093
            CHARSET_INFO *cs_cli= thd->variables.character_set_client;
 
6094
            uint repertoire= thd->lex->text_string_is_7bit &&
5669
6095
                             my_charset_is_ascii_based(cs_cli) ?
5670
6096
                             MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5671
6097
            if (thd->charset_is_collation_connection ||
5677
6103
            $$= new Item_string(tmp.str, tmp.length, cs_con,
5678
6104
                                DERIVATION_COERCIBLE, repertoire);
5679
6105
          }
 
6106
        | NCHAR_STRING
 
6107
          {
 
6108
            uint repertoire= Lex->text_string_is_7bit ?
 
6109
                             MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
 
6110
            DBUG_ASSERT(my_charset_is_ascii_based(national_charset_info));
 
6111
            $$= new Item_string($1.str, $1.length, national_charset_info,
 
6112
                                DERIVATION_COERCIBLE, repertoire);
 
6113
          }
5680
6114
        | UNDERSCORE_CHARSET TEXT_STRING
5681
6115
          {
5682
6116
            Item_string *str= new Item_string($2.str, $2.length, $1);
5683
6117
            str->set_repertoire_from_value();
5684
 
            str->set_cs_specified(true);
 
6118
            str->set_cs_specified(TRUE);
5685
6119
 
5686
6120
            $$= str;
5687
6121
          }
5695
6129
                 If the string has been pure ASCII so far,
5696
6130
                 check the new part.
5697
6131
              */
5698
 
              const CHARSET_INFO * const cs= YYTHD->variables.collation_connection;
 
6132
              CHARSET_INFO *cs= YYTHD->variables.collation_connection;
5699
6133
              item->collation.repertoire|= my_string_repertoire(cs,
5700
6134
                                                                $2.str,
5701
6135
                                                                $2.length);
5733
6167
          }
5734
6168
        ;
5735
6169
 
 
6170
param_marker:
 
6171
          PARAM_MARKER
 
6172
          {
 
6173
            THD *thd= YYTHD;
 
6174
            LEX *lex= thd->lex;
 
6175
            Lex_input_stream *lip= thd->m_lip;
 
6176
            Item_param *item;
 
6177
            if (! lex->parsing_options.allows_variable)
 
6178
            {
 
6179
              my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));
 
6180
              MYSQL_YYABORT;
 
6181
            }
 
6182
            item= new Item_param((uint) (lip->get_tok_start() - thd->query));
 
6183
            if (!($$= item) || lex->param_list.push_back(item))
 
6184
            {
 
6185
              my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
 
6186
              MYSQL_YYABORT;
 
6187
            }
 
6188
          }
 
6189
        ;
 
6190
 
5736
6191
signed_literal:
5737
6192
          literal { $$ = $1; }
5738
6193
        | '+' NUM_literal { $$ = $2; }
5772
6227
                              str ? str->length() : 0,
5773
6228
                              $1);
5774
6229
            if (!item_str ||
5775
 
                !item_str->check_well_formed_result(&item_str->str_value, true))
 
6230
                !item_str->check_well_formed_result(&item_str->str_value, TRUE))
5776
6231
            {
5777
 
              DRIZZLE_YYABORT;
 
6232
              MYSQL_YYABORT;
5778
6233
            }
5779
6234
 
5780
6235
            item_str->set_repertoire_from_value();
5781
 
            item_str->set_cs_specified(true);
 
6236
            item_str->set_cs_specified(TRUE);
5782
6237
 
5783
6238
            $$= item_str;
5784
6239
          }
5799
6254
                              str ? str->length() : 0,
5800
6255
                              $1);
5801
6256
            if (!item_str ||
5802
 
                !item_str->check_well_formed_result(&item_str->str_value, true))
 
6257
                !item_str->check_well_formed_result(&item_str->str_value, TRUE))
5803
6258
            {
5804
 
              DRIZZLE_YYABORT;
 
6259
              MYSQL_YYABORT;
5805
6260
            }
5806
6261
 
5807
 
            item_str->set_cs_specified(true);
 
6262
            item_str->set_cs_specified(TRUE);
5808
6263
 
5809
6264
            $$= item_str;
5810
6265
          }
5817
6272
          NUM
5818
6273
          {
5819
6274
            int error;
5820
 
            $$ = new Item_int($1.str, (int64_t) my_strtoll10($1.str, NULL, &error), $1.length);
 
6275
            $$ = new Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length);
5821
6276
          }
5822
6277
        | LONG_NUM
5823
6278
          {
5824
6279
            int error;
5825
 
            $$ = new Item_int($1.str, (int64_t) my_strtoll10($1.str, NULL, &error), $1.length);
 
6280
            $$ = new Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length);
5826
6281
          }
5827
6282
        | ULONGLONG_NUM
5828
6283
          { $$ = new Item_uint($1.str, $1.length); }
5831
6286
            $$= new Item_decimal($1.str, $1.length, YYTHD->charset());
5832
6287
            if (YYTHD->is_error())
5833
6288
            {
5834
 
              DRIZZLE_YYABORT;
 
6289
              MYSQL_YYABORT;
5835
6290
            }
5836
6291
          }
5837
6292
        | FLOAT_NUM
5839
6294
            $$ = new Item_float($1.str, $1.length);
5840
6295
            if (YYTHD->is_error())
5841
6296
            {
5842
 
              DRIZZLE_YYABORT;
 
6297
              MYSQL_YYABORT;
5843
6298
            }
5844
6299
          }
5845
6300
        ;
5857
6312
          ident '.' '*'
5858
6313
          {
5859
6314
            SELECT_LEX *sel= Select;
5860
 
            $$ = new Item_field(Lex->current_context(), NULL, $1.str, "*");
 
6315
            $$ = new Item_field(Lex->current_context(), NullS, $1.str, "*");
5861
6316
            sel->with_wild++;
5862
6317
          }
5863
6318
        | ident '.' ident '.' '*'
5864
6319
          {
5865
6320
            SELECT_LEX *sel= Select;
5866
6321
            $$ = new Item_field(Lex->current_context(), (YYTHD->client_capabilities &
5867
 
                                CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6322
                                CLIENT_NO_SCHEMA ? NullS : $1.str),
5868
6323
                                $3.str,"*");
5869
6324
            sel->with_wild++;
5870
6325
          }
5881
6336
              SELECT_LEX *sel=Select;
5882
6337
              $$= (sel->parsing_place != IN_HAVING ||
5883
6338
                  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);
 
6339
                  (Item*) new Item_field(Lex->current_context(), NullS, NullS, $1.str) :
 
6340
                  (Item*) new Item_ref(Lex->current_context(), NullS, NullS, $1.str);
5888
6341
            }
5889
6342
          }
5890
6343
        | simple_ident_q { $$= $1; }
5896
6349
            SELECT_LEX *sel=Select;
5897
6350
            $$= (sel->parsing_place != IN_HAVING ||
5898
6351
                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);
 
6352
                (Item*) new Item_field(Lex->current_context(), NullS, NullS, $1.str) :
 
6353
                (Item*) new Item_ref(Lex->current_context(), NullS, NullS, $1.str);
5903
6354
          }
5904
6355
        | simple_ident_q { $$= $1; }
5905
6356
        ;
5919
6370
              }
5920
6371
              $$= (sel->parsing_place != IN_HAVING ||
5921
6372
                  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);
 
6373
                  (Item*) new Item_field(Lex->current_context(), NullS, $1.str, $3.str) :
 
6374
                  (Item*) new Item_ref(Lex->current_context(), NullS, $1.str, $3.str);
5926
6375
            }
5927
6376
          }
5928
6377
        | '.' ident '.' ident
5937
6386
            }
5938
6387
            $$= (sel->parsing_place != IN_HAVING ||
5939
6388
                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);
 
6389
                (Item*) new Item_field(Lex->current_context(), NullS, $2.str, $4.str) :
 
6390
                (Item*) new Item_ref(Lex->current_context(), NullS, $2.str, $4.str);
5943
6391
          }
5944
6392
        | ident '.' ident '.' ident
5945
6393
          {
5955
6403
                sel->get_in_sum_expr() > 0) ?
5956
6404
                (Item*) new Item_field(Lex->current_context(),
5957
6405
                                       (YYTHD->client_capabilities &
5958
 
                                       CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6406
                                       CLIENT_NO_SCHEMA ? NullS : $1.str),
5959
6407
                                       $3.str, $5.str) :
5960
6408
                (Item*) new Item_ref(Lex->current_context(),
5961
6409
                                     (YYTHD->client_capabilities &
5962
 
                                     CLIENT_NO_SCHEMA ? NULL : $1.str),
 
6410
                                     CLIENT_NO_SCHEMA ? NullS : $1.str),
5963
6411
                                     $3.str, $5.str);
5964
6412
          }
5965
6413
        ;
5968
6416
          ident { $$=$1;}
5969
6417
        | ident '.' ident '.' ident
5970
6418
          {
5971
 
            TableList *table= (TableList*) Select->table_list.first;
 
6419
            TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
5972
6420
            if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5973
6421
            {
5974
6422
              my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5975
 
              DRIZZLE_YYABORT;
 
6423
              MYSQL_YYABORT;
5976
6424
            }
5977
6425
            if (my_strcasecmp(table_alias_charset, $3.str,
5978
6426
                              table->table_name))
5979
6427
            {
5980
6428
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
5981
 
              DRIZZLE_YYABORT;
 
6429
              MYSQL_YYABORT;
5982
6430
            }
5983
6431
            $$=$5;
5984
6432
          }
5985
6433
        | ident '.' ident
5986
6434
          {
5987
 
            TableList *table= (TableList*) Select->table_list.first;
 
6435
            TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first;
5988
6436
            if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5989
6437
            {
5990
6438
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
5991
 
              DRIZZLE_YYABORT;
 
6439
              MYSQL_YYABORT;
5992
6440
            }
5993
6441
            $$=$3;
5994
6442
          }
6009
6457
 
6010
6458
            if (thd->charset_is_system_charset)
6011
6459
            {
6012
 
              const CHARSET_INFO * const cs= system_charset_info;
 
6460
              CHARSET_INFO *cs= system_charset_info;
6013
6461
              int dummy_error;
6014
 
              uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
 
6462
              uint wlen= cs->cset->well_formed_len(cs, $1.str,
6015
6463
                                                   $1.str+$1.length,
6016
6464
                                                   $1.length, &dummy_error);
6017
6465
              if (wlen < $1.length)
6018
6466
              {
6019
6467
                my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
6020
6468
                         cs->csname, $1.str + wlen);
6021
 
                DRIZZLE_YYABORT;
 
6469
                MYSQL_YYABORT;
6022
6470
              }
6023
6471
              $$= $1;
6024
6472
            }
6113
6561
        | SAVEPOINT_SYM         {}
6114
6562
        | SECURITY_SYM          {}
6115
6563
        | SERVER_SYM            {}
 
6564
        | SIGNED_SYM            {}
6116
6565
        | SOCKET_SYM            {}
6117
6566
        | SLAVE                 {}
6118
6567
        | SONAME_SYM            {}
6119
6568
        | START_SYM             {}
6120
6569
        | STOP_SYM              {}
6121
6570
        | TRUNCATE_SYM          {}
 
6571
        | UNICODE_SYM           {}
 
6572
        | UNINSTALL_SYM         {}
 
6573
        | WRAPPER_SYM           {}
6122
6574
        | UPGRADE_SYM           {}
6123
6575
        ;
6124
6576
 
6143
6595
        | AVG_SYM                  {}
6144
6596
        | BINLOG_SYM               {}
6145
6597
        | BIT_SYM                  {}
6146
 
        | BLOCK_SIZE_SYM           {}
6147
6598
        | BLOCK_SYM                {}
6148
6599
        | BOOL_SYM                 {}
6149
6600
        | BOOLEAN_SYM              {}
6151
6602
        | CASCADED                 {}
6152
6603
        | CHAIN_SYM                {}
6153
6604
        | CHANGED                  {}
 
6605
        | CIPHER_SYM               {}
 
6606
        | CLIENT_SYM               {}
6154
6607
        | COALESCE                 {}
 
6608
        | CODE_SYM                 {}
6155
6609
        | COLLATION_SYM            {}
6156
6610
        | COLUMN_FORMAT_SYM        {}
6157
6611
        | COLUMNS                  {}
6163
6617
        | CONNECTION_SYM           {}
6164
6618
        | CONSISTENT_SYM           {}
6165
6619
        | CONTEXT_SYM              {}
 
6620
        | CONTRIBUTORS_SYM         {}
 
6621
        | CPU_SYM                  {}
6166
6622
        | CUBE_SYM                 {}
6167
6623
        | DATA_SYM                 {}
6168
6624
        | DATAFILE_SYM             {}
6169
6625
        | DATETIME                 {}
6170
6626
        | DATE_SYM                 {}
6171
6627
        | DAY_SYM                  {}
 
6628
        | DEFINER_SYM              {}
6172
6629
        | DELAY_KEY_WRITE_SYM      {}
 
6630
        | DES_KEY_FILE             {}
6173
6631
        | DIRECTORY_SYM            {}
6174
6632
        | DISABLE_SYM              {}
6175
6633
        | DISCARD                  {}
 
6634
        | DISK_SYM                 {}
6176
6635
        | DUMPFILE                 {}
6177
6636
        | DUPLICATE_SYM            {}
6178
6637
        | DYNAMIC_SYM              {}
6179
6638
        | ENDS_SYM                 {}
6180
6639
        | ENUM                     {}
6181
6640
        | ENGINE_SYM               {}
 
6641
        | ENGINES_SYM              {}
6182
6642
        | ERRORS                   {}
6183
6643
        | ESCAPE_SYM               {}
 
6644
        | EVENTS_SYM               {}
 
6645
        | EVERY_SYM                {}
6184
6646
        | EXCLUSIVE_SYM            {}
6185
6647
        | EXTENDED_SYM             {}
6186
6648
        | EXTENT_SIZE_SYM          {}
6202
6664
        | IMPORT                   {}
6203
6665
        | INDEXES                  {}
6204
6666
        | INITIAL_SIZE_SYM         {}
 
6667
        | IO_SYM                   {}
 
6668
        | IPC_SYM                  {}
6205
6669
        | ISOLATION                {}
 
6670
        | ISSUER_SYM               {}
6206
6671
        | INSERT_METHOD            {}
6207
6672
        | KEY_BLOCK_SIZE           {}
6208
6673
        | LAST_SYM                 {}
6231
6696
        | MAX_USER_CONNECTIONS_SYM {}
6232
6697
        | MAX_VALUE_SYM            {}
6233
6698
        | MEDIUM_SYM               {}
 
6699
        | MEMORY_SYM               {}
6234
6700
        | MERGE_SYM                {}
6235
6701
        | MICROSECOND_SYM          {}
6236
6702
        | MIGRATE_SYM              {}
6242
6708
        | NAME_SYM                 {}
6243
6709
        | NAMES_SYM                {}
6244
6710
        | NATIONAL_SYM             {}
 
6711
        | NCHAR_SYM                {}
6245
6712
        | NEXT_SYM                 {}
6246
6713
        | NEW_SYM                  {}
6247
6714
        | NO_WAIT_SYM              {}
6248
6715
        | NODEGROUP_SYM            {}
6249
6716
        | NONE_SYM                 {}
6250
6717
        | NOWAIT_SYM               {}
 
6718
        | NVARCHAR_SYM             {}
6251
6719
        | OFFLINE_SYM              {}
6252
6720
        | OFFSET_SYM               {}
 
6721
        | OLD_PASSWORD             {}
6253
6722
        | ONE_SHOT_SYM             {}
6254
6723
        | ONE_SYM                  {}
6255
6724
        | ONLINE_SYM               {}
6257
6726
        | PAGE_SYM                 {}
6258
6727
        | PAGE_CHECKSUM_SYM        {}
6259
6728
        | PARTIAL                  {}
 
6729
        | PASSWORD                 {}
6260
6730
        | PHASE_SYM                {}
6261
6731
        | PLUGIN_SYM               {}
6262
6732
        | PLUGINS_SYM              {}
6264
6734
        | PREV_SYM                 {}
6265
6735
        | PROCESS                  {}
6266
6736
        | PROCESSLIST_SYM          {}
 
6737
        | PROFILE_SYM              {}
 
6738
        | PROFILES_SYM             {}
6267
6739
        | QUARTER_SYM              {}
6268
6740
        | QUERY_SYM                {}
6269
6741
        | QUICK                    {}
6339
6811
        | WEEK_SYM                 {}
6340
6812
        | WEIGHT_STRING_SYM        {}
6341
6813
        | WORK_SYM                 {}
 
6814
        | XML_SYM                  {}
6342
6815
        | YEAR_SYM                 {}
6343
6816
        ;
6344
6817
 
6428
6901
            lex->var_list.push_back(new set_var(lex->option_type,
6429
6902
                                                find_sys_var(YYTHD, "tx_isolation"),
6430
6903
                                                &null_lex_str,
6431
 
                                                new Item_int((int32_t) $5)));
 
6904
                                                new Item_int((int32) $5)));
6432
6905
          }
6433
6906
        ;
6434
6907
 
6442
6915
            LEX *lex=Lex;
6443
6916
            lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
6444
6917
          }
6445
 
        | NAMES_SYM COLLATE_SYM collation_name_or_default
 
6918
        | charset old_or_new_charset_name_or_default
 
6919
          {
 
6920
            THD *thd= YYTHD;
 
6921
            LEX *lex= thd->lex;
 
6922
            $2= $2 ? $2: global_system_variables.character_set_client;
 
6923
            lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
 
6924
          }
 
6925
        | NAMES_SYM charset_name_or_default opt_collate
6446
6926
          {
6447
6927
            LEX *lex= Lex;
6448
 
            $3= $3 ? $3 : global_system_variables.character_set_client;
 
6928
            $2= $2 ? $2 : global_system_variables.character_set_client;
 
6929
            $3= $3 ? $3 : $2;
 
6930
            if (!my_charset_same($2,$3))
 
6931
            {
 
6932
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
 
6933
                       $3->name, $2->csname);
 
6934
              MYSQL_YYABORT;
 
6935
            }
6449
6936
            lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
6450
6937
          }
6451
6938
        ;
6460
6947
              /* Not an SP local variable */
6461
6948
              sys_var *tmp=find_sys_var(thd, $1.str, $1.length);
6462
6949
              if (!tmp)
6463
 
                DRIZZLE_YYABORT;
 
6950
                MYSQL_YYABORT;
6464
6951
              $$.var= tmp;
6465
6952
              $$.base_name= null_lex_str;
6466
6953
            }
6470
6957
            if (check_reserved_words(&$1))
6471
6958
            {
6472
6959
              my_parse_error(ER(ER_SYNTAX_ERROR));
6473
 
              DRIZZLE_YYABORT;
 
6960
              MYSQL_YYABORT;
6474
6961
            }
6475
6962
            {
6476
6963
              sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6477
6964
              if (!tmp)
6478
 
                DRIZZLE_YYABORT;
 
6965
                MYSQL_YYABORT;
6479
6966
              if (!tmp->is_struct())
6480
6967
                my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6481
6968
              $$.var= tmp;
6486
6973
          {
6487
6974
            sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6488
6975
            if (!tmp)
6489
 
              DRIZZLE_YYABORT;
 
6976
              MYSQL_YYABORT;
6490
6977
            if (!tmp->is_struct())
6491
6978
              my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6492
6979
            $$.var= tmp;
6523
7010
              requested for the table. This is used to warn about a
6524
7011
              changed locking method later.
6525
7012
            */
6526
 
            Lex->lock_transactional= true;
 
7013
            Lex->lock_transactional= TRUE;
6527
7014
          }
6528
7015
          table_or_tables
6529
7016
          {
6547
7034
table_lock:
6548
7035
        table_ident opt_table_alias table_lock_info
6549
7036
        {
6550
 
          TableList *tlist;
 
7037
          TABLE_LIST *tlist;
6551
7038
          if (!(tlist= Select->add_table_to_list(YYTHD, $1, $2, 0,
6552
7039
                                                 $3.lock_type)))
6553
 
            DRIZZLE_YYABORT; /* purecov: inspected */
 
7040
            MYSQL_YYABORT; /* purecov: inspected */
6554
7041
          tlist->lock_timeout= $3.lock_timeout;
6555
7042
          /* Store the requested lock method for later warning. */
6556
7043
          tlist->lock_transactional= $3.lock_transactional;
6557
7044
          /* Compute the resulting lock method for all tables. */
6558
7045
          if (!$3.lock_transactional)
6559
 
            Lex->lock_transactional= false;
 
7046
            Lex->lock_transactional= FALSE;
6560
7047
        }
6561
7048
        ;
6562
7049
 
6565
7052
        {
6566
7053
          $$.lock_type=          TL_READ_NO_INSERT;
6567
7054
          $$.lock_timeout=       -1;
6568
 
          $$.lock_transactional= false;
 
7055
          $$.lock_transactional= FALSE;
6569
7056
        }
6570
7057
        | WRITE_SYM
6571
7058
        {
6572
7059
          $$.lock_type=          TL_WRITE_DEFAULT;
6573
7060
          $$.lock_timeout=       -1;
6574
 
          $$.lock_transactional= false;
 
7061
          $$.lock_transactional= FALSE;
6575
7062
        }
6576
7063
        | LOW_PRIORITY WRITE_SYM
6577
7064
        {
6578
7065
          $$.lock_type=          TL_WRITE_LOW_PRIORITY;
6579
7066
          $$.lock_timeout=       -1;
6580
 
          $$.lock_transactional= false;
 
7067
          $$.lock_transactional= FALSE;
6581
7068
        }
6582
7069
        | READ_SYM LOCAL_SYM
6583
7070
        {
6584
7071
          $$.lock_type=          TL_READ;
6585
7072
          $$.lock_timeout=       -1;
6586
 
          $$.lock_transactional= false;
 
7073
          $$.lock_transactional= FALSE;
6587
7074
        }
6588
7075
        | IN_SYM transactional_lock_mode MODE_SYM opt_transactional_lock_timeout
6589
7076
        {
6590
7077
          $$.lock_type=          $2;
6591
7078
          $$.lock_timeout=       $4;
6592
 
          $$.lock_transactional= true;
 
7079
          $$.lock_transactional= TRUE;
6593
7080
        }
6594
7081
        ;
6595
7082
 
6716
7203
          UNION_SYM union_option
6717
7204
          {
6718
7205
            if (add_select_to_union_list(Lex, (bool)$2))
6719
 
              DRIZZLE_YYABORT;
 
7206
              MYSQL_YYABORT;
6720
7207
          }
6721
7208
          select_init
6722
7209
          {
6738
7225
          {
6739
7226
            THD *thd= YYTHD;
6740
7227
            LEX *lex= thd->lex;
6741
 
            assert(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
 
7228
            DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
6742
7229
            SELECT_LEX *sel= lex->current_select;
6743
7230
            SELECT_LEX_UNIT *unit= sel->master_unit();
6744
7231
            SELECT_LEX *fake= unit->fake_select_lex;
6786
7273
          UNION_SYM union_option 
6787
7274
          {
6788
7275
            if (add_select_to_union_list(Lex, (bool)$3))
6789
 
              DRIZZLE_YYABORT;
 
7276
              MYSQL_YYABORT;
6790
7277
          }
6791
7278
          query_specification
6792
7279
          {
6810
7297
               lex->sql_command == (int)SQLCOM_PURGE)
6811
7298
            {
6812
7299
              my_parse_error(ER(ER_SYNTAX_ERROR));
6813
 
              DRIZZLE_YYABORT;
 
7300
              MYSQL_YYABORT;
6814
7301
            }
6815
7302
            /* 
6816
7303
              we are making a "derived table" for the parenthesis
6820
7307
              SELECT * FROM ((SELECT ...) UNION ...)
6821
7308
            */
6822
7309
            if (mysql_new_select(Lex, 1))
6823
 
              DRIZZLE_YYABORT;
 
7310
              MYSQL_YYABORT;
6824
7311
          }
6825
7312
        ;
6826
7313