~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2003 MySQL AB
 
1
/* 
 
2
   Copyright (C) 2010-2011 Brian Aker
 
3
   Copyright (C) 2000-2003 MySQL AB
2
4
 
3
5
   This program is free software; you can redistribute it and/or modify
4
6
   it under the terms of the GNU General Public License as published by
40
42
#include <drizzled/parser.h>
41
43
#include <drizzled/session.h>
42
44
#include <drizzled/alter_column.h>
43
 
#include <drizzled/alter_drop.h>
44
45
#include <drizzled/alter_info.h>
 
46
#include <drizzled/message/alter_table.pb.h>
45
47
#include <drizzled/item/subselect.h>
 
48
#include <drizzled/table_ident.h>
 
49
#include <drizzled/var.h>
 
50
#include <drizzled/system_variables.h>
 
51
#include <drizzled/lex_input_stream.h>
 
52
#include <drizzled/show.h>
46
53
 
47
54
int yylex(union ParserType *yylval, drizzled::Session *session);
48
55
 
51
58
    unsigned long val= *(F);                          \
52
59
    if (drizzled::my_yyoverflow((B), (D), &val)) \
53
60
    {                                         \
54
 
      yyerror(NULL, (char*) (A));                   \
 
61
      yyerror(NULL, (A));                   \
55
62
      return 2;                               \
56
63
    }                                         \
57
64
    else                                      \
108
115
  to abort from the parser.
109
116
*/
110
117
 
111
 
static void base_sql_error(drizzled::Session *session, const char *s)
 
118
static void base_sql_error(drizzled::Session *session, const char* s)
112
119
{
113
120
  parser::errorOn(session, s);
114
121
}
123
130
  unsigned long ulong_num;
124
131
  uint64_t ulonglong_number;
125
132
  int64_t longlong_number;
126
 
  drizzled::LEX_STRING lex_str;
127
 
  drizzled::LEX_STRING *lex_str_ptr;
 
133
  drizzled::lex_string_t lex_str;
 
134
  drizzled::lex_string_t *lex_str_ptr;
128
135
  drizzled::LEX_SYMBOL symbol;
129
136
  drizzled::Table_ident *table;
130
 
  char *simple_string;
 
137
  const char* simple_string;
131
138
  drizzled::Item *item;
132
139
  drizzled::Item_num *item_num;
133
140
  drizzled::List<drizzled::Item> *item_list;
144
151
  drizzled::ha_rkey_function ha_rkey_mode;
145
152
  drizzled::enum_tx_isolation tx_isolation;
146
153
  drizzled::Cast_target cast_type;
147
 
  const drizzled::CHARSET_INFO *charset;
 
154
  const drizzled::charset_info_st *charset;
148
155
  drizzled::thr_lock_type lock_type;
149
156
  drizzled::interval_type interval, interval_time_st;
150
157
  drizzled::type::timestamp_t date_time_type;
151
158
  drizzled::Select_Lex *select_lex;
152
159
  drizzled::chooser_compare_func_creator boolfunc2creator;
153
 
  drizzled::st_lex *lex;
 
160
  drizzled::LEX *lex;
154
161
  drizzled::index_hint_type index_hint;
155
162
  drizzled::enum_filetype filetype;
156
 
  drizzled::ha_build_method build_method;
157
163
  drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
158
164
  drizzled::execute_string_t execute_string;
159
165
}
166
172
%}
167
173
 
168
174
%debug
169
 
%require "2.2"
 
175
%require "2.4"
170
176
%pure-parser
171
177
%name-prefix="base_sql_"
172
178
%parse-param { drizzled::Session *session }
178
184
  Currently there are 70 shift/reduce conflicts.
179
185
  We should not introduce new conflicts any more.
180
186
*/
181
 
%expect 79
 
187
%expect 80
182
188
 
183
189
/*
184
190
   Comments for TOKENS.
199
205
 
200
206
%token  ABORT_SYM                     /* INTERNAL (used in lex) */
201
207
%token  ACTION                        /* SQL-2003-N */
 
208
%token  ADDDATE_SYM                   /* MYSQL-FUNC */
202
209
%token  ADD_SYM                           /* SQL-2003-R */
203
 
%token  ADDDATE_SYM                   /* MYSQL-FUNC */
204
210
%token  AFTER_SYM                     /* SQL-2003-N */
205
211
%token  AGGREGATE_SYM
206
212
%token  ALL                           /* SQL-2003-R */
235
241
%token  CATALOG_SYM
236
242
%token  CHAIN_SYM                     /* SQL-2003-N */
237
243
%token  CHANGE_SYM
 
244
%token  CHARSET
238
245
%token  CHAR_SYM                      /* SQL-2003-R */
239
246
%token  CHECKSUM_SYM
240
247
%token  CHECK_SYM                     /* SQL-2003-R */
261
268
%token  CROSS                         /* SQL-2003-R */
262
269
%token  CUBE_SYM                      /* SQL-2003-R */
263
270
%token  CURDATE                       /* MYSQL-FUNC */
 
271
%token  CURTIME                       /* MYSQL-FUNC */
264
272
%token  CURRENT_USER                  /* SQL-2003-R */
265
273
%token  CURSOR_SYM                    /* SQL-2003-R */
266
274
%token  DATABASE
280
288
%token  DECIMAL_SYM                   /* SQL-2003-R */
281
289
%token  DECLARE_SYM                   /* SQL-2003-R */
282
290
%token  DEFAULT                       /* SQL-2003-R */
 
291
%token  DEFINER
283
292
%token  DELETE_SYM                    /* SQL-2003-R */
284
293
%token  DESC                          /* SQL-2003-N */
285
294
%token  DESCRIBE                      /* SQL-2003-R */
288
297
%token  DISCARD
289
298
%token  DISTINCT                      /* SQL-2003-R */
290
299
%token  DIV_SYM
 
300
%token  DOUBLE_SYM                    /* SQL-2003-R */
291
301
%token  DO_SYM
292
 
%token  DOUBLE_SYM                    /* SQL-2003-R */
293
302
%token  DROP                          /* SQL-2003-R */
294
303
%token  DUMPFILE
295
304
%token  DUPLICATE_SYM
327
336
%token  FULL                          /* SQL-2003-R */
328
337
%token  GE
329
338
%token  GLOBAL_SYM                    /* SQL-2003-R */
 
339
%token  GROUP_CONCAT_SYM
330
340
%token  GROUP_SYM                     /* SQL-2003-R */
331
 
%token  GROUP_CONCAT_SYM
332
341
%token  HASH_SYM
333
342
%token  HAVING                        /* SQL-2003-R */
334
343
%token  HEX_NUM
353
362
%token  INTERVAL_SYM                  /* SQL-2003-R */
354
363
%token  INTO                          /* SQL-2003-R */
355
364
%token  INT_SYM                       /* SQL-2003-R */
 
365
%token  INVOKER
356
366
%token  IN_SYM                        /* SQL-2003-R */
357
367
%token  IS                            /* SQL-2003-R */
358
368
%token  ISOLATION                     /* SQL-2003-R */
359
369
%token  ITERATE_SYM
 
370
%token  IPV6_SYM
360
371
%token  JOIN_SYM                      /* SQL-2003-R */
361
372
%token  KEYS
362
373
%token  KEY_BLOCK_SIZE
437
448
%token  READ_WRITE_SYM
438
449
%token  REAL                          /* SQL-2003-R */
439
450
%token  REDUNDANT_SYM
 
451
%token  REFERENCES                    /* SQL-2003-R */
440
452
%token  REGEXP_SYM
441
 
%token  REFERENCES                    /* SQL-2003-R */
442
453
%token  RELEASE_SYM                   /* SQL-2003-R */
443
454
%token  RENAME
444
455
%token  REPEATABLE_SYM                /* SQL-2003-N */
466
477
%token  SEPARATOR_SYM
467
478
%token  SERIALIZABLE_SYM              /* SQL-2003-N */
468
479
%token  SERIAL_SYM
 
480
%token  SERVER_SYM
469
481
%token  SESSION_SYM                   /* SQL-2003-N */
470
 
%token  SERVER_SYM
471
 
%token  SET_SYM                           /* SQL-2003-R */
 
482
%token  SET_SYM                       /* SQL-2003-R */
472
483
%token  SET_VAR
473
484
%token  SHARE_SYM
474
485
%token  SHOW
508
519
%token  TEXT_STRING
509
520
%token  TEXT_SYM
510
521
%token  THEN_SYM                      /* SQL-2003-R */
511
 
%token  TIME_SYM                 /* SQL-2003-R */
512
 
%token  TIMESTAMP_SYM                 /* SQL-2003-R */
513
522
%token  TIMESTAMP_ADD
514
523
%token  TIMESTAMP_DIFF
 
524
%token  TIMESTAMP_SYM                 /* SQL-2003-R */
 
525
%token  TIME_SYM                 /* SQL-2003-R */
515
526
%token  TO_SYM                        /* SQL-2003-R */
516
527
%token  TRAILING                      /* SQL-2003-R */
517
528
%token  TRANSACTION_SYM
534
545
%token  USE_SYM
535
546
%token  USING                         /* SQL-2003-R */
536
547
%token  UTC_DATE_SYM
 
548
%token  UTC_TIME_SYM
537
549
%token  UTC_TIMESTAMP_SYM
 
550
%token  UTF8_SYM
538
551
%token  UUID_SYM
539
552
%token  VALUES                        /* SQL-2003-R */
540
553
%token  VALUE_SYM                     /* SQL-2003-R */
574
587
%nonassoc IN_SYM
575
588
%nonassoc IS NULL_SYM TRUE_SYM FALSE_SYM
576
589
 
577
 
%nonassoc CONCAT
 
590
%left CONCAT
578
591
%nonassoc '|'
579
592
%nonassoc '&'
580
593
%nonassoc SHIFT_LEFT SHIFT_RIGHT
731
744
 
732
745
%type <boolfunc2creator> comp_op
733
746
 
734
 
%type <build_method> build_method
735
 
 
736
747
%type <NONE>
737
748
        query verb_clause create select drop insert replace insert2
738
749
        insert_values update delete truncate rename
868
879
          }
869
880
        | CREATE build_method
870
881
          {
871
 
            Lex.statement= new statement::CreateIndex(YYSession, $2);
 
882
            Lex.statement= new statement::CreateIndex(YYSession);
872
883
          }
873
884
          opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
874
885
          {
976
987
 
977
988
opt_create_database_options:
978
989
          /* empty */ {}
979
 
        | default_collation_schema {}
980
 
        | opt_database_custom_options {}
 
990
        | default_collation_schema
 
991
        | default_collation_schema opt_database_custom_options
 
992
        | default_collation_schema ',' opt_database_custom_options
 
993
        | opt_database_custom_options
981
994
        ;
982
995
 
983
996
opt_database_custom_options:
984
997
        custom_database_option
 
998
        | custom_database_option opt_database_custom_options
985
999
        | custom_database_option ',' opt_database_custom_options
986
1000
        ;
987
1001
 
989
1003
          ident_or_text
990
1004
          {
991
1005
            statement::CreateSchema *statement= (statement::CreateSchema *)Lex.statement;
992
 
            statement->schema_message.mutable_engine()->add_options()->set_name($1.str);
 
1006
            statement->schema_message.mutable_engine()->add_options()->set_name($1.data());
993
1007
          }
994
 
        | REPLICATE opt_equal TRUE_SYM
 
1008
        | REPLICATE '=' TRUE_SYM
995
1009
          {
996
1010
            parser::buildReplicationOption(&Lex, true);
997
1011
          }
998
 
        | REPLICATE opt_equal FALSE_SYM
 
1012
        | REPLICATE '=' FALSE_SYM
999
1013
          {
1000
1014
            parser::buildReplicationOption(&Lex, false);
1001
1015
          }
1002
 
        | ident_or_text equal ident_or_text
1003
 
          {
1004
 
            parser::buildSchemaOption(&Lex, $1.str, $3);
1005
 
          }
1006
 
        | ident_or_text equal ulonglong_num
1007
 
          {
1008
 
            parser::buildSchemaOption(&Lex, $1.str, $3);
 
1016
        | DEFINER TEXT_STRING_sys
 
1017
          {
 
1018
            parser::buildSchemaDefiner(&Lex, identifier::User($2));
 
1019
          }
 
1020
        | DEFINER CURRENT_USER optional_braces
 
1021
          {
 
1022
            parser::buildSchemaDefiner(&Lex, *session->user());
 
1023
          }
 
1024
        | ident_or_text '=' ident_or_text
 
1025
          {
 
1026
            parser::buildSchemaOption(&Lex, $1.data(), $3);
 
1027
          }
 
1028
        | ident_or_text '=' ulonglong_num
 
1029
          {
 
1030
            parser::buildSchemaOption(&Lex, $1.data(), $3);
1009
1031
          }
1010
1032
        ;
1011
1033
 
1038
1060
          custom_engine_option;
1039
1061
 
1040
1062
custom_engine_option:
1041
 
        ENGINE_SYM equal ident_or_text
 
1063
        ENGINE_SYM '=' ident_or_text
1042
1064
          {
1043
 
            Lex.table()->mutable_engine()->set_name($3.str);
 
1065
            Lex.table()->mutable_engine()->set_name($3.data());
1044
1066
          }
1045
1067
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1046
1068
          {
1047
 
            Lex.table()->mutable_options()->set_comment($3.str);
 
1069
            Lex.table()->mutable_options()->set_comment($3.data());
1048
1070
          }
1049
1071
        | AUTO_INC opt_equal ulonglong_num
1050
1072
          {
1051
1073
            Lex.table()->mutable_options()->set_auto_increment_value($3);
1052
1074
          }
1053
 
        | REPLICATE opt_equal TRUE_SYM
 
1075
        | REPLICATE '=' TRUE_SYM
1054
1076
          {
1055
1077
            message::set_is_replicated(*Lex.table(), true);
1056
1078
          }
1057
 
        | REPLICATE opt_equal FALSE_SYM
 
1079
        | REPLICATE '=' FALSE_SYM
1058
1080
          {
1059
1081
            message::set_is_replicated(*Lex.table(), false);
1060
1082
          }
1061
 
        |  ROW_FORMAT_SYM equal row_format_or_text
 
1083
        | DEFINER TEXT_STRING_sys
 
1084
          {
 
1085
            message::set_definer(*Lex.table(), identifier::User($2));
 
1086
          }
 
1087
        | DEFINER CURRENT_USER optional_braces
 
1088
          {
 
1089
            message::set_definer(*Lex.table(), *session->user());
 
1090
          }
 
1091
        |  ROW_FORMAT_SYM '=' row_format_or_text
1062
1092
          {
1063
1093
            parser::buildEngineOption(&Lex, "ROW_FORMAT", $3);
1064
1094
          }
1065
 
        |  FILE_SYM equal TEXT_STRING_sys
 
1095
        |  FILE_SYM '=' TEXT_STRING_sys
1066
1096
          {
1067
1097
            parser::buildEngineOption(&Lex, "FILE", $3);
1068
1098
          }
1069
 
        |  ident_or_text equal engine_option_value
1070
 
          {
1071
 
            parser::buildEngineOption(&Lex, $1.str, $3);
1072
 
          }
1073
 
        | ident_or_text equal ulonglong_num
1074
 
          {
1075
 
            parser::buildEngineOption(&Lex, $1.str, $3);
1076
 
          }
 
1099
        |  ident_or_text '=' engine_option_value
 
1100
          {
 
1101
            parser::buildEngineOption(&Lex, $1.data(), $3);
 
1102
          }
 
1103
        | ident_or_text '=' ulonglong_num
 
1104
          {
 
1105
            parser::buildEngineOption(&Lex, $1.data(), $3);
 
1106
          }
 
1107
        | default_charset
1077
1108
        | default_collation
1078
1109
        ;
1079
1110
 
 
1111
charset:
 
1112
          CHAR_SYM SET_SYM {}
 
1113
        | CHARSET {}
 
1114
        ;
 
1115
 
 
1116
charset_name_or_default:
 
1117
          UTF8_SYM { } 
 
1118
        | DEFAULT    { }
 
1119
        ;
 
1120
 
 
1121
default_charset:
 
1122
          opt_default charset opt_equal charset_name_or_default
 
1123
        {
 
1124
        }
 
1125
 
1080
1126
default_collation:
1081
1127
          opt_default COLLATE_SYM opt_equal collation_name_or_default
1082
1128
          {
1106
1152
row_format_or_text:
1107
1153
          row_format
1108
1154
          {
1109
 
            $$.str= YYSession->strmake($1.str, $1.length);
1110
 
            $$.length= $1.length;
 
1155
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
1111
1156
          }
1112
1157
        ;
1113
1158
 
1142
1187
        | opt_constraint constraint_key_type opt_ident key_alg
1143
1188
          '(' key_list ')' key_options
1144
1189
          {
1145
 
            parser::buildKey(&Lex, $2, $3.str ? $3 : $1);
 
1190
            parser::buildKey(&Lex, $2, $3.data() ? $3 : $1);
1146
1191
          }
1147
1192
        | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1148
1193
          {
1149
 
            parser::buildForeignKey(&Lex, $1.str ? $1 : $4, $8);
 
1194
            parser::buildForeignKey(&Lex, $1.data() ? $1 : $4, $8);
1150
1195
          }
1151
1196
        | constraint opt_check_constraint
1152
1197
          {
1168
1213
        ;
1169
1214
 
1170
1215
opt_constraint:
1171
 
          /* empty */ { $$= null_lex_str; }
 
1216
          /* empty */ { $$= null_lex_string(); }
1172
1217
        | constraint { $$= $1; }
1173
1218
        ;
1174
1219
 
1183
1228
          }
1184
1229
          field_def opt_attribute_comment
1185
1230
          {
1186
 
            statement::CreateTable *statement= (statement::CreateTable *)Lex.statement;
 
1231
            statement::CreateTable *statement= (statement::CreateTable*)Lex.statement;
1187
1232
 
1188
1233
            if (Lex.field())
1189
1234
            {
1190
 
              Lex.field()->set_name($1.str);
 
1235
              Lex.field()->set_name($1.data());
1191
1236
            }
1192
1237
 
1193
 
            if (add_field_to_list(Lex.session, &$1, (enum enum_field_types) $3,
 
1238
            if (add_field_to_list(Lex.session, $1, (enum_field_types) $3,
1194
1239
                                  Lex.length, Lex.dec, Lex.type,
1195
1240
                                  statement->column_format,
1196
1241
                                  statement->default_value, statement->on_update_value,
1197
 
                                  &statement->comment,
 
1242
                                  statement->comment,
1198
1243
                                  statement->change, &Lex.interval_list, Lex.charset))
1199
1244
              DRIZZLE_YYABORT;
1200
1245
 
1209
1254
          }
1210
1255
        | TIMESTAMP_SYM '(' NUM ')' opt_attribute_timestamp
1211
1256
          {
1212
 
            $$=parser::buildTimestampColumn(&Lex, $3.str);
 
1257
            $$=parser::buildTimestampColumn(&Lex, $3.data());
1213
1258
          }
1214
1259
        | DATETIME_SYM opt_attribute_timestamp
1215
1260
          {
1228
1273
          }
1229
1274
        | varchar '(' NUM ')' opt_attribute_string
1230
1275
          {
1231
 
            $$= parser::buildVarcharColumn(&Lex, $3.str);
 
1276
            $$= parser::buildVarcharColumn(&Lex, $3.data());
1232
1277
          }
1233
1278
        | TEXT_SYM opt_attribute_string
1234
1279
          {
1235
1280
            $$=DRIZZLE_TYPE_BLOB;
1236
 
            Lex.length=(char*) 0; /* use default length */
 
1281
            Lex.length= NULL; /* use default length */
1237
1282
 
1238
1283
            if (Lex.field())
1239
1284
              Lex.field()->set_type(message::Table::Field::BLOB);
1251
1296
          }
1252
1297
        | VARBINARY '(' NUM ')' opt_attribute
1253
1298
          {
1254
 
            $$= parser::buildVarbinaryColumn(&Lex, $3.str);
 
1299
            $$= parser::buildVarbinaryColumn(&Lex, $3.data());
1255
1300
          }
1256
1301
        | real_type opt_attribute_number
1257
1302
          {
1292
1337
          {
1293
1338
            $$= parser::buildUuidColumn(&Lex);
1294
1339
          }
 
1340
        | IPV6_SYM opt_attribute
 
1341
          {
 
1342
            $$= parser::buildIPv6Column(&Lex);
 
1343
          }
1295
1344
        | BOOLEAN_SYM opt_attribute_boolean
1296
1345
          {
1297
1346
            $$= parser::buildBooleanColumn(&Lex);
1339
1388
 
1340
1389
float_options:
1341
1390
          /* empty */
1342
 
          { Lex.dec=Lex.length= (char*)0; }
 
1391
          { Lex.dec=Lex.length= NULL; }
1343
1392
        | '(' NUM ')'
1344
 
          { Lex.length=$2.str; Lex.dec= (char*)0; }
 
1393
          { Lex.length=$2.data(); Lex.dec= NULL; }
1345
1394
        | precision
1346
1395
          {}
1347
1396
        ;
1349
1398
precision:
1350
1399
          '(' NUM ',' NUM ')'
1351
1400
          {
1352
 
            Lex.length= $2.str;
1353
 
            Lex.dec= $4.str;
 
1401
            Lex.length= $2.data();
 
1402
            Lex.dec= $4.data();
1354
1403
          }
1355
1404
        ;
1356
1405
 
1357
1406
opt_len:
1358
 
          /* empty */ { Lex.length=(char*) 0; /* use default length */ }
1359
 
        | '(' NUM ')' { Lex.length= $2.str; }
 
1407
          /* empty */ { Lex.length= NULL; /* use default length */ }
 
1408
        | '(' NUM ')' { Lex.length= $2.data(); }
1360
1409
        ;
1361
1410
 
1362
1411
opt_field_number_signed:
1377
1426
 
1378
1427
opt_precision:
1379
1428
          /* empty */
1380
 
          { Lex.dec=Lex.length= (char*)0; }
 
1429
          { Lex.dec=Lex.length= NULL; }
1381
1430
        | '(' NUM ')'
1382
 
          { Lex.length=Lex.dec= (char*)0; }
 
1431
          { Lex.length=Lex.dec= NULL; }
1383
1432
        | precision
1384
1433
          {}
1385
1434
        ;
1421
1470
          { }
1422
1471
        | opt_attribute DEFAULT signed_literal
1423
1472
          {
1424
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1473
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1425
1474
 
1426
1475
            statement->default_value= $3;
1427
1476
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1436
1485
          { }
1437
1486
        | opt_attribute_boolean DEFAULT boolean_literal
1438
1487
          {
1439
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1488
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1440
1489
 
1441
1490
            statement->default_value= $3;
1442
1491
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1460
1509
          { }
1461
1510
        | DEFAULT signed_literal
1462
1511
          {
1463
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1512
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1464
1513
 
1465
1514
            statement->default_value=$2;
1466
1515
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1505
1554
          }
1506
1555
        | DEFAULT integer_literal
1507
1556
          {
1508
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1557
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1509
1558
 
1510
1559
            statement->default_value=$2;
1511
1560
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1529
1578
          { }
1530
1579
        | DEFAULT NOW_SYM optional_braces
1531
1580
          {
1532
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1581
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1533
1582
 
1534
1583
            statement->default_value= new Item_func_now_local();
1535
1584
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1536
1585
          }
1537
1586
        | DEFAULT date_literal
1538
1587
          {
1539
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1588
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1540
1589
 
1541
1590
            statement->default_value=$2;
1542
1591
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1543
1592
          }
1544
1593
        | ON UPDATE_SYM NOW_SYM optional_braces
1545
1594
          {
1546
 
            ((statement::AlterTable *)Lex.statement)->on_update_value= new Item_func_now_local();
 
1595
            ((statement::AlterTable*)Lex.statement)->on_update_value= new Item_func_now_local();
1547
1596
          }
1548
1597
        | opt_attribute_index
1549
1598
          { }
1553
1602
          /* empty */ { }
1554
1603
        | COMMENT_SYM TEXT_STRING_sys
1555
1604
          {
1556
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1605
            statement::AlterTable *statement= (statement::AlterTable*)Lex.statement;
1557
1606
            statement->comment= $2;
1558
1607
 
1559
1608
            if (Lex.field())
1560
 
              Lex.field()->set_comment($2.str);
 
1609
              Lex.field()->set_comment($2.data());
1561
1610
          }
1562
1611
        ;
1563
1612
 
1564
1613
collation_name:
1565
1614
          ident_or_text
1566
1615
          {
1567
 
            if (!($$=get_charset_by_name($1.str)))
 
1616
            if (!($$=get_charset_by_name($1.data())))
1568
1617
            {
1569
 
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str);
 
1618
              my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.data());
1570
1619
              DRIZZLE_YYABORT;
1571
1620
            }
1572
1621
          }
1612
1661
 
1613
1662
opt_match_clause:
1614
1663
          /* empty */
1615
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
 
1664
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1616
1665
        | MATCH FULL
1617
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
 
1666
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1618
1667
        | MATCH PARTIAL
1619
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
 
1668
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1620
1669
        | MATCH SIMPLE_SYM
1621
 
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
 
1670
          { ((statement::CreateTable*)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1622
1671
        ;
1623
1672
 
1624
1673
opt_on_update_delete:
1625
1674
          /* empty */
1626
1675
          {
1627
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1628
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1676
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1677
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1629
1678
          }
1630
1679
        | ON UPDATE_SYM delete_option
1631
1680
          {
1632
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= $3;
1633
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1681
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= $3;
 
1682
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1634
1683
          }
1635
1684
        | ON DELETE_SYM delete_option
1636
1685
          {
1637
 
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1638
 
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= $3;
 
1686
            ((statement::CreateTable*)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1687
            ((statement::CreateTable*)Lex.statement)->fk_delete_opt= $3;
1639
1688
          }
1640
1689
        | ON UPDATE_SYM delete_option
1641
1690
          ON DELETE_SYM delete_option
1742
1791
          ident { $$=new Key_part_spec($1, 0); }
1743
1792
        | ident '(' NUM ')'
1744
1793
          {
1745
 
            int key_part_len= atoi($3.str);
 
1794
            int key_part_len= atoi($3.data());
1746
1795
            if (!key_part_len)
1747
1796
            {
1748
 
              my_error(ER_KEY_PART_0, MYF(0), $1.str);
 
1797
              my_error(ER_KEY_PART_0, MYF(0), $1.data());
1749
1798
            }
1750
1799
            $$=new Key_part_spec($1, (uint) key_part_len);
1751
1800
          }
1752
1801
        ;
1753
1802
 
1754
1803
opt_ident:
1755
 
          /* empty */ { $$= null_lex_str; }
 
1804
          /* empty */ { $$= null_lex_string(); }
1756
1805
        | field_ident { $$= $1; }
1757
1806
        ;
1758
1807
 
1759
1808
opt_component:
1760
 
          /* empty */    { $$= null_lex_str; }
 
1809
          /* empty */    { $$= null_lex_string(); }
1761
1810
        | '.' ident      { $$= $2; }
1762
1811
        ;
1763
1812
 
1772
1821
alter:
1773
1822
          ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
1774
1823
          {
1775
 
            statement::AlterTable *statement= new statement::AlterTable(YYSession, $5, $2);
 
1824
            statement::AlterTable *statement= new statement::AlterTable(YYSession, $5);
1776
1825
            Lex.statement= statement;
1777
1826
            Lex.duplicates= DUP_ERROR;
1778
1827
            if (not Lex.select_lex.add_table_to_list(YYSession, $5, NULL, TL_OPTION_UPDATING))
1782
1831
 
1783
1832
            Lex.col_list.clear();
1784
1833
            Lex.select_lex.init_order();
1785
 
            Lex.select_lex.db= const_cast<char *>(((TableList*) Lex.select_lex.table_list.first)->getSchemaName());
 
1834
            Lex.select_lex.db= ((TableList*) Lex.select_lex.table_list.first)->getSchemaName();
1786
1835
          }
1787
1836
          alter_commands
1788
1837
          {}
1793
1842
          default_collation_schema
1794
1843
          {
1795
1844
            Lex.name= $3;
1796
 
            if (Lex.name.str == NULL && Lex.copy_db_to(&Lex.name.str, &Lex.name.length))
1797
 
              DRIZZLE_YYABORT;
 
1845
            if (not Lex.name.data())
 
1846
            {
 
1847
              str_ref db = Lex.session->copy_db_to();
 
1848
              if (db.empty())
 
1849
                DRIZZLE_YYABORT;
 
1850
              Lex.name.assign(db.data(), db.size());
 
1851
            }
1798
1852
          }
1799
1853
        ;
1800
1854
 
1802
1856
          /* empty */
1803
1857
        | DISCARD TABLESPACE
1804
1858
          {
1805
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1806
 
            statement->alter_info.tablespace_op= DISCARD_TABLESPACE;
 
1859
            message::AlterTable::AlterTableOperation *alter_operation;
 
1860
            alter_operation= Lex.alter_table()->add_operations();
 
1861
            alter_operation->set_operation(message::AlterTable::AlterTableOperation::DISCARD_TABLESPACE);
1807
1862
          }
1808
1863
        | IMPORT TABLESPACE
1809
1864
          {
1810
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1811
 
            statement->alter_info.tablespace_op= IMPORT_TABLESPACE;
 
1865
            message::AlterTable::AlterTableOperation *alter_operation;
 
1866
            alter_operation= Lex.alter_table()->add_operations();
 
1867
            alter_operation->set_operation(message::AlterTable::AlterTableOperation::IMPORT_TABLESPACE);
1812
1868
          }
1813
1869
        | alter_list
1814
1870
        ;
1816
1872
build_method:
1817
1873
        /* empty */
1818
1874
          {
1819
 
            $$= HA_BUILD_DEFAULT;
 
1875
            Lex.alter_table()->set_build_method(message::AlterTable::BUILD_DEFAULT);
1820
1876
          }
1821
1877
        | ONLINE_SYM
1822
1878
          {
1823
 
            $$= HA_BUILD_ONLINE;
 
1879
            Lex.alter_table()->set_build_method(message::AlterTable::BUILD_ONLINE);
1824
1880
          }
1825
1881
        | OFFLINE_SYM
1826
1882
          {
1827
 
            $$= HA_BUILD_OFFLINE;
 
1883
            Lex.alter_table()->set_build_method(message::AlterTable::BUILD_OFFLINE);
1828
1884
          }
1829
1885
        ;
1830
1886
 
1861
1917
        | CHANGE_SYM opt_column field_ident
1862
1918
          {
1863
1919
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1864
 
            statement->change= $3.str;
 
1920
            statement->change= $3.data();
1865
1921
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1866
1922
          }
1867
1923
          field_spec opt_place
1871
1927
            Lex.length= Lex.dec=0;
1872
1928
            Lex.type= 0;
1873
1929
            statement->default_value= statement->on_update_value= 0;
1874
 
            statement->comment= null_lex_str;
 
1930
            statement->comment= null_lex_string();
1875
1931
            Lex.charset= NULL;
1876
1932
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1877
1933
            statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1882
1938
          {
1883
1939
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1884
1940
 
1885
 
            if (add_field_to_list(Lex.session,&$3,
 
1941
            if (add_field_to_list(Lex.session, $3,
1886
1942
                                  (enum enum_field_types) $5,
1887
1943
                                  Lex.length, Lex.dec, Lex.type,
1888
1944
                                  statement->column_format,
1889
1945
                                  statement->default_value,
1890
1946
                                  statement->on_update_value,
1891
 
                                  &statement->comment,
1892
 
                                  $3.str, &Lex.interval_list, Lex.charset))
 
1947
                                  statement->comment,
 
1948
                                  $3.data(), &Lex.interval_list, Lex.charset))
1893
1949
              DRIZZLE_YYABORT;
1894
1950
          }
1895
1951
          opt_place
1897
1953
          {
1898
1954
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1899
1955
 
1900
 
            statement->alter_info.drop_list.push_back(AlterDrop(AlterDrop::COLUMN, $3.str));
1901
1956
            statement->alter_info.flags.set(ALTER_DROP_COLUMN);
 
1957
            message::AlterTable::AlterTableOperation *operation;
 
1958
            operation= Lex.alter_table()->add_operations();
 
1959
            operation->set_operation(message::AlterTable::AlterTableOperation::DROP_COLUMN);
 
1960
            operation->set_drop_name($3.data());
1902
1961
          }
1903
1962
        | DROP FOREIGN KEY_SYM opt_ident
1904
1963
          {
1905
 
            parser::buildAddAlterDropIndex(&Lex, $4.str, true);
 
1964
            parser::buildAddAlterDropIndex(&Lex, $4.data(), true);
1906
1965
          }
1907
1966
        | DROP PRIMARY_SYM KEY_SYM
1908
1967
          {
1910
1969
          }
1911
1970
        | DROP key_or_index field_ident
1912
1971
          {
1913
 
            parser::buildAddAlterDropIndex(&Lex, $3.str);
 
1972
            parser::buildAddAlterDropIndex(&Lex, $3.data());
1914
1973
          }
1915
1974
        | DISABLE_SYM KEYS
1916
1975
          {
1917
1976
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1918
1977
 
1919
 
            statement->alter_info.keys_onoff= DISABLE;
1920
1978
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
 
1979
 
 
1980
            message::AlterTable::AlterKeysOnOff *alter_keys_operation;
 
1981
            alter_keys_operation= Lex.alter_table()->mutable_alter_keys_onoff();
 
1982
            alter_keys_operation->set_enable(false);
1921
1983
          }
1922
1984
        | ENABLE_SYM KEYS
1923
1985
          {
1924
1986
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1925
1987
 
1926
 
            statement->alter_info.keys_onoff= ENABLE;
1927
1988
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
 
1989
            message::AlterTable::AlterKeysOnOff *alter_keys_operation;
 
1990
            alter_keys_operation= Lex.alter_table()->mutable_alter_keys_onoff();
 
1991
            alter_keys_operation->set_enable(true);
1928
1992
          }
1929
1993
        | ALTER_SYM opt_column field_ident SET_SYM DEFAULT signed_literal
1930
1994
          {
1931
1995
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1932
1996
 
1933
 
            statement->alter_info.alter_list.push_back(AlterColumn($3.str,$6));
 
1997
            statement->alter_info.alter_list.push_back(AlterColumn($3.data(),$6));
1934
1998
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1935
1999
          }
1936
2000
        | ALTER_SYM opt_column field_ident DROP DEFAULT
1937
2001
          {
1938
2002
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1939
2003
 
1940
 
            statement->alter_info.alter_list.push_back(AlterColumn($3.str, (Item*) 0));
 
2004
            statement->alter_info.alter_list.push_back(AlterColumn($3.data(), NULL));
1941
2005
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1942
2006
          }
1943
2007
        | RENAME opt_to table_ident
1944
2008
          {
1945
2009
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1946
 
            size_t dummy;
1947
 
 
1948
 
            Lex.select_lex.db=$3->db.str;
1949
 
            if (Lex.select_lex.db == NULL &&
1950
 
                Lex.copy_db_to(&Lex.select_lex.db, &dummy))
 
2010
            Lex.select_lex.db= $3->db.data();
 
2011
            if (not Lex.select_lex.db)
1951
2012
            {
1952
 
              DRIZZLE_YYABORT;
 
2013
              str_ref db = Lex.session->copy_db_to();
 
2014
              if (db.empty())
 
2015
                DRIZZLE_YYABORT;
 
2016
              Lex.select_lex.db = db.data();
1953
2017
            }
1954
2018
 
1955
 
            if (check_table_name($3->table.str,$3->table.length))
 
2019
            if (check_table_name($3->table))
1956
2020
            {
1957
 
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
 
2021
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.data());
1958
2022
              DRIZZLE_YYABORT;
1959
2023
            }
1960
2024
 
1961
2025
            Lex.name= $3->table;
1962
2026
            statement->alter_info.flags.set(ALTER_RENAME);
 
2027
 
 
2028
            message::AlterTable::RenameTable *rename_operation;
 
2029
            rename_operation= Lex.alter_table()->mutable_rename();
 
2030
            rename_operation->set_to_schema(Lex.select_lex.db);
 
2031
            rename_operation->set_to_name(Lex.name.data());
1963
2032
          }
1964
2033
        | CONVERT_SYM TO_SYM collation_name_or_default
1965
2034
          {
2005
2074
          /* empty */ {}
2006
2075
        | AFTER_SYM ident
2007
2076
          {
2008
 
            parser::storeAlterColumnPosition(&Lex, $2.str);
 
2077
            parser::storeAlterColumnPosition(&Lex, $2.data());
2009
2078
          }
2010
2079
        | FIRST_SYM
2011
2080
          {
2262
2331
        | select_item
2263
2332
        | '*'
2264
2333
          {
2265
 
            if (YYSession->add_item_to_list( new Item_field(&YYSession->lex().current_select->context, NULL, NULL, "*")))
2266
 
              DRIZZLE_YYABORT;
2267
 
 
2268
 
            (YYSession->lex().current_select->with_wild)++;
 
2334
            YYSession->add_item_to_list( new Item_field(&YYSession->lex().current_select->context, NULL, NULL, "*"));
 
2335
            YYSession->lex().current_select->with_wild++;
2269
2336
          }
2270
2337
        ;
2271
2338
 
2272
2339
select_item:
2273
2340
          remember_name table_wild remember_end
2274
2341
          {
2275
 
            if (YYSession->add_item_to_list($2))
2276
 
              DRIZZLE_YYABORT;
 
2342
            YYSession->add_item_to_list($2);
2277
2343
          }
2278
2344
        | remember_name expr remember_end select_alias
2279
2345
          {
2280
2346
            assert($1 < $3);
2281
2347
 
2282
 
            if (YYSession->add_item_to_list($2))
2283
 
              DRIZZLE_YYABORT;
 
2348
            YYSession->add_item_to_list($2);
2284
2349
 
2285
 
            if ($4.str)
 
2350
            if ($4.data())
2286
2351
            {
2287
2352
              $2->is_autogenerated_name= false;
2288
 
              $2->set_name($4.str, $4.length, system_charset_info);
 
2353
              $2->set_name($4.data(), $4.size(), system_charset_info);
2289
2354
            }
2290
2355
            else if (!$2->name)
2291
2356
            {
2297
2362
remember_name:
2298
2363
          {
2299
2364
            Lex_input_stream *lip= YYSession->m_lip;
2300
 
            $$= (char*) lip->get_cpp_tok_start();
 
2365
            $$= lip->get_cpp_tok_start();
2301
2366
          }
2302
2367
        ;
2303
2368
 
2304
2369
remember_end:
2305
2370
          {
2306
2371
            Lex_input_stream *lip= YYSession->m_lip;
2307
 
            $$= (char*) lip->get_cpp_tok_end();
 
2372
            $$= lip->get_cpp_tok_end();
2308
2373
          }
2309
2374
        ;
2310
2375
 
2311
2376
select_alias:
2312
 
          /* empty */ { $$=null_lex_str;}
 
2377
          /* empty */ { $$= null_lex_string();}
2313
2378
        | AS ident { $$=$2; }
2314
2379
        | AS TEXT_STRING_sys { $$=$2; }
2315
2380
        | ident { $$=$1; }
2627
2692
        | function_call_conflict
2628
2693
        | simple_expr COLLATE_SYM ident_or_text %prec UMINUS
2629
2694
          {
2630
 
            Item *i1= new (YYSession->mem_root) Item_string($3.str,
2631
 
                                                      $3.length,
2632
 
                                                      YYSession->charset());
 
2695
            Item *i1= new (YYSession->mem_root) Item_string($3, YYSession->charset());
2633
2696
            $$= new (YYSession->mem_root) Item_func_set_collation($1, i1);
2634
2697
          }
2635
2698
        | literal
2806
2869
          }
2807
2870
        | ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
2808
2871
          { $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 0); }
 
2872
        | CURTIME optional_braces
 
2873
          {
 
2874
            $$= new (YYSession->mem_root) Item_func_curtime_local();
 
2875
            Lex.setCacheable(false);
 
2876
          }
2809
2877
        | CURDATE optional_braces
2810
2878
          {
2811
2879
            $$= new (YYSession->mem_root) Item_func_curdate_local();
2892
2960
          { $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2893
2961
        | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
2894
2962
          { $$= new (YYSession->mem_root) Item_func_timestamp_diff($5,$7,$3); }
 
2963
        | UTC_TIME_SYM optional_braces
 
2964
          {
 
2965
            $$= new (YYSession->mem_root) Item_func_curtime_utc();
 
2966
            Lex.setCacheable(false);
 
2967
          }
2895
2968
        | UTC_DATE_SYM optional_braces
2896
2969
          {
2897
2970
            $$= new (YYSession->mem_root) Item_func_curdate_utc();
2946
3019
            }
2947
3020
          }
2948
3021
        | IF '(' expr ',' expr ',' expr ')'
2949
 
          { $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
 
3022
          { 
 
3023
            $$= new (YYSession->mem_root) Item_func_if($3,$5,$7);
 
3024
          }
2950
3025
        | KILL_SYM kill_option '(' expr ')'
2951
3026
          {
2952
3027
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2991
3066
            }
2992
3067
            Lex.setCacheable(false);
2993
3068
          }
 
3069
        | IPV6_SYM '(' ')'
 
3070
          {
 
3071
            if (! ($$= parser::reserved_keyword_function(YYSession, "ipv6", NULL)))
 
3072
            {
 
3073
              DRIZZLE_YYABORT;
 
3074
            }
 
3075
            Lex.setCacheable(false);
 
3076
          }
2994
3077
        | WAIT_SYM '(' expr ',' expr ')'
2995
3078
          {
2996
3079
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3014
3097
function_call_generic:
3015
3098
          IDENT_sys '('
3016
3099
          {
3017
 
            const plugin::Function *udf= plugin::Function::get(std::string($1.str, $1.length));
 
3100
            const plugin::Function *udf= plugin::Function::get(to_string($1));
3018
3101
 
3019
3102
            /* Temporary placing the result of getFunction in $3 */
3020
3103
            $<udf>$= udf;
3021
3104
          }
3022
3105
          opt_udf_expr_list ')'
3023
3106
          {
3024
 
            Create_func *builder;
3025
3107
            Item *item= NULL;
3026
3108
 
3027
3109
            /*
3033
3115
 
3034
3116
              This will be revised with WL#2128 (SQL PATH)
3035
3117
            */
3036
 
            builder= find_native_function_builder($1);
3037
 
            if (builder)
 
3118
            if (Create_func* builder= find_native_function_builder($1))
3038
3119
            {
3039
3120
              item= builder->create(YYSession, $1, $4);
3040
3121
            }
3041
 
            else
 
3122
            else if (const plugin::Function* udf= $<udf>3) /* Retrieving the result of service::Function::get */
3042
3123
            {
3043
 
              /* Retrieving the result of service::Function::get */
3044
 
              const plugin::Function *udf= $<udf>3;
3045
 
              if (udf)
3046
 
              {
3047
 
                item= Create_udf_func::s_singleton.create(YYSession, udf, $4);
3048
 
              } else {
3049
 
                /* fix for bug 250065, from Andrew Garner <muzazzi@gmail.com> */
3050
 
                my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", $1.str);
3051
 
              }
 
3124
                  item= Create_udf_func::s_singleton.create(YYSession, udf, $4);
 
3125
            } 
 
3126
                        else 
 
3127
                        {
 
3128
              /* fix for bug 250065, from Andrew Garner <muzazzi@gmail.com> */
 
3129
              my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", $1.data());
3052
3130
            }
3053
3131
 
3054
 
            if (! ($$= item))
 
3132
            if (not ($$= item))
3055
3133
            {
3056
3134
              DRIZZLE_YYABORT;
3057
3135
            }
3086
3164
             because the syntax will not allow having an explicit name here.
3087
3165
             See WL#1017 re. udf attributes.
3088
3166
            */
3089
 
            if ($4.str)
 
3167
            if ($4.data())
3090
3168
            {
3091
3169
              $2->is_autogenerated_name= false;
3092
 
              $2->set_name($4.str, $4.length, system_charset_info);
 
3170
              $2->set_name($4.data(), $4.size(), system_charset_info);
3093
3171
            }
3094
3172
            else
3095
3173
              $2->set_name($1, (uint) ($3 - $1), YYSession->charset());
3103
3181
        | AVG_SYM '(' DISTINCT in_sum_expr ')'
3104
3182
          { $$=new Item_sum_avg_distinct($4); }
3105
3183
        | COUNT_SYM '(' opt_all '*' ')'
3106
 
          { $$=new Item_sum_count(new Item_int((int32_t) 0L,1)); }
 
3184
          { $$=new Item_sum_count(new Item_int(0, 1)); }
3107
3185
        | COUNT_SYM '(' in_sum_expr ')'
3108
3186
          { $$=new Item_sum_count($3); }
3109
3187
        | COUNT_SYM '(' DISTINCT
3174
3252
        | '@' opt_var_ident_type user_variable_ident opt_component
3175
3253
          {
3176
3254
            /* disallow "SELECT @@global.global.variable" */
3177
 
            if ($3.str && $4.str && parser::check_reserved_words(&$3))
 
3255
            if ($3.data() && $4.data() && parser::check_reserved_words($3))
3178
3256
            {
3179
3257
              parser::my_parse_error(YYSession->m_lip);
3180
3258
              DRIZZLE_YYABORT;
3205
3283
        | order_clause
3206
3284
          {
3207
3285
            Select_Lex *select= Lex.current_select;
3208
 
            select->gorder_list=
3209
 
              (SQL_LIST*) memory::sql_memdup((char*) &select->order_list,
3210
 
                                     sizeof(st_sql_list));
 
3286
            select->gorder_list= (SQL_LIST*) memory::sql_memdup(&select->order_list, sizeof(SQL_LIST));
3211
3287
            select->order_list.clear();
3212
3288
          }
3213
3289
        ;
3234
3310
        | BOOLEAN_SYM
3235
3311
          { $$=ITEM_CAST_BOOLEAN; Lex.charset= &my_charset_bin; Lex.dec= 0; }
3236
3312
        | SIGNED_SYM
3237
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3313
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3238
3314
        | SIGNED_SYM INT_SYM
3239
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3315
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3240
3316
        | INT_SYM
3241
 
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3317
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3242
3318
        | UNSIGNED_SYM
3243
 
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3319
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3244
3320
        | UNSIGNED_SYM INT_SYM
3245
 
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3321
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3246
3322
        | CHAR_SYM opt_len
3247
3323
          { $$=ITEM_CAST_CHAR; Lex.dec= 0; }
3248
3324
        | DATE_SYM
3249
 
          { $$=ITEM_CAST_DATE; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3325
          { $$=ITEM_CAST_DATE; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3250
3326
        | TIME_SYM
3251
 
          { $$=ITEM_CAST_TIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3327
          { $$=ITEM_CAST_TIME; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3252
3328
        | DATETIME_SYM
3253
 
          { $$=ITEM_CAST_DATETIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
 
3329
          { $$=ITEM_CAST_DATETIME; Lex.charset= NULL; Lex.dec=Lex.length= NULL; }
3254
3330
        | DECIMAL_SYM float_options
3255
3331
          { $$=ITEM_CAST_DECIMAL; Lex.charset= NULL; }
3256
3332
        ;
3359
3435
            DRIZZLE_YYABORT_UNLESS($1 && $3);
3360
3436
            DRIZZLE_YYABORT_UNLESS( not Lex.is_cross );
3361
3437
            /* Change the current name resolution context to a local context. */
3362
 
            if (push_new_name_resolution_context(YYSession, $1, $3))
3363
 
              DRIZZLE_YYABORT;
 
3438
            push_new_name_resolution_context(*YYSession, *$1, *$3);
3364
3439
            Lex.current_select->parsing_place= IN_ON;
3365
3440
          }
3366
3441
          expr
3374
3449
          {
3375
3450
            DRIZZLE_YYABORT_UNLESS($1 && $3);
3376
3451
            /* Change the current name resolution context to a local context. */
3377
 
            if (push_new_name_resolution_context(YYSession, $1, $3))
3378
 
              DRIZZLE_YYABORT;
 
3452
            push_new_name_resolution_context(*YYSession, *$1, *$3);
3379
3453
            Lex.current_select->parsing_place= IN_ON;
3380
3454
          }
3381
3455
          expr
3404
3478
          {
3405
3479
            DRIZZLE_YYABORT_UNLESS($1 && $5);
3406
3480
            /* Change the current name resolution context to a local context. */
3407
 
            if (push_new_name_resolution_context(YYSession, $1, $5))
3408
 
              DRIZZLE_YYABORT;
 
3481
            push_new_name_resolution_context(*YYSession, *$1, *$5);
3409
3482
            Lex.current_select->parsing_place= IN_ON;
3410
3483
          }
3411
3484
          expr
3440
3513
          {
3441
3514
            DRIZZLE_YYABORT_UNLESS($1 && $5);
3442
3515
            /* Change the current name resolution context to a local context. */
3443
 
            if (push_new_name_resolution_context(YYSession, $1, $5))
3444
 
              DRIZZLE_YYABORT;
 
3516
            push_new_name_resolution_context(*YYSession, *$1, *$5);
3445
3517
            Lex.current_select->parsing_place= IN_ON;
3446
3518
          }
3447
3519
          expr
3516
3588
                sel->master_unit()->global_parameters=
3517
3589
                   sel->master_unit()->fake_select_lex;
3518
3590
            }
3519
 
            if ($2->init_nested_join(Lex.session))
3520
 
              DRIZZLE_YYABORT;
 
3591
            $2->init_nested_join(*Lex.session);
3521
3592
            $$= 0;
3522
3593
            /* incomplete derived tables return NULL, we must be
3523
3594
               nested in select_derived rule to be here. */
3638
3709
select_derived:
3639
3710
          get_select_lex
3640
3711
          {
3641
 
            if ($1->init_nested_join(Lex.session))
3642
 
              DRIZZLE_YYABORT;
 
3712
            $1->init_nested_join(*Lex.session);
3643
3713
          }
3644
3714
          derived_table_list
3645
3715
          {
3646
3716
            /* for normal joins, $3 != NULL and end_nested_join() != NULL,
3647
3717
               for derived tables, both must equal NULL */
3648
3718
 
3649
 
            if (!($$= $1->end_nested_join(Lex.session)) && $3)
 
3719
            if (!($$= $1->end_nested_join()) && $3)
3650
3720
              DRIZZLE_YYABORT;
3651
3721
 
3652
3722
            if (!$3 && $$)
3687
3757
          {
3688
3758
            Select_Lex *sel= Lex.current_select;
3689
3759
            TableList *embedding;
3690
 
            if (!sel->embedding || sel->end_nested_join(Lex.session))
 
3760
            if (!sel->embedding || sel->end_nested_join())
3691
3761
            {
3692
3762
              /* we are not in parentheses */
3693
3763
              parser::my_parse_error(YYSession->m_lip);
3749
3819
        ;
3750
3820
 
3751
3821
opt_key_usage_list:
3752
 
          /* empty */ { Lex.current_select->add_index_hint(YYSession, NULL, 0); }
 
3822
          /* empty */ { Lex.current_select->add_index_hint(YYSession, NULL); }
3753
3823
        | key_usage_list {}
3754
3824
        ;
3755
3825
 
3756
3826
key_usage_element:
3757
3827
          ident
3758
 
          { Lex.current_select->add_index_hint(YYSession, $1.str, $1.length); }
 
3828
          { Lex.current_select->add_index_hint(YYSession, $1.data()); }
3759
3829
        | PRIMARY_SYM
3760
 
          { Lex.current_select->add_index_hint(YYSession, (char *)"PRIMARY", 7); }
 
3830
          { Lex.current_select->add_index_hint(YYSession, "PRIMARY"); }
3761
3831
        ;
3762
3832
 
3763
3833
key_usage_list:
3768
3838
using_list:
3769
3839
          ident
3770
3840
          {
3771
 
            if (!($$= new List<String>))
3772
 
              DRIZZLE_YYABORT;
3773
 
            $$->push_back(new (YYSession->mem_root)
3774
 
                              String((const char *) $1.str, $1.length,
3775
 
                                      system_charset_info));
 
3841
            $$= new List<String>;
 
3842
            $$->push_back(new (YYSession->mem_root) String($1.data(), $1.size(), system_charset_info));
3776
3843
          }
3777
3844
        | using_list ',' ident
3778
3845
          {
3779
 
            $1->push_back(new (YYSession->mem_root)
3780
 
                              String((const char *) $3.str, $3.length,
3781
 
                                      system_charset_info));
 
3846
            $1->push_back(new (YYSession->mem_root) String($3.data(), $3.size(), system_charset_info));
3782
3847
            $$= $1;
3783
3848
          }
3784
3849
        ;
3838
3903
          /* empty */ { $$=0; }
3839
3904
        | table_alias ident
3840
3905
          {
3841
 
            $$= (drizzled::LEX_STRING*) memory::sql_memdup(&$2,sizeof(drizzled::LEX_STRING));
 
3906
            $$= (drizzled::lex_string_t*) memory::sql_memdup(&$2,sizeof(drizzled::lex_string_t));
3842
3907
          }
3843
3908
        ;
3844
3909
 
3888
3953
        | /* empty */
3889
3954
          {
3890
3955
            Lex.escape_used= false;
3891
 
            $$= new Item_string("\\", 1, &my_charset_utf8_general_ci);
 
3956
            $$= new Item_string(str_ref("\\"), &my_charset_utf8_general_ci);
3892
3957
          }
3893
3958
        ;
3894
3959
 
3903
3968
 
3904
3969
group_list:
3905
3970
          group_list ',' order_ident order_dir
3906
 
          { if (YYSession->add_group_to_list($3,(bool) $4)) DRIZZLE_YYABORT; }
 
3971
          { YYSession->add_group_to_list($3,(bool) $4); }
3907
3972
        | order_ident order_dir
3908
 
          { if (YYSession->add_group_to_list($1,(bool) $2)) DRIZZLE_YYABORT; }
 
3973
          { YYSession->add_group_to_list($1,(bool) $2); }
3909
3974
        ;
3910
3975
 
3911
3976
olap_opt:
3945
4010
alter_order_item:
3946
4011
          simple_ident order_dir
3947
4012
          {
3948
 
            bool ascending= ($2 == 1) ? true : false;
3949
 
            if (YYSession->add_order_to_list($1, ascending))
3950
 
              DRIZZLE_YYABORT;
 
4013
            bool ascending= $2 == 1;
 
4014
            YYSession->add_order_to_list($1, ascending);
3951
4015
          }
3952
4016
        ;
3953
4017
 
3972
4036
order_list:
3973
4037
          order_list ',' order_ident order_dir
3974
4038
          {
3975
 
            if (YYSession->add_order_to_list($3,(bool) $4))
3976
 
              DRIZZLE_YYABORT;
 
4039
            YYSession->add_order_to_list($3,(bool) $4);
3977
4040
          }
3978
4041
        | order_ident order_dir
3979
4042
          {
3980
 
            if (YYSession->add_order_to_list($1,(bool) $2))
3981
 
              DRIZZLE_YYABORT;
 
4043
            YYSession->add_order_to_list($1,(bool) $2);
3982
4044
          }
3983
4045
        ;
3984
4046
 
4032
4094
        ;
4033
4095
 
4034
4096
limit_option:
4035
 
          ULONGLONG_NUM { $$= new Item_uint($1.str, $1.length); }
4036
 
        | LONG_NUM      { $$= new Item_uint($1.str, $1.length); }
4037
 
        | NUM           { $$= new Item_uint($1.str, $1.length); }
 
4097
          ULONGLONG_NUM { $$= new Item_uint($1.data(), $1.size()); }
 
4098
        | LONG_NUM      { $$= new Item_uint($1.data(), $1.size()); }
 
4099
        | NUM           { $$= new Item_uint($1.data(), $1.size()); }
4038
4100
        ;
4039
4101
 
4040
4102
delete_limit_clause:
4051
4113
        ;
4052
4114
 
4053
4115
ulong_num:
4054
 
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4055
 
        | HEX_NUM       { $$= (unsigned long) strtol($1.str, (char**) 0, 16); }
4056
 
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4057
 
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4058
 
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4059
 
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
 
4116
          NUM           { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4117
        | HEX_NUM       { $$= (unsigned long) strtol($1.data(), NULL, 16); }
 
4118
        | LONG_NUM      { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4119
        | ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4120
        | DECIMAL_NUM   { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
 
4121
        | FLOAT_NUM     { int error; $$= (unsigned long) internal::my_strtoll10($1.data(), NULL, &error); }
4060
4122
        ;
4061
4123
 
4062
4124
ulonglong_num:
4063
 
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4064
 
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4065
 
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4066
 
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4067
 
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
 
4125
          NUM           { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4126
        | ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4127
        | LONG_NUM      { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4128
        | DECIMAL_NUM   { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
 
4129
        | FLOAT_NUM     { int error; $$= (uint64_t) internal::my_strtoll10($1.data(), NULL, &error); }
4068
4130
        ;
4069
4131
 
4070
4132
select_var_list_init:
4071
4133
          {
4072
 
            if (not Lex.describe && (not (Lex.result= new select_dumpvar())))
4073
 
              DRIZZLE_YYABORT;
 
4134
            if (not Lex.describe)
 
4135
                          Lex.result= new select_dumpvar;
4074
4136
          }
4075
4137
          select_var_list
4076
4138
          {}
4109
4171
          OUTFILE TEXT_STRING_filesystem
4110
4172
          {
4111
4173
            Lex.setCacheable(false);
4112
 
            if (!(Lex.exchange= new file_exchange($2.str, 0)) ||
4113
 
                !(Lex.result= new select_export(Lex.exchange)))
4114
 
              DRIZZLE_YYABORT;
 
4174
            Lex.exchange= new file_exchange($2.data(), 0);
 
4175
            Lex.result= new select_export(Lex.exchange);
4115
4176
          }
4116
4177
          opt_field_term opt_line_term
4117
4178
        | DUMPFILE TEXT_STRING_filesystem
4119
4180
            if (not Lex.describe)
4120
4181
            {
4121
4182
              Lex.setCacheable(false);
4122
 
              if (not (Lex.exchange= new file_exchange($2.str,1)))
4123
 
                DRIZZLE_YYABORT;
4124
 
              if (not (Lex.result= new select_dump(Lex.exchange)))
4125
 
                DRIZZLE_YYABORT;
 
4183
              Lex.exchange= new file_exchange($2.data(),1);
 
4184
              Lex.result= new select_dump(Lex.exchange);
4126
4185
            }
4127
4186
          }
4128
4187
        | select_var_list_init
4150
4209
            statement::DropIndex *statement= new statement::DropIndex(YYSession);
4151
4210
            Lex.statement= statement;
4152
4211
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
4153
 
            statement->alter_info.build_method= $2;
4154
 
            statement->alter_info.drop_list.push_back(AlterDrop(AlterDrop::KEY, $4.str));
 
4212
 
4155
4213
            if (not Lex.current_select->add_table_to_list(Lex.session, $6, NULL,
4156
4214
                                                          TL_OPTION_UPDATING))
4157
4215
              DRIZZLE_YYABORT;
 
4216
 
 
4217
            message::AlterTable::AlterTableOperation *operation;
 
4218
            operation= Lex.alter_table()->add_operations();
 
4219
            operation->set_operation(message::AlterTable::AlterTableOperation::DROP_KEY);
 
4220
            operation->set_drop_name($4.data());
 
4221
 
4158
4222
          }
4159
4223
        | DROP DATABASE if_exists schema_name
4160
4224
          {
4281
4345
        | '(' fields ')' insert_values {}
4282
4346
        | SET_SYM
4283
4347
          {
4284
 
            if (not (Lex.insert_list = new List_item) ||
4285
 
                Lex.many_values.push_back(Lex.insert_list))
4286
 
              DRIZZLE_YYABORT;
 
4348
            Lex.insert_list = new List_item;
 
4349
            Lex.many_values.push_back(Lex.insert_list);
4287
4350
          }
4288
4351
          ident_eq_list
4289
4352
        ;
4321
4384
ident_eq_value:
4322
4385
          simple_ident equal expr_or_default
4323
4386
          {
4324
 
            if (Lex.field_list.push_back($1) ||
4325
 
                Lex.insert_list->push_back($3))
4326
 
              DRIZZLE_YYABORT;
 
4387
            Lex.field_list.push_back($1);
 
4388
            Lex.insert_list->push_back($3);
4327
4389
          }
4328
4390
        ;
4329
4391
 
4334
4396
 
4335
4397
opt_equal:
4336
4398
          /* empty */ {}
4337
 
        | equal {}
 
4399
        | '=' {}
4338
4400
        ;
4339
4401
 
4340
4402
no_braces:
4341
4403
          '('
4342
4404
          {
4343
 
              if (!(Lex.insert_list = new List_item))
4344
 
                DRIZZLE_YYABORT;
 
4405
              Lex.insert_list = new List_item;
4345
4406
          }
4346
4407
          opt_values ')'
4347
4408
          {
4348
 
            if (Lex.many_values.push_back(Lex.insert_list))
4349
 
              DRIZZLE_YYABORT;
 
4409
            Lex.many_values.push_back(Lex.insert_list);
4350
4410
          }
4351
4411
        ;
4352
4412
 
4358
4418
values:
4359
4419
          values ','  expr_or_default
4360
4420
          {
4361
 
            if (Lex.insert_list->push_back($3))
4362
 
              DRIZZLE_YYABORT;
 
4421
            Lex.insert_list->push_back($3);
4363
4422
          }
4364
4423
        | expr_or_default
4365
4424
          {
4366
 
            if (Lex.insert_list->push_back($1))
4367
 
              DRIZZLE_YYABORT;
 
4425
            Lex.insert_list->push_back($1);
4368
4426
          }
4369
4427
        ;
4370
4428
 
4416
4474
update_elem:
4417
4475
          simple_ident equal expr_or_default
4418
4476
          {
4419
 
            if (YYSession->add_item_to_list($1) || YYSession->add_value_to_list($3))
4420
 
              DRIZZLE_YYABORT;
 
4477
            YYSession->add_item_to_list($1);
 
4478
                        YYSession->add_value_to_list($3);
4421
4479
          }
4422
4480
        ;
4423
4481
 
4429
4487
insert_update_elem:
4430
4488
          simple_ident equal expr_or_default
4431
4489
          {
4432
 
          if (Lex.update_list.push_back($1) ||
4433
 
              Lex.value_list.push_back($3))
4434
 
              DRIZZLE_YYABORT;
 
4490
                        Lex.update_list.push_back($1);
 
4491
            Lex.value_list.push_back($3);
4435
4492
          }
4436
4493
        ;
4437
4494
 
4444
4501
            init_select(&Lex);
4445
4502
            Lex.lock_option= TL_WRITE_DEFAULT;
4446
4503
            Lex.select_lex.init_order();
4447
 
 
4448
 
            if (!Lex.current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING,
4449
 
                                           Lex.lock_option))
4450
 
              DRIZZLE_YYABORT;
 
4504
            Lex.current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING, Lex.lock_option);
4451
4505
          }
4452
4506
          where_clause opt_order_clause
4453
4507
          delete_limit_clause {}
4489
4543
show_param:
4490
4544
           DATABASES show_wild
4491
4545
           {
4492
 
             if (not show::buildScemas(YYSession))
4493
 
               DRIZZLE_YYABORT;
 
4546
             if (not show::buildSchemas(YYSession))
 
4547
                                DRIZZLE_YYABORT;
4494
4548
           }
4495
4549
           /* SHOW TABLES */
4496
4550
         | TABLES opt_db show_wild
4571
4625
 
4572
4626
opt_db:
4573
4627
          /* empty */  { $$= 0; }
4574
 
        | from_or_in ident { $$= $2.str; }
 
4628
        | from_or_in ident { $$= $2.data(); }
4575
4629
        ;
4576
4630
 
4577
4631
from_or_in:
4583
4637
          /* empty */
4584
4638
        | LIKE TEXT_STRING_sys
4585
4639
          {
4586
 
            Lex.wild= new (YYSession->mem_root) String($2.str, $2.length,
4587
 
                                                    system_charset_info);
4588
 
            if (Lex.wild == NULL)
4589
 
              DRIZZLE_YYABORT;
 
4640
            Lex.wild= new (YYSession->mem_root) String($2.data(), $2.size(), system_charset_info);
4590
4641
          }
4591
4642
        | WHERE expr
4592
4643
          {
4629
4680
        | text_string { Lex.wild= $1; }
4630
4681
        | ident
4631
4682
          {
4632
 
            Lex.wild= new (YYSession->mem_root) String((const char*) $1.str,
4633
 
                                                    $1.length,
4634
 
                                                    system_charset_info);
 
4683
            Lex.wild= new (YYSession->mem_root) String($1.data(), $1.size(), system_charset_info);
4635
4684
          }
4636
4685
        ;
4637
4686
 
4707
4756
          USE_SYM schema_name
4708
4757
          {
4709
4758
            Lex.statement= new statement::ChangeSchema(YYSession);
4710
 
            Lex.select_lex.db= $2.str;
 
4759
            Lex.select_lex.db= $2.data();
4711
4760
          }
4712
4761
        ;
4713
4762
 
4727
4776
            Lex.lock_option= $4;
4728
4777
            Lex.duplicates= DUP_ERROR;
4729
4778
            Lex.ignore= 0;
4730
 
            if (not (Lex.exchange= new file_exchange($6.str, 0, $2)))
4731
 
              DRIZZLE_YYABORT;
 
4779
            Lex.exchange= new file_exchange($6.data(), 0, $2);
4732
4780
          }
4733
4781
          opt_duplicate INTO
4734
4782
          {
4838
4886
        | IGNORE_SYM NUM lines_or_rows
4839
4887
          {
4840
4888
            assert(Lex.exchange != 0);
4841
 
            Lex.exchange->skip_lines= atol($2.str);
 
4889
            Lex.exchange->skip_lines= atol($2.data());
4842
4890
          }
4843
4891
        ;
4844
4892
 
4876
4924
text_literal:
4877
4925
        TEXT_STRING_literal
4878
4926
        {
4879
 
          $$ = new Item_string($1.str, $1.length, YYSession->variables.getCollation());
 
4927
          $$ = new Item_string($1.data(), $1.size(), YYSession->variables.getCollation());
4880
4928
        }
4881
4929
        | text_literal TEXT_STRING_literal
4882
4930
          {
4883
 
            ((Item_string*) $1)->append($2.str, $2.length);
 
4931
            ((Item_string*) $1)->append($2);
4884
4932
          }
4885
4933
        ;
4886
4934
 
4887
4935
text_string:
4888
4936
          TEXT_STRING_literal
4889
4937
          {
4890
 
            $$= new (YYSession->mem_root) String($1.str,
4891
 
                                             $1.length,
4892
 
                                             YYSession->variables.getCollation());
 
4938
            $$= new (YYSession->mem_root) String($1.data(), $1.size(), YYSession->variables.getCollation());
4893
4939
          }
4894
4940
        | HEX_NUM
4895
4941
          {
4896
 
            Item *tmp= new Item_hex_string($1.str, $1.length);
 
4942
            Item *tmp= new Item_hex_string($1);
4897
4943
            /*
4898
4944
              it is OK only emulate fix_fields, because we need only
4899
4945
              value of constant
4900
4946
            */
4901
 
            $$= tmp ?
4902
 
              tmp->quick_fix_field(), tmp->val_str((String*) 0) :
4903
 
              (String*) 0;
 
4947
            $$= tmp ? tmp->quick_fix_field(), tmp->val_str(NULL) : NULL;
4904
4948
          }
4905
4949
        | BIN_NUM
4906
4950
          {
4907
 
            Item *tmp= new Item_bin_string($1.str, $1.length);
 
4951
            Item *tmp= new Item_bin_string($1);
4908
4952
            /*
4909
4953
              it is OK only emulate fix_fields, because we need only
4910
4954
              value of constant
4911
4955
            */
4912
 
            $$= tmp ? tmp->quick_fix_field(), tmp->val_str((String*) 0) :
4913
 
              (String*) 0;
 
4956
            $$= tmp ? tmp->quick_fix_field(), tmp->val_str(NULL) : NULL;
4914
4957
          }
4915
4958
        ;
4916
4959
 
4934
4977
          }
4935
4978
        | FALSE_SYM { $$= new drizzled::item::False(); }
4936
4979
        | TRUE_SYM { $$= new drizzled::item::True(); }
4937
 
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
4938
 
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
 
4980
        | HEX_NUM { $$ = new Item_hex_string($1);}
 
4981
        | BIN_NUM { $$= new Item_bin_string($1); }
4939
4982
        | DATE_SYM text_literal { $$ = $2; }
4940
4983
        | TIMESTAMP_SYM text_literal { $$ = $2; }
4941
4984
        ;
4942
4985
 
4943
4986
integer_literal:
4944
4987
          text_literal { $$ = $1; }
4945
 
        | HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
4946
 
        | BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
 
4988
        | HEX_NUM { $$ = new Item_hex_string($1);}
 
4989
        | BIN_NUM { $$= new Item_bin_string($1); }
4947
4990
        | NUM_literal { $$ = $1; }
4948
4991
        | NULL_SYM
4949
4992
          {
4990
5033
          NUM
4991
5034
          {
4992
5035
            int error;
4993
 
            $$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
 
5036
            $$ = new Item_int($1.data(), internal::my_strtoll10($1.data(), NULL, &error), $1.size());
4994
5037
          }
4995
5038
        | LONG_NUM
4996
5039
          {
4997
5040
            int error;
4998
 
            $$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
 
5041
            $$ = new Item_int($1.data(), internal::my_strtoll10($1.data(), NULL, &error), $1.size());
4999
5042
          }
5000
5043
        | ULONGLONG_NUM
5001
 
          { $$ = new Item_uint($1.str, $1.length); }
 
5044
          { $$ = new Item_uint($1.data(), $1.size()); }
5002
5045
        | DECIMAL_NUM
5003
5046
          {
5004
 
            $$= new Item_decimal($1.str, $1.length, YYSession->charset());
 
5047
            $$= new Item_decimal($1.data(), $1.size(), YYSession->charset());
5005
5048
            if (YYSession->is_error())
5006
5049
            {
5007
5050
              DRIZZLE_YYABORT;
5009
5052
          }
5010
5053
        | FLOAT_NUM
5011
5054
          {
5012
 
            $$ = new Item_float($1.str, $1.length);
 
5055
            $$ = new Item_float($1.data(), $1.size());
5013
5056
            if (YYSession->is_error())
5014
5057
            {
5015
5058
              DRIZZLE_YYABORT;
5029
5072
table_wild:
5030
5073
          ident '.' '*'
5031
5074
          {
5032
 
            $$= parser::buildTableWild(&Lex, NULL_LEX_STRING, $1);
 
5075
            $$= parser::buildTableWild(&Lex, null_lex_string(), $1);
5033
5076
          }
5034
5077
        | ident '.' ident '.' '*'
5035
5078
          {
5044
5087
simple_ident:
5045
5088
          ident
5046
5089
          {
5047
 
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, NULL_LEX_STRING, $1);
 
5090
            $$= parser::buildIdent(&Lex, null_lex_string(), null_lex_string(), $1);
5048
5091
          }
5049
5092
        | simple_ident_q { $$= $1; }
5050
5093
        ;
5052
5095
simple_ident_q:
5053
5096
          ident '.' ident
5054
5097
          {
5055
 
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, $1, $3);
 
5098
            $$= parser::buildIdent(&Lex, null_lex_string(), $1, $3);
5056
5099
          }
5057
5100
        | '.' ident '.' ident
5058
5101
          {
5059
 
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, $2, $4);
 
5102
            $$= parser::buildIdent(&Lex, null_lex_string(), $2, $4);
5060
5103
          }
5061
5104
        | ident '.' ident '.' ident
5062
5105
          {
5078
5121
          }
5079
5122
        | ident '.' ident
5080
5123
          {
5081
 
            if (not parser::checkFieldIdent(&Lex, NULL_LEX_STRING, $1))
 
5124
            if (not parser::checkFieldIdent(&Lex, null_lex_string(), $1))
5082
5125
              DRIZZLE_YYABORT;
5083
5126
 
5084
5127
            $$=$3;
5119
5162
          }
5120
5163
        | IDENT_QUOTED
5121
5164
          {
5122
 
            const CHARSET_INFO * const cs= system_charset_info;
 
5165
            const charset_info_st * const cs= system_charset_info;
5123
5166
            int dummy_error;
5124
 
            uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
5125
 
                                                 $1.str+$1.length,
5126
 
                                                 $1.length, &dummy_error);
5127
 
            if (wlen < $1.length)
 
5167
            uint32_t wlen= cs->cset->well_formed_len(*cs, $1, $1.size(), &dummy_error);
 
5168
            if (wlen < $1.size())
5128
5169
            {
5129
 
              my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
5130
 
                       cs->csname, $1.str + wlen);
 
5170
              my_error(ER_INVALID_CHARACTER_STRING, MYF(0), cs->csname, $1.data() + wlen);
5131
5171
              DRIZZLE_YYABORT;
5132
5172
            }
5133
5173
            $$= $1;
5159
5199
          IDENT_sys    { $$=$1; }
5160
5200
        | keyword
5161
5201
          {
5162
 
            $$.str= YYSession->strmake($1.str, $1.length);
5163
 
            $$.length= $1.length;
 
5202
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
5164
5203
          }
5165
5204
        ;
5166
5205
 
5267
5306
        | IMPORT                   {}
5268
5307
        | INDEXES                  {}
5269
5308
        | ISOLATION                {}
 
5309
        | IPV6_SYM                 {}
5270
5310
        | KEY_BLOCK_SIZE           {}
5271
5311
        | LAST_SYM                 {}
5272
5312
        | LEVEL_SYM                {}
5407
5447
              {
5408
5448
                Lex.option_type= $1;
5409
5449
              }
5410
 
              Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type, $2.var, &$2.base_name, $4)));
 
5450
              Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type, $2.var, $2.base_name, $4)));
5411
5451
            }
5412
5452
          }
5413
5453
        | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
5414
5454
          {
5415
5455
            Lex.option_type= $1;
5416
 
            Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type,
5417
 
                                              find_sys_var("tx_isolation"),
5418
 
                                              &null_lex_str,
5419
 
                                              new Item_int((int32_t)
5420
 
                                              $5))));
 
5456
            Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type, find_sys_var("tx_isolation"), str_ref(), new Item_int((int32_t) $5))));
5421
5457
          }
5422
5458
        ;
5423
5459
 
5428
5464
          }
5429
5465
        | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
5430
5466
          {
5431
 
            Lex.var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
 
5467
            Lex.var_list.push_back(SetVarPtr(new set_var($3, $4.var, $4.base_name, $6)));
5432
5468
          }
5433
5469
        ;
5434
5470
 
5441
5477
internal_variable_ident:
5442
5478
          keyword_exception_for_variable
5443
5479
          {
5444
 
            $$.str= YYSession->strmake($1.str, $1.length);
5445
 
            $$.length= $1.length;
 
5480
            $$.assign(YYSession->mem.strdup($1.data(), $1.length), $1.length);
5446
5481
          }
5447
5482
        | IDENT_sys    { $$=$1; }
5448
5483
        ;
5453
5488
            /* We have to lookup here since local vars can shadow sysvars */
5454
5489
            {
5455
5490
              /* Not an SP local variable */
5456
 
              sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
5457
 
              if (!tmp)
 
5491
              sys_var *tmp= find_sys_var(to_string($1));
 
5492
              if (not tmp)
5458
5493
                DRIZZLE_YYABORT;
5459
5494
              $$.var= tmp;
5460
 
              $$.base_name= null_lex_str;
 
5495
              $$.base_name= null_lex_string();
5461
5496
            }
5462
5497
          }
5463
5498
        ;
5472
5507
set_expr_or_default:
5473
5508
          expr { $$=$1; }
5474
5509
        | DEFAULT { $$=0; }
5475
 
        | ON     { $$=new Item_string("ON",  2, system_charset_info); }
5476
 
        | ALL    { $$=new Item_string("ALL", 3, system_charset_info); }
5477
 
        | BINARY { $$=new Item_string("binary", 6, system_charset_info); }
 
5510
        | ON     { $$=new Item_string(str_ref("ON"), system_charset_info); }
 
5511
        | ALL    { $$=new Item_string(str_ref("ALL"), system_charset_info); }
 
5512
        | BINARY { $$=new Item_string(str_ref("binary"), system_charset_info); }
5478
5513
        ;
5479
5514
 
5480
5515
table_or_tables: