~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Lee Bieber
  • Date: 2011-03-13 16:37:38 UTC
  • mfrom: (2227.4.18 session2)
  • Revision ID: kalebral@gmail.com-20110313163738-7ti21zk40o2xi3ew
Merge Olaf - Refactor Session

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#define YYINITDEPTH 100
35
35
#define YYMAXDEPTH 3200                        /* Because of 64K stack */
36
 
#define Lex (session->getLex())
 
36
#define Lex (session->lex())
37
37
 
38
38
#include <config.h>
39
39
#include <cstdio>
632
632
        opt_status
633
633
        opt_zerofill
634
634
        opt_if_not_exists
635
 
        if_exists 
636
 
        opt_temporary 
 
635
        if_exists
 
636
        opt_temporary
637
637
        opt_field_number_signed
638
638
 
639
639
%type <num>
797
797
query:
798
798
          END_OF_INPUT
799
799
          {
800
 
            if (!(YYSession->getLex()->select_lex.options & OPTION_FOUND_COMMENT))
 
800
            if (!(YYSession->lex().select_lex.options & OPTION_FOUND_COMMENT))
801
801
            {
802
802
              my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
803
803
              DRIZZLE_YYABORT;
804
804
            }
805
805
            else
806
806
            {
807
 
              YYSession->getLex()->statement= new statement::EmptyQuery(YYSession);
 
807
              YYSession->lex().statement= new statement::EmptyQuery(YYSession);
808
808
            }
809
809
          }
810
810
        | verb_clause END_OF_INPUT {}
850
850
create:
851
851
          CREATE CATALOG_SYM catalog_name
852
852
          {
853
 
            Lex->statement= new statement::catalog::Create(YYSession, $3);
 
853
            Lex.statement= new statement::catalog::Create(YYSession, $3);
854
854
          }
855
855
        | CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
856
856
          {
857
 
            Lex->statement= new statement::CreateTable(YYSession, $5, $2);
 
857
            Lex.statement= new statement::CreateTable(YYSession, $5, $2);
858
858
 
859
 
            if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
 
859
            if (not Lex.select_lex.add_table_to_list(YYSession, $5, NULL,
860
860
                                                     TL_OPTION_UPDATING,
861
861
                                                     TL_WRITE))
862
862
              DRIZZLE_YYABORT;
863
 
            Lex->col_list.clear();
 
863
            Lex.col_list.clear();
864
864
          }
865
865
          create_table_definition
866
866
          {
867
 
            Lex->current_select= &Lex->select_lex;
 
867
            Lex.current_select= &Lex.select_lex;
868
868
          }
869
869
        | CREATE build_method
870
870
          {
871
 
            Lex->statement= new statement::CreateIndex(YYSession, $2);
 
871
            Lex.statement= new statement::CreateIndex(YYSession, $2);
872
872
          }
873
873
          opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
874
874
          {
875
 
            if (not Lex->current_select->add_table_to_list(Lex->session, $9,
 
875
            if (not Lex.current_select->add_table_to_list(Lex.session, $9,
876
876
                                                            NULL,
877
877
                                                            TL_OPTION_UPDATING))
878
878
              DRIZZLE_YYABORT;
879
879
 
880
 
            parser::buildKey(Lex, $4, $6);
 
880
            parser::buildKey(&Lex, $4, $6);
881
881
          }
882
882
        | CREATE DATABASE opt_if_not_exists schema_name
883
883
          {
884
 
            Lex->statement= new statement::CreateSchema(YYSession);
 
884
            Lex.statement= new statement::CreateSchema(YYSession);
885
885
          }
886
886
          opt_create_database_options
887
887
          {
888
 
            Lex->name= $4;
 
888
            Lex.name= $4;
889
889
          }
890
890
        ;
891
891
 
894
894
          { }
895
895
        | '(' create_select ')'
896
896
           {
897
 
             Lex->current_select->set_braces(1);
 
897
             Lex.current_select->set_braces(1);
898
898
           }
899
899
           union_opt {}
900
900
        |  '(' create_like ')' opt_create_table_options
901
901
          { }
902
902
        | create_like opt_create_table_options
903
903
          { }
904
 
        | opt_create_table_options create_select_as 
 
904
        | opt_create_table_options create_select_as
905
905
          { }
906
906
        ;
907
907
 
909
909
          /* empty */ {}
910
910
        | opt_duplicate_as create_select
911
911
          {
912
 
            Lex->current_select->set_braces(0);
 
912
            Lex.current_select->set_braces(0);
913
913
          }
914
914
          union_clause {}
915
915
        | opt_duplicate_as '(' create_select ')'
916
916
          {
917
 
            Lex->current_select->set_braces(1);
 
917
            Lex.current_select->set_braces(1);
918
918
          }
919
919
          union_opt {}
920
920
        ;
922
922
create_like:
923
923
          LIKE table_ident
924
924
          {
925
 
            ((statement::CreateTable *)(YYSession->getLex()->statement))->is_create_table_like= true;
 
925
            ((statement::CreateTable *)(YYSession->lex().statement))->is_create_table_like= true;
926
926
 
927
 
            if (not YYSession->getLex()->select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
 
927
            if (not YYSession->lex().select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
928
928
              DRIZZLE_YYABORT;
929
929
          }
930
930
        ;
941
941
stored_select:
942
942
          SELECT_SYM
943
943
          {
944
 
            Lex->lock_option= TL_READ;
945
 
            if (Lex->sql_command == SQLCOM_INSERT)
 
944
            Lex.lock_option= TL_READ;
 
945
            if (Lex.sql_command == SQLCOM_INSERT)
946
946
            {
947
 
              delete Lex->statement;
948
 
              Lex->statement= new statement::InsertSelect(YYSession);
 
947
              delete Lex.statement;
 
948
              Lex.statement= new statement::InsertSelect(YYSession);
949
949
            }
950
 
            else if (Lex->sql_command == SQLCOM_REPLACE)
 
950
            else if (Lex.sql_command == SQLCOM_REPLACE)
951
951
            {
952
 
              delete Lex->statement;
953
 
              Lex->statement= new statement::ReplaceSelect(YYSession);
 
952
              delete Lex.statement;
 
953
              Lex.statement= new statement::ReplaceSelect(YYSession);
954
954
            }
955
955
            /*
956
956
              The following work only with the local list, the global list
957
957
              is created correctly in this case
958
958
            */
959
 
            Lex->current_select->table_list.save_and_clear(&Lex->save_list);
960
 
            init_select(Lex);
961
 
            Lex->current_select->parsing_place= SELECT_LIST;
 
959
            Lex.current_select->table_list.save_and_clear(&Lex.save_list);
 
960
            init_select(&Lex);
 
961
            Lex.current_select->parsing_place= SELECT_LIST;
962
962
          }
963
963
          select_options select_item_list
964
964
          {
965
 
            Lex->current_select->parsing_place= NO_MATTER;
 
965
            Lex.current_select->parsing_place= NO_MATTER;
966
966
          }
967
967
          opt_select_from
968
968
          {
970
970
              The following work only with the local list, the global list
971
971
              is created correctly in this case
972
972
            */
973
 
            Lex->current_select->table_list.push_front(&Lex->save_list);
 
973
            Lex.current_select->table_list.push_front(&Lex.save_list);
974
974
          }
975
975
        ;
976
976
 
988
988
custom_database_option:
989
989
          ident_or_text
990
990
          {
991
 
            statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
 
991
            statement::CreateSchema *statement= (statement::CreateSchema *)Lex.statement;
992
992
            statement->schema_message.mutable_engine()->add_options()->set_name($1.str);
993
993
          }
994
994
        | REPLICATE opt_equal TRUE_SYM
995
995
          {
996
 
            parser::buildReplicationOption(Lex, true);
 
996
            parser::buildReplicationOption(&Lex, true);
997
997
          }
998
998
        | REPLICATE opt_equal FALSE_SYM
999
999
          {
1000
 
            parser::buildReplicationOption(Lex, false);
 
1000
            parser::buildReplicationOption(&Lex, false);
1001
1001
          }
1002
1002
        | ident_or_text equal ident_or_text
1003
1003
          {
1004
 
            parser::buildSchemaOption(Lex, $1.str, $3);
 
1004
            parser::buildSchemaOption(&Lex, $1.str, $3);
1005
1005
          }
1006
1006
        | ident_or_text equal ulonglong_num
1007
1007
          {
1008
 
            parser::buildSchemaOption(Lex, $1.str, $3);
 
1008
            parser::buildSchemaOption(&Lex, $1.str, $3);
1009
1009
          }
1010
1010
        ;
1011
1011
 
1016
1016
 
1017
1017
opt_if_not_exists:
1018
1018
          /* empty */ { $$= false; }
1019
 
        | IF NOT_SYM EXISTS { $$= true; YYSession->getLex()->setExists(); }
 
1019
        | IF NOT_SYM EXISTS { $$= true; YYSession->lex().setExists(); }
1020
1020
        ;
1021
1021
 
1022
1022
opt_create_table_options:
1040
1040
custom_engine_option:
1041
1041
        ENGINE_SYM equal ident_or_text
1042
1042
          {
1043
 
            Lex->table()->mutable_engine()->set_name($3.str);
 
1043
            Lex.table()->mutable_engine()->set_name($3.str);
1044
1044
          }
1045
1045
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1046
1046
          {
1047
 
            Lex->table()->mutable_options()->set_comment($3.str);
 
1047
            Lex.table()->mutable_options()->set_comment($3.str);
1048
1048
          }
1049
1049
        | AUTO_INC opt_equal ulonglong_num
1050
1050
          {
1051
 
            Lex->table()->mutable_options()->set_auto_increment_value($3);
 
1051
            Lex.table()->mutable_options()->set_auto_increment_value($3);
1052
1052
          }
1053
1053
        | REPLICATE opt_equal TRUE_SYM
1054
1054
          {
1055
 
            message::set_is_replicated(*Lex->table(), true);
 
1055
            message::set_is_replicated(*Lex.table(), true);
1056
1056
          }
1057
1057
        | REPLICATE opt_equal FALSE_SYM
1058
1058
          {
1059
 
            message::set_is_replicated(*Lex->table(), false);
 
1059
            message::set_is_replicated(*Lex.table(), false);
1060
1060
          }
1061
1061
        |  ROW_FORMAT_SYM equal row_format_or_text
1062
1062
          {
1063
 
            parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
 
1063
            parser::buildEngineOption(&Lex, "ROW_FORMAT", $3);
1064
1064
          }
1065
1065
        |  FILE_SYM equal TEXT_STRING_sys
1066
1066
          {
1067
 
            parser::buildEngineOption(Lex, "FILE", $3);
 
1067
            parser::buildEngineOption(&Lex, "FILE", $3);
1068
1068
          }
1069
1069
        |  ident_or_text equal engine_option_value
1070
1070
          {
1071
 
            parser::buildEngineOption(Lex, $1.str, $3);
 
1071
            parser::buildEngineOption(&Lex, $1.str, $3);
1072
1072
          }
1073
1073
        | ident_or_text equal ulonglong_num
1074
1074
          {
1075
 
            parser::buildEngineOption(Lex, $1.str, $3);
 
1075
            parser::buildEngineOption(&Lex, $1.str, $3);
1076
1076
          }
1077
1077
        | default_collation
1078
1078
        ;
1080
1080
default_collation:
1081
1081
          opt_default COLLATE_SYM opt_equal collation_name_or_default
1082
1082
          {
1083
 
            if (not parser::buildCollation(Lex, $4))
 
1083
            if (not parser::buildCollation(&Lex, $4))
1084
1084
            {
1085
1085
              DRIZZLE_YYABORT;
1086
1086
            }
1090
1090
default_collation_schema:
1091
1091
          opt_default COLLATE_SYM opt_equal collation_name_or_default
1092
1092
          {
1093
 
            ((statement::CreateSchema *)Lex->statement)->schema_message.set_collation($4->name);
 
1093
            ((statement::CreateSchema *)Lex.statement)->schema_message.set_collation($4->name);
1094
1094
          }
1095
1095
        ;
1096
1096
 
1130
1130
          field_spec opt_check_constraint
1131
1131
        | field_spec references
1132
1132
          {
1133
 
            Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
 
1133
            Lex.col_list.clear(); /* Alloced by memory::sql_alloc */
1134
1134
          }
1135
1135
        ;
1136
1136
 
1137
1137
key_def:
1138
1138
          key_type opt_ident key_alg '(' key_list ')' key_options
1139
1139
          {
1140
 
            parser::buildKey(Lex, $1, $2);
 
1140
            parser::buildKey(&Lex, $1, $2);
1141
1141
          }
1142
1142
        | opt_constraint constraint_key_type opt_ident key_alg
1143
1143
          '(' key_list ')' key_options
1144
1144
          {
1145
 
            parser::buildKey(Lex, $2, $3.str ? $3 : $1);
 
1145
            parser::buildKey(&Lex, $2, $3.str ? $3 : $1);
1146
1146
          }
1147
1147
        | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1148
1148
          {
1149
 
            parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
 
1149
            parser::buildForeignKey(&Lex, $1.str ? $1 : $4, $8);
1150
1150
          }
1151
1151
        | constraint opt_check_constraint
1152
1152
          {
1153
 
            Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
 
1153
            Lex.col_list.clear(); /* Alloced by memory::sql_alloc */
1154
1154
          }
1155
1155
        | opt_constraint check_constraint
1156
1156
          {
1157
 
            Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
 
1157
            Lex.col_list.clear(); /* Alloced by memory::sql_alloc */
1158
1158
          }
1159
1159
        ;
1160
1160
 
1179
1179
field_spec:
1180
1180
          field_ident
1181
1181
          {
1182
 
            parser::buildCreateFieldIdent(Lex);
 
1182
            parser::buildCreateFieldIdent(&Lex);
1183
1183
          }
1184
1184
          field_def opt_attribute_comment
1185
1185
          {
1186
 
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1186
            statement::CreateTable *statement= (statement::CreateTable *)Lex.statement;
1187
1187
 
1188
 
            if (Lex->field())
 
1188
            if (Lex.field())
1189
1189
            {
1190
 
              Lex->field()->set_name($1.str);
 
1190
              Lex.field()->set_name($1.str);
1191
1191
            }
1192
1192
 
1193
 
            if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1194
 
                                  Lex->length, Lex->dec, Lex->type,
 
1193
            if (add_field_to_list(Lex.session, &$1, (enum enum_field_types) $3,
 
1194
                                  Lex.length, Lex.dec, Lex.type,
1195
1195
                                  statement->column_format,
1196
1196
                                  statement->default_value, statement->on_update_value,
1197
1197
                                  &statement->comment,
1198
 
                                  statement->change, &Lex->interval_list, Lex->charset))
 
1198
                                  statement->change, &Lex.interval_list, Lex.charset))
1199
1199
              DRIZZLE_YYABORT;
1200
1200
 
1201
 
            Lex->setField(NULL);
 
1201
            Lex.setField(NULL);
1202
1202
          }
1203
1203
        ;
1204
1204
 
1205
1205
field_def:
1206
1206
          TIMESTAMP_SYM opt_attribute_timestamp
1207
1207
          {
1208
 
            $$=parser::buildTimestampColumn(Lex, NULL);
 
1208
            $$=parser::buildTimestampColumn(&Lex, NULL);
1209
1209
          }
1210
1210
        | TIMESTAMP_SYM '(' NUM ')' opt_attribute_timestamp
1211
1211
          {
1212
 
            $$=parser::buildTimestampColumn(Lex, $3.str);
1213
 
          } 
 
1212
            $$=parser::buildTimestampColumn(&Lex, $3.str);
 
1213
          }
1214
1214
        | DATETIME_SYM opt_attribute_timestamp
1215
1215
          {
1216
1216
            $$=DRIZZLE_TYPE_DATETIME;
1217
1217
 
1218
 
            if (Lex->field())
1219
 
              Lex->field()->set_type(message::Table::Field::DATETIME);
1220
 
          } 
 
1218
            if (Lex.field())
 
1219
              Lex.field()->set_type(message::Table::Field::DATETIME);
 
1220
          }
1221
1221
        | int_type opt_attribute_number
1222
 
          { 
 
1222
          {
1223
1223
            $$= $1;
1224
1224
          }
1225
1225
        | CHAR_SYM opt_attribute_string
1226
1226
          {
1227
 
            $$= parser::buildVarcharColumn(Lex, "1");
 
1227
            $$= parser::buildVarcharColumn(&Lex, "1");
1228
1228
          }
1229
1229
        | varchar '(' NUM ')' opt_attribute_string
1230
1230
          {
1231
 
            $$= parser::buildVarcharColumn(Lex, $3.str);
 
1231
            $$= parser::buildVarcharColumn(&Lex, $3.str);
1232
1232
          }
1233
1233
        | TEXT_SYM opt_attribute_string
1234
1234
          {
1235
1235
            $$=DRIZZLE_TYPE_BLOB;
1236
 
            Lex->length=(char*) 0; /* use default length */
 
1236
            Lex.length=(char*) 0; /* use default length */
1237
1237
 
1238
 
            if (Lex->field())
1239
 
              Lex->field()->set_type(message::Table::Field::BLOB);
 
1238
            if (Lex.field())
 
1239
              Lex.field()->set_type(message::Table::Field::BLOB);
1240
1240
          }
1241
1241
        | ENUM_SYM
1242
1242
          {
1243
 
            Lex->interval_list.clear();
 
1243
            Lex.interval_list.clear();
1244
1244
          }
1245
1245
          '(' string_list ')' opt_attribute_string
1246
1246
          {
1247
1247
            $$=DRIZZLE_TYPE_ENUM;
1248
1248
 
1249
 
            if (Lex->field())
1250
 
              Lex->field()->set_type(message::Table::Field::ENUM);
 
1249
            if (Lex.field())
 
1250
              Lex.field()->set_type(message::Table::Field::ENUM);
1251
1251
          }
1252
1252
        | VARBINARY '(' NUM ')' opt_attribute
1253
1253
          {
1254
 
            $$= parser::buildVarbinaryColumn(Lex, $3.str);
 
1254
            $$= parser::buildVarbinaryColumn(&Lex, $3.str);
1255
1255
          }
1256
1256
        | real_type opt_attribute_number
1257
1257
          {
1258
1258
            assert ($1 == DRIZZLE_TYPE_DOUBLE);
1259
 
            $$= parser::buildDoubleColumn(Lex);
1260
 
          } 
 
1259
            $$= parser::buildDoubleColumn(&Lex);
 
1260
          }
1261
1261
        | DATE_SYM opt_attribute
1262
1262
          {
1263
1263
            $$=DRIZZLE_TYPE_DATE;
1264
1264
 
1265
 
            if (Lex->field())
1266
 
              Lex->field()->set_type(message::Table::Field::DATE);
 
1265
            if (Lex.field())
 
1266
              Lex.field()->set_type(message::Table::Field::DATE);
1267
1267
          }
1268
1268
        | TIME_SYM opt_attribute
1269
1269
          {
1270
1270
            $$=DRIZZLE_TYPE_TIME;
1271
1271
 
1272
 
            if (Lex->field())
1273
 
              Lex->field()->set_type(message::Table::Field::TIME);
 
1272
            if (Lex.field())
 
1273
              Lex.field()->set_type(message::Table::Field::TIME);
1274
1274
          }
1275
1275
        | BLOB_SYM opt_attribute
1276
1276
          {
1277
 
            $$= parser::buildBlobColumn(Lex);
 
1277
            $$= parser::buildBlobColumn(&Lex);
1278
1278
          }
1279
1279
        | DECIMAL_SYM float_options opt_attribute_number
1280
1280
          {
1281
 
            $$= parser::buildDecimalColumn(Lex);
 
1281
            $$= parser::buildDecimalColumn(&Lex);
1282
1282
          }
1283
1283
        | NUMERIC_SYM float_options opt_attribute_number
1284
1284
          {
1285
 
            $$= parser::buildDecimalColumn(Lex);
 
1285
            $$= parser::buildDecimalColumn(&Lex);
1286
1286
          }
1287
1287
        | FIXED_SYM float_options opt_attribute_number
1288
1288
          {
1289
 
            $$= parser::buildDecimalColumn(Lex);
 
1289
            $$= parser::buildDecimalColumn(&Lex);
1290
1290
          }
1291
1291
        | UUID_SYM opt_attribute
1292
1292
          {
1293
 
            $$= parser::buildUuidColumn(Lex);
 
1293
            $$= parser::buildUuidColumn(&Lex);
1294
1294
          }
1295
1295
        | BOOLEAN_SYM opt_attribute_boolean
1296
1296
          {
1297
 
            $$= parser::buildBooleanColumn(Lex);
 
1297
            $$= parser::buildBooleanColumn(&Lex);
1298
1298
          }
1299
1299
        | SERIAL_SYM
1300
1300
          {
1301
 
            $$= parser::buildSerialColumn(Lex);
 
1301
            $$= parser::buildSerialColumn(&Lex);
1302
1302
          }
1303
1303
        ;
1304
1304
 
1312
1312
        ;
1313
1313
 
1314
1314
int_type:
1315
 
          INT_SYM  ignored_field_number_length opt_field_number_signed opt_zerofill 
 
1315
          INT_SYM  ignored_field_number_length opt_field_number_signed opt_zerofill
1316
1316
          {
1317
 
            $$= parser::buildIntegerColumn(Lex, DRIZZLE_TYPE_LONG, ($3 or $4));
 
1317
            $$= parser::buildIntegerColumn(&Lex, DRIZZLE_TYPE_LONG, ($3 or $4));
1318
1318
          }
1319
 
        | BIGINT_SYM ignored_field_number_length opt_field_number_signed opt_zerofill 
 
1319
        | BIGINT_SYM ignored_field_number_length opt_field_number_signed opt_zerofill
1320
1320
          {
1321
 
            $$= parser::buildIntegerColumn(Lex, DRIZZLE_TYPE_LONGLONG, ($3 or $4));
 
1321
            $$= parser::buildIntegerColumn(&Lex, DRIZZLE_TYPE_LONGLONG, ($3 or $4));
1322
1322
          }
1323
1323
        ;
1324
1324
 
1339
1339
 
1340
1340
float_options:
1341
1341
          /* empty */
1342
 
          { Lex->dec=Lex->length= (char*)0; }
 
1342
          { Lex.dec=Lex.length= (char*)0; }
1343
1343
        | '(' NUM ')'
1344
 
          { Lex->length=$2.str; Lex->dec= (char*)0; }
 
1344
          { Lex.length=$2.str; Lex.dec= (char*)0; }
1345
1345
        | precision
1346
1346
          {}
1347
1347
        ;
1349
1349
precision:
1350
1350
          '(' NUM ',' NUM ')'
1351
1351
          {
1352
 
            Lex->length= $2.str;
1353
 
            Lex->dec= $4.str;
 
1352
            Lex.length= $2.str;
 
1353
            Lex.dec= $4.str;
1354
1354
          }
1355
1355
        ;
1356
1356
 
1357
1357
opt_len:
1358
 
          /* empty */ { Lex->length=(char*) 0; /* use default length */ }
1359
 
        | '(' NUM ')' { Lex->length= $2.str; }
 
1358
          /* empty */ { Lex.length=(char*) 0; /* use default length */ }
 
1359
        | '(' NUM ')' { Lex.length= $2.str; }
1360
1360
        ;
1361
1361
 
1362
1362
opt_field_number_signed:
1363
1363
          /* empty */ { $$= false; }
1364
1364
        | SIGNED_SYM { $$= false; }
1365
 
        | UNSIGNED_SYM { $$= true; Lex->type|= UNSIGNED_FLAG; }
 
1365
        | UNSIGNED_SYM { $$= true; Lex.type|= UNSIGNED_FLAG; }
1366
1366
        ;
1367
1367
 
1368
1368
ignored_field_number_length:
1372
1372
 
1373
1373
opt_zerofill:
1374
1374
          /* empty */ { $$= false; }
1375
 
        | ZEROFILL_SYM { $$= true; Lex->type|= UNSIGNED_FLAG; }
 
1375
        | ZEROFILL_SYM { $$= true; Lex.type|= UNSIGNED_FLAG; }
1376
1376
        ;
1377
1377
 
1378
1378
opt_precision:
1379
1379
          /* empty */
1380
 
          { Lex->dec=Lex->length= (char*)0; }
 
1380
          { Lex.dec=Lex.length= (char*)0; }
1381
1381
        | '(' NUM ')'
1382
 
          { Lex->length=Lex->dec= (char*)0; }
 
1382
          { Lex.length=Lex.dec= (char*)0; }
1383
1383
        | precision
1384
1384
          {}
1385
1385
        ;
1387
1387
opt_attribute_not_null:
1388
1388
          NULL_SYM
1389
1389
          {
1390
 
            Lex->type&= ~ NOT_NULL_FLAG;
 
1390
            Lex.type&= ~ NOT_NULL_FLAG;
1391
1391
          }
1392
1392
        | NOT_SYM NULL_SYM
1393
1393
          {
1394
 
            Lex->type|= NOT_NULL_FLAG;
 
1394
            Lex.type|= NOT_NULL_FLAG;
1395
1395
 
1396
 
            if (Lex->field())
 
1396
            if (Lex.field())
1397
1397
            {
1398
 
              Lex->field()->mutable_constraints()->set_is_notnull(true);
 
1398
              Lex.field()->mutable_constraints()->set_is_notnull(true);
1399
1399
            }
1400
1400
          }
1401
1401
        ;
1403
1403
opt_attribute_index:
1404
1404
          opt_primary KEY_SYM
1405
1405
          {
1406
 
            parser::buildPrimaryOnColumn(Lex);
 
1406
            parser::buildPrimaryOnColumn(&Lex);
1407
1407
          }
1408
1408
        | UNIQUE_SYM
1409
1409
          {
1410
 
            parser::buildKeyOnColumn(Lex);
 
1410
            parser::buildKeyOnColumn(&Lex);
1411
1411
          }
1412
1412
        | UNIQUE_SYM KEY_SYM
1413
1413
          {
1414
 
            parser::buildKeyOnColumn(Lex);
 
1414
            parser::buildKeyOnColumn(&Lex);
1415
1415
          }
1416
1416
        ;
1417
1417
 
1421
1421
          { }
1422
1422
        | opt_attribute DEFAULT signed_literal
1423
1423
          {
1424
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1424
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1425
1425
 
1426
1426
            statement->default_value= $3;
1427
1427
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1436
1436
          { }
1437
1437
        | opt_attribute_boolean DEFAULT boolean_literal
1438
1438
          {
1439
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1439
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1440
1440
 
1441
1441
            statement->default_value= $3;
1442
1442
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1460
1460
          { }
1461
1461
        | DEFAULT signed_literal
1462
1462
          {
1463
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1463
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1464
1464
 
1465
1465
            statement->default_value=$2;
1466
1466
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1467
1467
          }
1468
1468
        | COLLATE_SYM collation_name
1469
1469
          {
1470
 
            if (Lex->charset && !my_charset_same(Lex->charset,$2))
 
1470
            if (Lex.charset && !my_charset_same(Lex.charset,$2))
1471
1471
            {
1472
1472
              my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1473
 
                       $2->name,Lex->charset->csname);
 
1473
                       $2->name,Lex.charset->csname);
1474
1474
              DRIZZLE_YYABORT;
1475
1475
            }
1476
1476
            else
1477
1477
            {
1478
 
              Lex->charset=$2;
 
1478
              Lex.charset=$2;
1479
1479
            }
1480
1480
          }
1481
1481
        | opt_attribute_index
1497
1497
          { }
1498
1498
        | AUTO_INC
1499
1499
          {
1500
 
            parser::buildAutoOnColumn(Lex);
 
1500
            parser::buildAutoOnColumn(&Lex);
1501
1501
          }
1502
1502
        | SERIAL_SYM DEFAULT VALUE_SYM
1503
1503
          {
1504
 
            (void)parser::buildSerialColumn(Lex);
 
1504
            (void)parser::buildSerialColumn(&Lex);
1505
1505
          }
1506
1506
        | DEFAULT integer_literal
1507
1507
          {
1508
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1508
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1509
1509
 
1510
1510
            statement->default_value=$2;
1511
1511
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1529
1529
          { }
1530
1530
        | DEFAULT NOW_SYM optional_braces
1531
1531
          {
1532
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1532
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1533
1533
 
1534
1534
            statement->default_value= new Item_func_now_local();
1535
1535
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1536
1536
          }
1537
1537
        | DEFAULT date_literal
1538
1538
          {
1539
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1539
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1540
1540
 
1541
1541
            statement->default_value=$2;
1542
1542
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1543
1543
          }
1544
1544
        | ON UPDATE_SYM NOW_SYM optional_braces
1545
1545
          {
1546
 
            ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
 
1546
            ((statement::AlterTable *)Lex.statement)->on_update_value= new Item_func_now_local();
1547
1547
          }
1548
1548
        | opt_attribute_index
1549
1549
          { }
1553
1553
          /* empty */ { }
1554
1554
        | COMMENT_SYM TEXT_STRING_sys
1555
1555
          {
1556
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1556
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1557
1557
            statement->comment= $2;
1558
1558
 
1559
 
            if (Lex->field())
1560
 
              Lex->field()->set_comment($2.str);
 
1559
            if (Lex.field())
 
1560
              Lex.field()->set_comment($2.str);
1561
1561
          }
1562
1562
        ;
1563
1563
 
1596
1596
 
1597
1597
opt_ref_list:
1598
1598
          /* empty */
1599
 
          { Lex->ref_list.clear(); }
 
1599
          { Lex.ref_list.clear(); }
1600
1600
        | '(' ref_list ')'
1601
1601
        ;
1602
1602
 
1603
1603
ref_list:
1604
1604
          ref_list ',' ident
1605
 
          { Lex->ref_list.push_back(new Key_part_spec($3, 0)); }
 
1605
          { Lex.ref_list.push_back(new Key_part_spec($3, 0)); }
1606
1606
        | ident
1607
1607
          {
1608
 
            Lex->ref_list.clear();
1609
 
            Lex->ref_list.push_back(new Key_part_spec($1, 0));
 
1608
            Lex.ref_list.clear();
 
1609
            Lex.ref_list.push_back(new Key_part_spec($1, 0));
1610
1610
          }
1611
1611
        ;
1612
1612
 
1613
1613
opt_match_clause:
1614
1614
          /* empty */
1615
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
 
1615
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1616
1616
        | MATCH FULL
1617
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
 
1617
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1618
1618
        | MATCH PARTIAL
1619
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
 
1619
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1620
1620
        | MATCH SIMPLE_SYM
1621
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
 
1621
          { ((statement::CreateTable *)Lex.statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1622
1622
        ;
1623
1623
 
1624
1624
opt_on_update_delete:
1625
1625
          /* empty */
1626
1626
          {
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;
 
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;
1629
1629
          }
1630
1630
        | ON UPDATE_SYM delete_option
1631
1631
          {
1632
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1633
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1632
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= $3;
 
1633
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1634
1634
          }
1635
1635
        | ON DELETE_SYM delete_option
1636
1636
          {
1637
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1638
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
 
1637
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1638
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= $3;
1639
1639
          }
1640
1640
        | ON UPDATE_SYM delete_option
1641
1641
          ON DELETE_SYM delete_option
1642
1642
          {
1643
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1644
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
 
1643
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= $3;
 
1644
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= $6;
1645
1645
          }
1646
1646
        | ON DELETE_SYM delete_option
1647
1647
          ON UPDATE_SYM delete_option
1648
1648
          {
1649
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1650
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
 
1649
            ((statement::CreateTable *)Lex.statement)->fk_update_opt= $6;
 
1650
            ((statement::CreateTable *)Lex.statement)->fk_delete_opt= $3;
1651
1651
          }
1652
1652
        ;
1653
1653
 
1691
1691
 
1692
1692
init_key_options:
1693
1693
          {
1694
 
            ((statement::CreateTable *)Lex->statement)->key_create_info= default_key_create_info;
 
1694
            ((statement::CreateTable *)Lex.statement)->key_create_info= default_key_create_info;
1695
1695
          }
1696
1696
        ;
1697
1697
 
1698
1698
/*
1699
 
  For now, key_alg initializies Lex->key_create_info.
 
1699
  For now, key_alg initializies Lex.key_create_info.
1700
1700
  In the future, when all key options are after key definition,
1701
1701
  we can remove key_alg and move init_key_options to key_options
1702
1702
*/
1717
1717
        ;
1718
1718
 
1719
1719
key_using_alg:
1720
 
          USING btree_or_rtree     { ((statement::CreateTable *)Lex->statement)->key_create_info.algorithm= $2; }
 
1720
          USING btree_or_rtree     { ((statement::CreateTable *)Lex.statement)->key_create_info.algorithm= $2; }
1721
1721
        ;
1722
1722
 
1723
1723
key_opt:
1724
1724
          key_using_alg
1725
1725
        | KEY_BLOCK_SIZE opt_equal ulong_num
1726
 
          { ((statement::CreateTable *)Lex->statement)->key_create_info.block_size= $3; }
 
1726
          { ((statement::CreateTable *)Lex.statement)->key_create_info.block_size= $3; }
1727
1727
        | COMMENT_SYM TEXT_STRING_sys
1728
 
          { ((statement::CreateTable *)Lex->statement)->key_create_info.comment= $2; }
 
1728
          { ((statement::CreateTable *)Lex.statement)->key_create_info.comment= $2; }
1729
1729
        ;
1730
1730
 
1731
1731
btree_or_rtree:
1734
1734
        ;
1735
1735
 
1736
1736
key_list:
1737
 
          key_list ',' key_part order_dir { Lex->col_list.push_back($3); }
1738
 
        | key_part order_dir { Lex->col_list.push_back($1); }
 
1737
          key_list ',' key_part order_dir { Lex.col_list.push_back($3); }
 
1738
        | key_part order_dir { Lex.col_list.push_back($1); }
1739
1739
        ;
1740
1740
 
1741
1741
key_part:
1762
1762
        ;
1763
1763
 
1764
1764
string_list:
1765
 
          text_string { Lex->interval_list.push_back($1); }
1766
 
        | string_list ',' text_string { Lex->interval_list.push_back($3); };
 
1765
          text_string { Lex.interval_list.push_back($1); }
 
1766
        | string_list ',' text_string { Lex.interval_list.push_back($3); };
1767
1767
 
1768
1768
/*
1769
1769
** Alter table
1773
1773
          ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
1774
1774
          {
1775
1775
            statement::AlterTable *statement= new statement::AlterTable(YYSession, $5, $2);
1776
 
            Lex->statement= statement;
1777
 
            Lex->duplicates= DUP_ERROR;
1778
 
            if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL, TL_OPTION_UPDATING))
 
1776
            Lex.statement= statement;
 
1777
            Lex.duplicates= DUP_ERROR;
 
1778
            if (not Lex.select_lex.add_table_to_list(YYSession, $5, NULL, TL_OPTION_UPDATING))
1779
1779
            {
1780
1780
              DRIZZLE_YYABORT;
1781
1781
            }
1782
1782
 
1783
 
            Lex->col_list.clear();
1784
 
            Lex->select_lex.init_order();
1785
 
            Lex->select_lex.db= const_cast<char *>(((TableList*) Lex->select_lex.table_list.first)->getSchemaName());
 
1783
            Lex.col_list.clear();
 
1784
            Lex.select_lex.init_order();
 
1785
            Lex.select_lex.db= const_cast<char *>(((TableList*) Lex.select_lex.table_list.first)->getSchemaName());
1786
1786
          }
1787
1787
          alter_commands
1788
1788
          {}
1789
1789
        | ALTER_SYM DATABASE schema_name
1790
1790
          {
1791
 
            Lex->statement= new statement::AlterSchema(YYSession);
 
1791
            Lex.statement= new statement::AlterSchema(YYSession);
1792
1792
          }
1793
1793
          default_collation_schema
1794
1794
          {
1795
 
            Lex->name= $3;
1796
 
            if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
 
1795
            Lex.name= $3;
 
1796
            if (Lex.name.str == NULL && Lex.copy_db_to(&Lex.name.str, &Lex.name.length))
1797
1797
              DRIZZLE_YYABORT;
1798
1798
          }
1799
1799
        ;
1802
1802
          /* empty */
1803
1803
        | DISCARD TABLESPACE
1804
1804
          {
1805
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1805
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1806
1806
            statement->alter_info.tablespace_op= DISCARD_TABLESPACE;
1807
1807
          }
1808
1808
        | IMPORT TABLESPACE
1809
1809
          {
1810
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1810
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1811
1811
            statement->alter_info.tablespace_op= IMPORT_TABLESPACE;
1812
1812
          }
1813
1813
        | alter_list
1836
1836
add_column:
1837
1837
          ADD_SYM opt_column
1838
1838
          {
1839
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1839
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1840
1840
 
1841
1841
            statement->change=0;
1842
1842
            statement->alter_info.flags.set(ALTER_ADD_COLUMN);
1847
1847
          add_column column_def opt_place { }
1848
1848
        | ADD_SYM key_def
1849
1849
          {
1850
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1850
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1851
1851
 
1852
1852
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1853
1853
          }
1854
1854
        | add_column '(' field_list ')'
1855
1855
          {
1856
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1856
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1857
1857
 
1858
1858
            statement->alter_info.flags.set(ALTER_ADD_COLUMN);
1859
1859
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1860
1860
          }
1861
1861
        | CHANGE_SYM opt_column field_ident
1862
1862
          {
1863
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1863
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1864
1864
            statement->change= $3.str;
1865
1865
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1866
1866
          }
1867
1867
          field_spec opt_place
1868
1868
        | MODIFY_SYM opt_column field_ident
1869
1869
          {
1870
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1871
 
            Lex->length= Lex->dec=0;
1872
 
            Lex->type= 0;
 
1870
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
 
1871
            Lex.length= Lex.dec=0;
 
1872
            Lex.type= 0;
1873
1873
            statement->default_value= statement->on_update_value= 0;
1874
1874
            statement->comment= null_lex_str;
1875
 
            Lex->charset= NULL;
 
1875
            Lex.charset= NULL;
1876
1876
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1877
1877
            statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1878
1878
 
1879
 
            Lex->setField(NULL);
 
1879
            Lex.setField(NULL);
1880
1880
          }
1881
1881
          field_def opt_attribute_comment
1882
1882
          {
1883
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1883
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1884
1884
 
1885
 
            if (add_field_to_list(Lex->session,&$3,
 
1885
            if (add_field_to_list(Lex.session,&$3,
1886
1886
                                  (enum enum_field_types) $5,
1887
 
                                  Lex->length, Lex->dec, Lex->type,
 
1887
                                  Lex.length, Lex.dec, Lex.type,
1888
1888
                                  statement->column_format,
1889
1889
                                  statement->default_value,
1890
1890
                                  statement->on_update_value,
1891
1891
                                  &statement->comment,
1892
 
                                  $3.str, &Lex->interval_list, Lex->charset))
 
1892
                                  $3.str, &Lex.interval_list, Lex.charset))
1893
1893
              DRIZZLE_YYABORT;
1894
1894
          }
1895
1895
          opt_place
1896
1896
        | DROP opt_column field_ident
1897
1897
          {
1898
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1898
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1899
1899
 
1900
1900
            statement->alter_info.drop_list.push_back(AlterDrop(AlterDrop::COLUMN, $3.str));
1901
1901
            statement->alter_info.flags.set(ALTER_DROP_COLUMN);
1902
1902
          }
1903
1903
        | DROP FOREIGN KEY_SYM opt_ident
1904
1904
          {
1905
 
            parser::buildAddAlterDropIndex(Lex, $4.str, true);
 
1905
            parser::buildAddAlterDropIndex(&Lex, $4.str, true);
1906
1906
          }
1907
1907
        | DROP PRIMARY_SYM KEY_SYM
1908
1908
          {
1909
 
            parser::buildAddAlterDropIndex(Lex, "PRIMARY");
 
1909
            parser::buildAddAlterDropIndex(&Lex, "PRIMARY");
1910
1910
          }
1911
1911
        | DROP key_or_index field_ident
1912
1912
          {
1913
 
            parser::buildAddAlterDropIndex(Lex, $3.str);
 
1913
            parser::buildAddAlterDropIndex(&Lex, $3.str);
1914
1914
          }
1915
1915
        | DISABLE_SYM KEYS
1916
1916
          {
1917
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1917
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1918
1918
 
1919
1919
            statement->alter_info.keys_onoff= DISABLE;
1920
1920
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
1921
1921
          }
1922
1922
        | ENABLE_SYM KEYS
1923
1923
          {
1924
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1924
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1925
1925
 
1926
1926
            statement->alter_info.keys_onoff= ENABLE;
1927
1927
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
1928
1928
          }
1929
1929
        | ALTER_SYM opt_column field_ident SET_SYM DEFAULT signed_literal
1930
1930
          {
1931
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1931
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1932
1932
 
1933
1933
            statement->alter_info.alter_list.push_back(AlterColumn($3.str,$6));
1934
1934
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1935
1935
          }
1936
1936
        | ALTER_SYM opt_column field_ident DROP DEFAULT
1937
1937
          {
1938
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1938
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1939
1939
 
1940
1940
            statement->alter_info.alter_list.push_back(AlterColumn($3.str, (Item*) 0));
1941
1941
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1942
1942
          }
1943
1943
        | RENAME opt_to table_ident
1944
1944
          {
1945
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1945
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1946
1946
            size_t dummy;
1947
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))
 
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))
1951
1951
            {
1952
1952
              DRIZZLE_YYABORT;
1953
1953
            }
1958
1958
              DRIZZLE_YYABORT;
1959
1959
            }
1960
1960
 
1961
 
            Lex->name= $3->table;
 
1961
            Lex.name= $3->table;
1962
1962
            statement->alter_info.flags.set(ALTER_RENAME);
1963
1963
          }
1964
1964
        | CONVERT_SYM TO_SYM collation_name_or_default
1965
1965
          {
1966
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1966
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1967
1967
 
1968
1968
            statement->create_info().table_charset=
1969
1969
            statement->create_info().default_table_charset= $3;
1973
1973
          }
1974
1974
        | create_table_options_space_separated
1975
1975
          {
1976
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1976
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1977
1977
 
1978
1978
            statement->alter_info.flags.set(ALTER_OPTIONS);
1979
1979
          }
1980
1980
        | FORCE_SYM
1981
1981
          {
1982
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1982
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1983
1983
 
1984
1984
            statement->alter_info.flags.set(ALTER_FORCE);
1985
1985
          }
1986
1986
        | alter_order_clause
1987
1987
          {
1988
 
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1988
            statement::AlterTable *statement= (statement::AlterTable *)Lex.statement;
1989
1989
 
1990
1990
            statement->alter_info.flags.set(ALTER_ORDER);
1991
1991
          }
1997
1997
        ;
1998
1998
 
1999
1999
opt_ignore:
2000
 
          /* empty */ { Lex->ignore= 0;}
2001
 
        | IGNORE_SYM { Lex->ignore= 1;}
 
2000
          /* empty */ { Lex.ignore= 0;}
 
2001
        | IGNORE_SYM { Lex.ignore= 1;}
2002
2002
        ;
2003
2003
 
2004
2004
opt_place:
2005
2005
          /* empty */ {}
2006
2006
        | AFTER_SYM ident
2007
2007
          {
2008
 
            parser::storeAlterColumnPosition(Lex, $2.str);
 
2008
            parser::storeAlterColumnPosition(&Lex, $2.str);
2009
2009
          }
2010
2010
        | FIRST_SYM
2011
2011
          {
2012
 
            parser::storeAlterColumnPosition(Lex, first_keyword);
 
2012
            parser::storeAlterColumnPosition(&Lex, first_keyword);
2013
2013
          }
2014
2014
        ;
2015
2015
 
2022
2022
start:
2023
2023
          START_SYM TRANSACTION_SYM start_transaction_opts
2024
2024
          {
2025
 
            Lex->statement= new statement::StartTransaction(YYSession, (start_transaction_option_t)$3);
 
2025
            Lex.statement= new statement::StartTransaction(YYSession, (start_transaction_option_t)$3);
2026
2026
          }
2027
2027
        ;
2028
2028
 
2037
2037
analyze:
2038
2038
          ANALYZE_SYM table_or_tables
2039
2039
          {
2040
 
            Lex->statement= new statement::Analyze(YYSession);
 
2040
            Lex.statement= new statement::Analyze(YYSession);
2041
2041
          }
2042
2042
          table_list
2043
2043
          {}
2046
2046
check:
2047
2047
          CHECK_SYM table_or_tables
2048
2048
          {
2049
 
            Lex->statement= new statement::Check(YYSession);
 
2049
            Lex.statement= new statement::Check(YYSession);
2050
2050
          }
2051
2051
          table_list
2052
2052
          {}
2055
2055
rename:
2056
2056
          RENAME table_or_tables
2057
2057
          {
2058
 
            Lex->statement= new statement::RenameTable(YYSession);
 
2058
            Lex.statement= new statement::RenameTable(YYSession);
2059
2059
          }
2060
2060
          table_to_table_list
2061
2061
          {}
2069
2069
table_to_table:
2070
2070
          table_ident TO_SYM table_ident
2071
2071
          {
2072
 
            Select_Lex *sl= Lex->current_select;
2073
 
            if (!sl->add_table_to_list(Lex->session, $1,NULL,TL_OPTION_UPDATING,
 
2072
            Select_Lex *sl= Lex.current_select;
 
2073
            if (!sl->add_table_to_list(Lex.session, $1,NULL,TL_OPTION_UPDATING,
2074
2074
                                       TL_IGNORE) ||
2075
 
                !sl->add_table_to_list(Lex->session, $3,NULL,TL_OPTION_UPDATING,
 
2075
                !sl->add_table_to_list(Lex.session, $3,NULL,TL_OPTION_UPDATING,
2076
2076
                                       TL_IGNORE))
2077
2077
              DRIZZLE_YYABORT;
2078
2078
          }
2086
2086
select:
2087
2087
          select_init
2088
2088
          {
2089
 
            Lex->statement= new statement::Select(YYSession);
 
2089
            Lex.statement= new statement::Select(YYSession);
2090
2090
          }
2091
2091
        ;
2092
2092
 
2099
2099
select_paren:
2100
2100
          SELECT_SYM select_part2
2101
2101
          {
2102
 
            if (parser::setup_select_in_parentheses(YYSession, Lex))
 
2102
            if (parser::setup_select_in_parentheses(YYSession, &Lex))
2103
2103
              DRIZZLE_YYABORT;
2104
2104
          }
2105
2105
        | '(' select_paren ')'
2109
2109
select_paren_derived:
2110
2110
          SELECT_SYM select_part2_derived
2111
2111
          {
2112
 
            if (parser::setup_select_in_parentheses(YYSession, Lex))
 
2112
            if (parser::setup_select_in_parentheses(YYSession, &Lex))
2113
2113
              DRIZZLE_YYABORT;
2114
2114
          }
2115
2115
        | '(' select_paren_derived ')'
2118
2118
select_init2:
2119
2119
          select_part2
2120
2120
          {
2121
 
            Select_Lex * sel= Lex->current_select;
2122
 
            if (Lex->current_select->set_braces(0))
 
2121
            Select_Lex * sel= Lex.current_select;
 
2122
            if (Lex.current_select->set_braces(0))
2123
2123
            {
2124
2124
              parser::my_parse_error(YYSession->m_lip);
2125
2125
              DRIZZLE_YYABORT;
2136
2136
 
2137
2137
select_part2:
2138
2138
          {
2139
 
            Select_Lex *sel= Lex->current_select;
 
2139
            Select_Lex *sel= Lex.current_select;
2140
2140
            if (sel->linkage != UNION_TYPE)
2141
 
              init_select(Lex);
2142
 
            Lex->current_select->parsing_place= SELECT_LIST;
 
2141
              init_select(&Lex);
 
2142
            Lex.current_select->parsing_place= SELECT_LIST;
2143
2143
          }
2144
2144
          select_options select_item_list
2145
2145
          {
2146
 
            Lex->current_select->parsing_place= NO_MATTER;
 
2146
            Lex.current_select->parsing_place= NO_MATTER;
2147
2147
          }
2148
2148
          select_into select_lock_type
2149
2149
        ;
2160
2160
          FROM join_table_list where_clause group_clause having_clause
2161
2161
          opt_order_clause opt_limit_clause
2162
2162
          {
2163
 
            Lex->current_select->context.table_list=
2164
 
              Lex->current_select->context.first_name_resolution_table=
2165
 
                reinterpret_cast<TableList *>(Lex->current_select->table_list.first);
 
2163
            Lex.current_select->context.table_list=
 
2164
              Lex.current_select->context.first_name_resolution_table=
 
2165
                reinterpret_cast<TableList *>(Lex.current_select->table_list.first);
2166
2166
          }
2167
2167
        ;
2168
2168
 
2180
2180
select_option_distinct_or_all:
2181
2181
          DISTINCT
2182
2182
          {
2183
 
            Lex->current_select->options|= SELECT_DISTINCT; 
 
2183
            Lex.current_select->options|= SELECT_DISTINCT;
2184
2184
 
2185
 
            if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
 
2185
            if (Lex.current_select->options & SELECT_DISTINCT && Lex.current_select->options & SELECT_ALL)
2186
2186
            {
2187
2187
              my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2188
2188
              DRIZZLE_YYABORT;
2190
2190
          }
2191
2191
        | ALL
2192
2192
          {
2193
 
            Lex->current_select->options|= SELECT_ALL; 
 
2193
            Lex.current_select->options|= SELECT_ALL;
2194
2194
 
2195
 
            if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
 
2195
            if (Lex.current_select->options & SELECT_DISTINCT && Lex.current_select->options & SELECT_ALL)
2196
2196
            {
2197
2197
              my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2198
2198
              DRIZZLE_YYABORT;
2203
2203
select_option_small_or_big:
2204
2204
          SQL_SMALL_RESULT
2205
2205
          {
2206
 
            Lex->current_select->options|= SELECT_SMALL_RESULT;
 
2206
            Lex.current_select->options|= SELECT_SMALL_RESULT;
2207
2207
 
2208
 
            if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
 
2208
            if (Lex.current_select->options & SELECT_SMALL_RESULT && Lex.current_select->options & SELECT_BIG_RESULT)
2209
2209
            {
2210
2210
              my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2211
2211
              DRIZZLE_YYABORT;
2213
2213
          }
2214
2214
        | SQL_BIG_RESULT
2215
2215
          {
2216
 
            Lex->current_select->options|= SELECT_BIG_RESULT;
 
2216
            Lex.current_select->options|= SELECT_BIG_RESULT;
2217
2217
 
2218
 
            if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
 
2218
            if (Lex.current_select->options & SELECT_SMALL_RESULT && Lex.current_select->options & SELECT_BIG_RESULT)
2219
2219
            {
2220
2220
              my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2221
2221
              DRIZZLE_YYABORT;
2225
2225
 
2226
2226
 
2227
2227
select_option:
2228
 
          STRAIGHT_JOIN { Lex->current_select->options|= SELECT_STRAIGHT_JOIN; }
 
2228
          STRAIGHT_JOIN { Lex.current_select->options|= SELECT_STRAIGHT_JOIN; }
2229
2229
        | SQL_BUFFER_RESULT
2230
2230
          {
2231
2231
            if (check_simple_select(YYSession))
2232
2232
              DRIZZLE_YYABORT;
2233
 
            Lex->current_select->options|= OPTION_BUFFER_RESULT;
 
2233
            Lex.current_select->options|= OPTION_BUFFER_RESULT;
2234
2234
          }
2235
2235
        | select_option_small_or_big
2236
2236
          { }
2240
2240
          {
2241
2241
            if (check_simple_select(YYSession))
2242
2242
              DRIZZLE_YYABORT;
2243
 
            Lex->current_select->options|= OPTION_FOUND_ROWS;
 
2243
            Lex.current_select->options|= OPTION_FOUND_ROWS;
2244
2244
          }
2245
2245
        ;
2246
2246
 
2248
2248
          /* empty */
2249
2249
        | FOR_SYM UPDATE_SYM
2250
2250
          {
2251
 
            Lex->current_select->set_lock_for_tables(TL_WRITE);
 
2251
            Lex.current_select->set_lock_for_tables(TL_WRITE);
2252
2252
          }
2253
2253
        | LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
2254
2254
          {
2255
 
            Lex->current_select->
 
2255
            Lex.current_select->
2256
2256
              set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
2257
2257
          }
2258
2258
        ;
2262
2262
        | select_item
2263
2263
        | '*'
2264
2264
          {
2265
 
            if (YYSession->add_item_to_list( new Item_field(&YYSession->getLex()->current_select->context, NULL, NULL, "*")))
 
2265
            if (YYSession->add_item_to_list( new Item_field(&YYSession->lex().current_select->context, NULL, NULL, "*")))
2266
2266
              DRIZZLE_YYABORT;
2267
2267
 
2268
 
            (YYSession->getLex()->current_select->with_wild)++;
 
2268
            (YYSession->lex().current_select->with_wild)++;
2269
2269
          }
2270
2270
        ;
2271
2271
 
2327
2327
          {
2328
2328
            /*
2329
2329
              Design notes:
2330
 
              Do not use a manually maintained stack like session->lex->xxx_list,
 
2330
              Do not use a manually maintained stack like session->Lex.xxx_list,
2331
2331
              but use the internal bison stack ($$, $1 and $3) instead.
2332
2332
              Using the bison stack is:
2333
2333
              - more robust to changes in the grammar,
2421
2421
        | NOT_SYM expr %prec NOT_SYM
2422
2422
          { $$= negate_expression(YYSession, $2); }
2423
2423
        | bool_pri IS TRUE_SYM %prec IS
2424
 
          { 
 
2424
          {
2425
2425
            $$= new (YYSession->mem_root) Item_func_istrue($1);
2426
2426
          }
2427
2427
        | bool_pri IS NOT_SYM TRUE_SYM %prec IS
2514
2514
            $$= item;
2515
2515
          }
2516
2516
        | bit_expr LIKE simple_expr opt_escape
2517
 
          { 
2518
 
            $$= new Item_func_like($1,$3,$4,Lex->escape_used);
 
2517
          {
 
2518
            $$= new Item_func_like($1,$3,$4,Lex.escape_used);
2519
2519
          }
2520
2520
        | bit_expr NOT_SYM LIKE simple_expr opt_escape
2521
 
          { 
2522
 
            $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used));
 
2521
          {
 
2522
            $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex.escape_used));
2523
2523
          }
2524
2524
        | bit_expr REGEXP_SYM bit_expr
2525
 
          { 
 
2525
          {
2526
2526
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2527
2527
            args->push_back($1);
2528
2528
            args->push_back($3);
2532
2532
            }
2533
2533
          }
2534
2534
        | bit_expr NOT_SYM REGEXP_SYM bit_expr
2535
 
          { 
 
2535
          {
2536
2536
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2537
2537
            args->push_back($1);
2538
2538
            args->push_back($4);
2567
2567
            $$= new Item_func_plus($1,$3);
2568
2568
          }
2569
2569
        | bit_expr '-' bit_expr %prec '-'
2570
 
          { 
 
2570
          {
2571
2571
            $$= new Item_func_minus($1,$3);
2572
2572
          }
2573
2573
        | bit_expr '+' INTERVAL_SYM expr interval %prec '+'
2636
2636
        | variable
2637
2637
        | sum_expr
2638
2638
          {
2639
 
            Lex->setSumExprUsed();
 
2639
            Lex.setSumExprUsed();
2640
2640
          }
2641
2641
        | simple_expr CONCAT simple_expr
2642
2642
          {
2678
2678
          }
2679
2679
        | CAST_SYM '(' expr AS cast_type ')'
2680
2680
          {
2681
 
            $$= create_func_cast(YYSession, $3, $5, Lex->length, Lex->dec,
2682
 
                                 Lex->charset);
 
2681
            $$= create_func_cast(YYSession, $3, $5, Lex.length, Lex.dec,
 
2682
                                 Lex.charset);
2683
2683
            if (!$$)
2684
2684
              DRIZZLE_YYABORT;
2685
2685
          }
2687
2687
          { $$= new (YYSession->mem_root) Item_func_case(* $3, $2, $4 ); }
2688
2688
        | CONVERT_SYM '(' expr ',' cast_type ')'
2689
2689
          {
2690
 
            $$= create_func_cast(YYSession, $3, $5, Lex->length, Lex->dec,
2691
 
                                 Lex->charset);
 
2690
            $$= create_func_cast(YYSession, $3, $5, Lex.length, Lex.dec,
 
2691
                                 Lex.charset);
2692
2692
            if (!$$)
2693
2693
              DRIZZLE_YYABORT;
2694
2694
          }
2695
2695
        | DEFAULT '(' simple_ident ')'
2696
2696
          {
2697
 
            $$= new (YYSession->mem_root) Item_default_value(Lex->current_context(),
 
2697
            $$= new (YYSession->mem_root) Item_default_value(Lex.current_context(),
2698
2698
                                                         $3);
2699
2699
          }
2700
2700
        | VALUES '(' simple_ident ')'
2701
2701
          {
2702
 
            $$= new (YYSession->mem_root) Item_insert_value(Lex->current_context(),
 
2702
            $$= new (YYSession->mem_root) Item_insert_value(Lex.current_context(),
2703
2703
                                                        $3);
2704
2704
          }
2705
2705
        | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
2722
2722
            {
2723
2723
              DRIZZLE_YYABORT;
2724
2724
            }
2725
 
            Lex->setCacheable(false);
 
2725
            Lex.setCacheable(false);
2726
2726
          }
2727
2727
        | DATE_SYM '(' expr ')'
2728
2728
          { $$= new (YYSession->mem_root) Item_date_typecast($3); }
2781
2781
            {
2782
2782
              DRIZZLE_YYABORT;
2783
2783
            }
2784
 
            Lex->setCacheable(false);
 
2784
            Lex.setCacheable(false);
2785
2785
          }
2786
2786
        | YEAR_SYM '(' expr ')'
2787
2787
          { $$= new (YYSession->mem_root) Item_func_year($3); }
2809
2809
        | CURDATE optional_braces
2810
2810
          {
2811
2811
            $$= new (YYSession->mem_root) Item_func_curdate_local();
2812
 
            Lex->setCacheable(false);
 
2812
            Lex.setCacheable(false);
2813
2813
          }
2814
2814
        | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
2815
2815
          { $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
2820
2820
        | NOW_SYM optional_braces
2821
2821
          {
2822
2822
            $$= new (YYSession->mem_root) Item_func_now_local();
2823
 
            Lex->setCacheable(false);
 
2823
            Lex.setCacheable(false);
2824
2824
          }
2825
2825
        | NOW_SYM '(' expr ')'
2826
2826
          {
2827
2827
            $$= new (YYSession->mem_root) Item_func_now_local($3);
2828
 
            Lex->setCacheable(false);
 
2828
            Lex.setCacheable(false);
2829
2829
          }
2830
2830
        | POSITION_SYM '(' bit_expr IN_SYM expr ')'
2831
2831
          { $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
2879
2879
            }
2880
2880
          }
2881
2881
        | SYSDATE optional_braces
2882
 
          { 
2883
 
            $$= new (YYSession->mem_root) Item_func_sysdate_local(); 
2884
 
            Lex->setCacheable(false);
 
2882
          {
 
2883
            $$= new (YYSession->mem_root) Item_func_sysdate_local();
 
2884
            Lex.setCacheable(false);
2885
2885
          }
2886
2886
        | SYSDATE '(' expr ')'
2887
 
          { 
2888
 
            $$= new (YYSession->mem_root) Item_func_sysdate_local($3); 
2889
 
            Lex->setCacheable(false);
 
2887
          {
 
2888
            $$= new (YYSession->mem_root) Item_func_sysdate_local($3);
 
2889
            Lex.setCacheable(false);
2890
2890
          }
2891
2891
        | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2892
2892
          { $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2895
2895
        | UTC_DATE_SYM optional_braces
2896
2896
          {
2897
2897
            $$= new (YYSession->mem_root) Item_func_curdate_utc();
2898
 
            Lex->setCacheable(false);
 
2898
            Lex.setCacheable(false);
2899
2899
          }
2900
2900
        | UTC_TIMESTAMP_SYM optional_braces
2901
2901
          {
2902
2902
            $$= new (YYSession->mem_root) Item_func_now_utc();
2903
 
            Lex->setCacheable(false);
 
2903
            Lex.setCacheable(false);
2904
2904
          }
2905
2905
        ;
2906
2906
 
2920
2920
            {
2921
2921
              DRIZZLE_YYABORT;
2922
2922
            }
2923
 
            Lex->setCacheable(false);
 
2923
            Lex.setCacheable(false);
2924
2924
          }
2925
2925
        | CATALOG_SYM '(' ')'
2926
2926
          {
2928
2928
            {
2929
2929
              DRIZZLE_YYABORT;
2930
2930
            }
2931
 
            Lex->setCacheable(false);
 
2931
            Lex.setCacheable(false);
2932
2932
          }
2933
2933
        | EXECUTE_SYM '(' expr ')' opt_wait
2934
2934
          {
2989
2989
            {
2990
2990
              DRIZZLE_YYABORT;
2991
2991
            }
2992
 
            Lex->setCacheable(false);
 
2992
            Lex.setCacheable(false);
2993
2993
          }
2994
2994
        | WAIT_SYM '(' expr ',' expr ')'
2995
2995
          {
3055
3055
            {
3056
3056
              DRIZZLE_YYABORT;
3057
3057
            }
3058
 
            Lex->setCacheable(false);
 
3058
            Lex.setCacheable(false);
3059
3059
          }
3060
3060
        ;
3061
3061
 
3107
3107
        | COUNT_SYM '(' in_sum_expr ')'
3108
3108
          { $$=new Item_sum_count($3); }
3109
3109
        | COUNT_SYM '(' DISTINCT
3110
 
          { Lex->current_select->in_sum_expr++; }
 
3110
          { Lex.current_select->in_sum_expr++; }
3111
3111
          expr_list
3112
 
          { Lex->current_select->in_sum_expr--; }
 
3112
          { Lex.current_select->in_sum_expr--; }
3113
3113
          ')'
3114
3114
          { $$=new Item_sum_count_distinct(* $5); }
3115
3115
        | MIN_SYM '(' in_sum_expr ')'
3138
3138
        | SUM_SYM '(' DISTINCT in_sum_expr ')'
3139
3139
          { $$=new Item_sum_sum_distinct($4); }
3140
3140
        | GROUP_CONCAT_SYM '(' opt_distinct
3141
 
          { Lex->current_select->in_sum_expr++; }
 
3141
          { Lex.current_select->in_sum_expr++; }
3142
3142
          expr_list opt_gorder_clause
3143
3143
          opt_gconcat_separator
3144
3144
          ')'
3145
3145
          {
3146
 
            Select_Lex *sel= Lex->current_select;
 
3146
            Select_Lex *sel= Lex.current_select;
3147
3147
            sel->in_sum_expr--;
3148
 
            $$=new Item_func_group_concat(Lex->current_context(), $3, $5,
 
3148
            $$=new Item_func_group_concat(Lex.current_context(), $3, $5,
3149
3149
                                          sel->gorder_list, $7);
3150
3150
            $5->clear();
3151
3151
          }
3164
3164
          user_variable_ident SET_VAR expr
3165
3165
          {
3166
3166
            $$= new Item_func_set_user_var($1, $3);
3167
 
            Lex->setCacheable(false);
 
3167
            Lex.setCacheable(false);
3168
3168
          }
3169
3169
        | user_variable_ident
3170
3170
          {
3171
3171
            $$= new Item_func_get_user_var(*YYSession, $1);
3172
 
            Lex->setCacheable(false);
 
3172
            Lex.setCacheable(false);
3173
3173
          }
3174
3174
        | '@' opt_var_ident_type user_variable_ident opt_component
3175
3175
          {
3200
3200
opt_gorder_clause:
3201
3201
          /* empty */
3202
3202
          {
3203
 
            Lex->current_select->gorder_list = NULL;
 
3203
            Lex.current_select->gorder_list = NULL;
3204
3204
          }
3205
3205
        | order_clause
3206
3206
          {
3207
 
            Select_Lex *select= Lex->current_select;
 
3207
            Select_Lex *select= Lex.current_select;
3208
3208
            select->gorder_list=
3209
3209
              (SQL_LIST*) memory::sql_memdup((char*) &select->order_list,
3210
3210
                                     sizeof(st_sql_list));
3215
3215
in_sum_expr:
3216
3216
          opt_all
3217
3217
          {
3218
 
            if (Lex->current_select->inc_in_sum_expr())
 
3218
            if (Lex.current_select->inc_in_sum_expr())
3219
3219
            {
3220
3220
              parser::my_parse_error(YYSession->m_lip);
3221
3221
              DRIZZLE_YYABORT;
3223
3223
          }
3224
3224
          expr
3225
3225
          {
3226
 
            Lex->current_select->in_sum_expr--;
 
3226
            Lex.current_select->in_sum_expr--;
3227
3227
            $$= $3;
3228
3228
          }
3229
3229
        ;
3230
3230
 
3231
3231
cast_type:
3232
3232
          BINARY opt_len
3233
 
          { $$=ITEM_CAST_CHAR; Lex->charset= &my_charset_bin; Lex->dec= 0; }
 
3233
          { $$=ITEM_CAST_CHAR; Lex.charset= &my_charset_bin; Lex.dec= 0; }
3234
3234
        | BOOLEAN_SYM
3235
 
          { $$=ITEM_CAST_BOOLEAN; Lex->charset= &my_charset_bin; Lex->dec= 0; }
 
3235
          { $$=ITEM_CAST_BOOLEAN; Lex.charset= &my_charset_bin; Lex.dec= 0; }
3236
3236
        | SIGNED_SYM
3237
 
          { $$=ITEM_CAST_SIGNED; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3237
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3238
3238
        | SIGNED_SYM INT_SYM
3239
 
          { $$=ITEM_CAST_SIGNED; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3239
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3240
3240
        | INT_SYM
3241
 
          { $$=ITEM_CAST_SIGNED; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3241
          { $$=ITEM_CAST_SIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3242
3242
        | UNSIGNED_SYM
3243
 
          { $$=ITEM_CAST_UNSIGNED; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3243
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3244
3244
        | UNSIGNED_SYM INT_SYM
3245
 
          { $$=ITEM_CAST_UNSIGNED; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3245
          { $$=ITEM_CAST_UNSIGNED; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3246
3246
        | CHAR_SYM opt_len
3247
 
          { $$=ITEM_CAST_CHAR; Lex->dec= 0; }
 
3247
          { $$=ITEM_CAST_CHAR; Lex.dec= 0; }
3248
3248
        | DATE_SYM
3249
 
          { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3249
          { $$=ITEM_CAST_DATE; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3250
3250
        | TIME_SYM
3251
 
          { $$=ITEM_CAST_TIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3251
          { $$=ITEM_CAST_TIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3252
3252
        | DATETIME_SYM
3253
 
          { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
 
3253
          { $$=ITEM_CAST_DATETIME; Lex.charset= NULL; Lex.dec=Lex.length= (char*)0; }
3254
3254
        | DECIMAL_SYM float_options
3255
 
          { $$=ITEM_CAST_DECIMAL; Lex->charset= NULL; }
 
3255
          { $$=ITEM_CAST_DECIMAL; Lex.charset= NULL; }
3256
3256
        ;
3257
3257
 
3258
3258
expr_list:
3299
3299
          table_factor { $$=$1; }
3300
3300
        | join_table
3301
3301
          {
3302
 
            if (!($$= Lex->current_select->nest_last_join(Lex->session)))
 
3302
            if (!($$= Lex.current_select->nest_last_join(Lex.session)))
3303
3303
              DRIZZLE_YYABORT;
3304
3304
          }
3305
3305
        ;
3345
3345
            left-associative joins.
3346
3346
          */
3347
3347
          table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3348
 
          { 
 
3348
          {
3349
3349
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
3350
 
            Lex->is_cross= false;
 
3350
            Lex.is_cross= false;
3351
3351
          }
3352
3352
        | table_ref STRAIGHT_JOIN table_factor
3353
 
          { 
3354
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; 
 
3353
          {
 
3354
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1;
3355
3355
          }
3356
3356
        | table_ref normal_join table_ref
3357
3357
          ON
3358
3358
          {
3359
3359
            DRIZZLE_YYABORT_UNLESS($1 && $3);
3360
 
            DRIZZLE_YYABORT_UNLESS( not Lex->is_cross );
 
3360
            DRIZZLE_YYABORT_UNLESS( not Lex.is_cross );
3361
3361
            /* Change the current name resolution context to a local context. */
3362
3362
            if (push_new_name_resolution_context(YYSession, $1, $3))
3363
3363
              DRIZZLE_YYABORT;
3364
 
            Lex->current_select->parsing_place= IN_ON;
 
3364
            Lex.current_select->parsing_place= IN_ON;
3365
3365
          }
3366
3366
          expr
3367
3367
          {
3368
3368
            add_join_on($3,$6);
3369
 
            Lex->pop_context();
3370
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3369
            Lex.pop_context();
 
3370
            Lex.current_select->parsing_place= NO_MATTER;
3371
3371
          }
3372
3372
        | table_ref STRAIGHT_JOIN table_factor
3373
3373
          ON
3376
3376
            /* Change the current name resolution context to a local context. */
3377
3377
            if (push_new_name_resolution_context(YYSession, $1, $3))
3378
3378
              DRIZZLE_YYABORT;
3379
 
            Lex->current_select->parsing_place= IN_ON;
 
3379
            Lex.current_select->parsing_place= IN_ON;
3380
3380
          }
3381
3381
          expr
3382
3382
          {
3383
3383
            $3->straight=1;
3384
3384
            add_join_on($3,$6);
3385
 
            Lex->pop_context();
3386
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3385
            Lex.pop_context();
 
3386
            Lex.current_select->parsing_place= NO_MATTER;
3387
3387
          }
3388
3388
        | table_ref normal_join table_ref
3389
3389
          USING
3391
3391
            DRIZZLE_YYABORT_UNLESS($1 && $3);
3392
3392
          }
3393
3393
          '(' using_list ')'
3394
 
          { add_join_natural($1,$3,$7,Lex->current_select); $$=$3; }
 
3394
          { add_join_natural($1,$3,$7,Lex.current_select); $$=$3; }
3395
3395
        | table_ref NATURAL JOIN_SYM table_factor
3396
3396
          {
3397
3397
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$4));
3398
 
            add_join_natural($1,$4,NULL,Lex->current_select);
 
3398
            add_join_natural($1,$4,NULL,Lex.current_select);
3399
3399
          }
3400
3400
 
3401
3401
          /* LEFT JOIN variants */
3406
3406
            /* Change the current name resolution context to a local context. */
3407
3407
            if (push_new_name_resolution_context(YYSession, $1, $5))
3408
3408
              DRIZZLE_YYABORT;
3409
 
            Lex->current_select->parsing_place= IN_ON;
 
3409
            Lex.current_select->parsing_place= IN_ON;
3410
3410
          }
3411
3411
          expr
3412
3412
          {
3413
3413
            add_join_on($5,$8);
3414
 
            Lex->pop_context();
 
3414
            Lex.pop_context();
3415
3415
            $5->outer_join|=JOIN_TYPE_LEFT;
3416
3416
            $$=$5;
3417
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3417
            Lex.current_select->parsing_place= NO_MATTER;
3418
3418
          }
3419
3419
        | table_ref LEFT opt_outer JOIN_SYM table_factor
3420
3420
          {
3422
3422
          }
3423
3423
          USING '(' using_list ')'
3424
3424
          {
3425
 
            add_join_natural($1,$5,$9,Lex->current_select);
 
3425
            add_join_natural($1,$5,$9,Lex.current_select);
3426
3426
            $5->outer_join|=JOIN_TYPE_LEFT;
3427
3427
            $$=$5;
3428
3428
          }
3429
3429
        | table_ref NATURAL LEFT opt_outer JOIN_SYM table_factor
3430
3430
          {
3431
3431
            DRIZZLE_YYABORT_UNLESS($1 && $6);
3432
 
            add_join_natural($1,$6,NULL,Lex->current_select);
 
3432
            add_join_natural($1,$6,NULL,Lex.current_select);
3433
3433
            $6->outer_join|=JOIN_TYPE_LEFT;
3434
3434
            $$=$6;
3435
3435
          }
3442
3442
            /* Change the current name resolution context to a local context. */
3443
3443
            if (push_new_name_resolution_context(YYSession, $1, $5))
3444
3444
              DRIZZLE_YYABORT;
3445
 
            Lex->current_select->parsing_place= IN_ON;
 
3445
            Lex.current_select->parsing_place= IN_ON;
3446
3446
          }
3447
3447
          expr
3448
3448
          {
3449
 
            if (!($$= Lex->current_select->convert_right_join()))
 
3449
            if (!($$= Lex.current_select->convert_right_join()))
3450
3450
              DRIZZLE_YYABORT;
3451
3451
            add_join_on($$, $8);
3452
 
            Lex->pop_context();
3453
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3452
            Lex.pop_context();
 
3453
            Lex.current_select->parsing_place= NO_MATTER;
3454
3454
          }
3455
3455
        | table_ref RIGHT opt_outer JOIN_SYM table_factor
3456
3456
          {
3458
3458
          }
3459
3459
          USING '(' using_list ')'
3460
3460
          {
3461
 
            if (!($$= Lex->current_select->convert_right_join()))
 
3461
            if (!($$= Lex.current_select->convert_right_join()))
3462
3462
              DRIZZLE_YYABORT;
3463
 
            add_join_natural($$,$5,$9,Lex->current_select);
 
3463
            add_join_natural($$,$5,$9,Lex.current_select);
3464
3464
          }
3465
3465
        | table_ref NATURAL RIGHT opt_outer JOIN_SYM table_factor
3466
3466
          {
3467
3467
            DRIZZLE_YYABORT_UNLESS($1 && $6);
3468
 
            add_join_natural($6,$1,NULL,Lex->current_select);
3469
 
            if (!($$= Lex->current_select->convert_right_join()))
 
3468
            add_join_natural($6,$1,NULL,Lex.current_select);
 
3469
            if (!($$= Lex.current_select->convert_right_join()))
3470
3470
              DRIZZLE_YYABORT;
3471
3471
          }
3472
3472
        ;
3476
3476
        | INNER_SYM JOIN_SYM {}
3477
3477
        | CROSS JOIN_SYM
3478
3478
          {
3479
 
            Lex->is_cross= true;
3480
 
            Lex->current_select->is_cross= true;
 
3479
            Lex.is_cross= true;
 
3480
            Lex.current_select->is_cross= true;
3481
3481
          }
3482
3482
        ;
3483
3483
 
3487
3487
 
3488
3488
   I.e.
3489
3489
   <table factor> ::= <table primary> [ <sample clause> ]
3490
 
*/  
 
3490
*/
3491
3491
/* Warning - may return NULL in case of incomplete SELECT */
3492
3492
table_factor:
3493
3493
          {
3494
3494
          }
3495
3495
          table_ident opt_table_alias opt_key_definition
3496
3496
          {
3497
 
            if (!($$= Lex->current_select->add_table_to_list(YYSession, $2, $3,
 
3497
            if (!($$= Lex.current_select->add_table_to_list(YYSession, $2, $3,
3498
3498
                             0,
3499
 
                             Lex->lock_option,
3500
 
                             Lex->current_select->pop_index_hints())))
 
3499
                             Lex.lock_option,
 
3500
                             Lex.current_select->pop_index_hints())))
3501
3501
              DRIZZLE_YYABORT;
3502
 
            Lex->current_select->add_joined_table($$);
 
3502
            Lex.current_select->add_joined_table($$);
3503
3503
          }
3504
3504
        | select_derived_init get_select_lex select_derived2
3505
3505
          {
3506
 
            Select_Lex *sel= Lex->current_select;
 
3506
            Select_Lex *sel= Lex.current_select;
3507
3507
            if ($1)
3508
3508
            {
3509
3509
              if (sel->set_braces(1))
3516
3516
                sel->master_unit()->global_parameters=
3517
3517
                   sel->master_unit()->fake_select_lex;
3518
3518
            }
3519
 
            if ($2->init_nested_join(Lex->session))
 
3519
            if ($2->init_nested_join(Lex.session))
3520
3520
              DRIZZLE_YYABORT;
3521
3521
            $$= 0;
3522
3522
            /* incomplete derived tables return NULL, we must be
3526
3526
            Represents a flattening of the following rules from the SQL:2003
3527
3527
            standard. This sub-rule corresponds to the sub-rule
3528
3528
            <table primary> ::= ... | <derived table> [ AS ] <correlation name>
3529
 
           
 
3529
 
3530
3530
            The following rules have been flattened into query_expression_body
3531
3531
            (since we have no <with clause>).
3532
3532
 
3542
3542
          */
3543
3543
        | '(' get_select_lex select_derived_union ')' opt_table_alias
3544
3544
          {
3545
 
            /* Use $2 instead of Lex->current_select as derived table will
3546
 
               alter value of Lex->current_select. */
 
3545
            /* Use $2 instead of Lex.current_select as derived table will
 
3546
               alter value of Lex.current_select. */
3547
3547
            if (!($3 || $5) && $2->embedding &&
3548
3548
                !$2->embedding->getNestedJoin()->join_list.size())
3549
3549
            {
3558
3558
              /* Handle case of derived table, alias may be NULL if there
3559
3559
                 are no outer parentheses, add_table_to_list() will throw
3560
3560
                 error in this case */
3561
 
              Select_Lex *sel= Lex->current_select;
 
3561
              Select_Lex *sel= Lex.current_select;
3562
3562
              Select_Lex_Unit *unit= sel->master_unit();
3563
 
              Lex->current_select= sel= unit->outer_select();
3564
 
              if (!($$= sel->add_table_to_list(Lex->session,
 
3563
              Lex.current_select= sel= unit->outer_select();
 
3564
              if (!($$= sel->add_table_to_list(Lex.session,
3565
3565
                                               new Table_ident(unit), $5, 0,
3566
3566
                                               TL_READ)))
3567
3567
 
3568
3568
                DRIZZLE_YYABORT;
3569
3569
              sel->add_joined_table($$);
3570
 
              Lex->pop_context();
 
3570
              Lex.pop_context();
3571
3571
            }
3572
3572
            else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3573
3573
            {
3586
3586
          UNION_SYM
3587
3587
          union_option
3588
3588
          {
3589
 
            if (parser::add_select_to_union_list(YYSession, Lex, (bool)$3))
 
3589
            if (parser::add_select_to_union_list(YYSession, &Lex, (bool)$3))
3590
3590
              DRIZZLE_YYABORT;
3591
3591
          }
3592
3592
          query_specification
3595
3595
              Remove from the name resolution context stack the context of the
3596
3596
              last select in the union.
3597
3597
             */
3598
 
            Lex->pop_context();
 
3598
            Lex.pop_context();
3599
3599
          }
3600
3600
          opt_order_clause opt_limit_clause
3601
3601
        ;
3604
3604
select_init2_derived:
3605
3605
          select_part2_derived
3606
3606
          {
3607
 
            Select_Lex * sel= Lex->current_select;
3608
 
            if (Lex->current_select->set_braces(0))
 
3607
            Select_Lex * sel= Lex.current_select;
 
3608
            if (Lex.current_select->set_braces(0))
3609
3609
            {
3610
3610
              parser::my_parse_error(YYSession->m_lip);
3611
3611
              DRIZZLE_YYABORT;
3622
3622
/* The equivalent of select_part2 for nested queries. */
3623
3623
select_part2_derived:
3624
3624
          {
3625
 
            Select_Lex *sel= Lex->current_select;
 
3625
            Select_Lex *sel= Lex.current_select;
3626
3626
            if (sel->linkage != UNION_TYPE)
3627
 
              init_select(Lex);
3628
 
            Lex->current_select->parsing_place= SELECT_LIST;
 
3627
              init_select(&Lex);
 
3628
            Lex.current_select->parsing_place= SELECT_LIST;
3629
3629
          }
3630
3630
          select_options select_item_list
3631
3631
          {
3632
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3632
            Lex.current_select->parsing_place= NO_MATTER;
3633
3633
          }
3634
3634
          opt_select_from select_lock_type
3635
3635
        ;
3638
3638
select_derived:
3639
3639
          get_select_lex
3640
3640
          {
3641
 
            if ($1->init_nested_join(Lex->session))
 
3641
            if ($1->init_nested_join(Lex.session))
3642
3642
              DRIZZLE_YYABORT;
3643
3643
          }
3644
3644
          derived_table_list
3646
3646
            /* for normal joins, $3 != NULL and end_nested_join() != NULL,
3647
3647
               for derived tables, both must equal NULL */
3648
3648
 
3649
 
            if (!($$= $1->end_nested_join(Lex->session)) && $3)
 
3649
            if (!($$= $1->end_nested_join(Lex.session)) && $3)
3650
3650
              DRIZZLE_YYABORT;
3651
3651
 
3652
3652
            if (!$3 && $$)
3659
3659
 
3660
3660
select_derived2:
3661
3661
          {
3662
 
            Lex->derived_tables|= DERIVED_SUBQUERY;
3663
 
            if (not Lex->expr_allows_subselect)
 
3662
            Lex.derived_tables|= DERIVED_SUBQUERY;
 
3663
            if (not Lex.expr_allows_subselect)
3664
3664
            {
3665
3665
              parser::my_parse_error(YYSession->m_lip);
3666
3666
              DRIZZLE_YYABORT;
3667
3667
            }
3668
 
            if (Lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || new_select(Lex, 1))
 
3668
            if (Lex.current_select->linkage == GLOBAL_OPTIONS_TYPE || new_select(&Lex, 1))
3669
3669
              DRIZZLE_YYABORT;
3670
 
            init_select(Lex);
3671
 
            Lex->current_select->linkage= DERIVED_TABLE_TYPE;
3672
 
            Lex->current_select->parsing_place= SELECT_LIST;
 
3670
            init_select(&Lex);
 
3671
            Lex.current_select->linkage= DERIVED_TABLE_TYPE;
 
3672
            Lex.current_select->parsing_place= SELECT_LIST;
3673
3673
          }
3674
3674
          select_options select_item_list
3675
3675
          {
3676
 
            Lex->current_select->parsing_place= NO_MATTER;
 
3676
            Lex.current_select->parsing_place= NO_MATTER;
3677
3677
          }
3678
3678
          opt_select_from
3679
3679
        ;
3680
3680
 
3681
3681
get_select_lex:
3682
 
          /* Empty */ { $$= Lex->current_select; }
 
3682
          /* Empty */ { $$= Lex.current_select; }
3683
3683
        ;
3684
3684
 
3685
3685
select_derived_init:
3686
3686
          SELECT_SYM
3687
3687
          {
3688
 
            Select_Lex *sel= Lex->current_select;
 
3688
            Select_Lex *sel= Lex.current_select;
3689
3689
            TableList *embedding;
3690
 
            if (!sel->embedding || sel->end_nested_join(Lex->session))
 
3690
            if (!sel->embedding || sel->end_nested_join(Lex.session))
3691
3691
            {
3692
3692
              /* we are not in parentheses */
3693
3693
              parser::my_parse_error(YYSession->m_lip);
3694
3694
              DRIZZLE_YYABORT;
3695
3695
            }
3696
 
            embedding= Lex->current_select->embedding;
 
3696
            embedding= Lex.current_select->embedding;
3697
3697
            $$= embedding &&
3698
3698
                !embedding->getNestedJoin()->join_list.size();
3699
3699
            /* return true if we are deeply nested */
3723
3723
index_hint_definition:
3724
3724
          index_hint_type key_or_index index_hint_clause
3725
3725
          {
3726
 
            Lex->current_select->set_index_hint_type($1, $3);
 
3726
            Lex.current_select->set_index_hint_type($1, $3);
3727
3727
          }
3728
3728
          '(' key_usage_list ')'
3729
3729
        | USE_SYM key_or_index index_hint_clause
3730
3730
          {
3731
 
            Lex->current_select->set_index_hint_type(INDEX_HINT_USE, $3);
 
3731
            Lex.current_select->set_index_hint_type(INDEX_HINT_USE, $3);
3732
3732
          }
3733
3733
          '(' opt_key_usage_list ')'
3734
3734
       ;
3740
3740
 
3741
3741
opt_index_hints_list:
3742
3742
          /* empty */
3743
 
        | { Lex->current_select->alloc_index_hints(YYSession); } index_hints_list
 
3743
        | { Lex.current_select->alloc_index_hints(YYSession); } index_hints_list
3744
3744
        ;
3745
3745
 
3746
3746
opt_key_definition:
3747
 
          {  Lex->current_select->clear_index_hints(); }
 
3747
          {  Lex.current_select->clear_index_hints(); }
3748
3748
          opt_index_hints_list
3749
3749
        ;
3750
3750
 
3751
3751
opt_key_usage_list:
3752
 
          /* empty */ { Lex->current_select->add_index_hint(YYSession, NULL, 0); }
 
3752
          /* empty */ { Lex.current_select->add_index_hint(YYSession, NULL, 0); }
3753
3753
        | key_usage_list {}
3754
3754
        ;
3755
3755
 
3756
3756
key_usage_element:
3757
3757
          ident
3758
 
          { Lex->current_select->add_index_hint(YYSession, $1.str, $1.length); }
 
3758
          { Lex.current_select->add_index_hint(YYSession, $1.str, $1.length); }
3759
3759
        | PRIMARY_SYM
3760
 
          { Lex->current_select->add_index_hint(YYSession, (char *)"PRIMARY", 7); }
 
3760
          { Lex.current_select->add_index_hint(YYSession, (char *)"PRIMARY", 7); }
3761
3761
        ;
3762
3762
 
3763
3763
key_usage_list:
3848
3848
        ;
3849
3849
 
3850
3850
where_clause:
3851
 
          /* empty */  { Lex->current_select->where= 0; }
 
3851
          /* empty */  { Lex.current_select->where= 0; }
3852
3852
        | WHERE
3853
3853
          {
3854
 
            Lex->current_select->parsing_place= IN_WHERE;
 
3854
            Lex.current_select->parsing_place= IN_WHERE;
3855
3855
          }
3856
3856
          expr
3857
3857
          {
3858
 
            Select_Lex *select= Lex->current_select;
 
3858
            Select_Lex *select= Lex.current_select;
3859
3859
            select->where= $3;
3860
3860
            select->parsing_place= NO_MATTER;
3861
3861
            if ($3)
3867
3867
          /* empty */
3868
3868
        | HAVING
3869
3869
          {
3870
 
            Lex->current_select->parsing_place= IN_HAVING;
 
3870
            Lex.current_select->parsing_place= IN_HAVING;
3871
3871
          }
3872
3872
          expr
3873
3873
          {
3874
 
            Select_Lex *sel= Lex->current_select;
 
3874
            Select_Lex *sel= Lex.current_select;
3875
3875
            sel->having= $3;
3876
3876
            sel->parsing_place= NO_MATTER;
3877
3877
            if ($3)
3882
3882
opt_escape:
3883
3883
          ESCAPE_SYM simple_expr
3884
3884
          {
3885
 
            Lex->escape_used= true;
 
3885
            Lex.escape_used= true;
3886
3886
            $$= $2;
3887
3887
          }
3888
3888
        | /* empty */
3889
3889
          {
3890
 
            Lex->escape_used= false;
 
3890
            Lex.escape_used= false;
3891
3891
            $$= new Item_string("\\", 1, &my_charset_utf8_general_ci);
3892
3892
          }
3893
3893
        ;
3919
3919
              MySQL syntax: GROUP BY col1, col2, col3 WITH ROLLUP
3920
3920
              SQL-2003: GROUP BY ... ROLLUP(col1, col2, col3)
3921
3921
            */
3922
 
            if (Lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
 
3922
            if (Lex.current_select->linkage == GLOBAL_OPTIONS_TYPE)
3923
3923
            {
3924
3924
              my_error(ER_WRONG_USAGE, MYF(0), "WITH ROLLUP",
3925
3925
                       "global union parameters");
3926
3926
              DRIZZLE_YYABORT;
3927
3927
            }
3928
 
            Lex->current_select->olap= ROLLUP_TYPE;
 
3928
            Lex.current_select->olap= ROLLUP_TYPE;
3929
3929
          }
3930
3930
        ;
3931
3931
 
3963
3963
order_clause:
3964
3964
          ORDER_SYM BY
3965
3965
          {
3966
 
            if (not parser::buildOrderBy(Lex))
 
3966
            if (not parser::buildOrderBy(&Lex))
3967
3967
              DRIZZLE_YYABORT;
3968
3968
          }
3969
3969
          order_list
3991
3991
opt_limit_clause_init:
3992
3992
          /* empty */
3993
3993
          {
3994
 
            Select_Lex *sel= Lex->current_select;
 
3994
            Select_Lex *sel= Lex.current_select;
3995
3995
            sel->offset_limit= 0;
3996
3996
            sel->select_limit= 0;
3997
3997
          }
4010
4010
limit_options:
4011
4011
          limit_option
4012
4012
          {
4013
 
            Select_Lex *sel= Lex->current_select;
 
4013
            Select_Lex *sel= Lex.current_select;
4014
4014
            sel->select_limit= $1;
4015
4015
            sel->offset_limit= 0;
4016
4016
            sel->explicit_limit= 1;
4017
4017
          }
4018
4018
        | limit_option ',' limit_option
4019
4019
          {
4020
 
            Select_Lex *sel= Lex->current_select;
 
4020
            Select_Lex *sel= Lex.current_select;
4021
4021
            sel->select_limit= $3;
4022
4022
            sel->offset_limit= $1;
4023
4023
            sel->explicit_limit= 1;
4024
4024
          }
4025
4025
        | limit_option OFFSET_SYM limit_option
4026
4026
          {
4027
 
            Select_Lex *sel= Lex->current_select;
 
4027
            Select_Lex *sel= Lex.current_select;
4028
4028
            sel->select_limit= $1;
4029
4029
            sel->offset_limit= $3;
4030
4030
            sel->explicit_limit= 1;
4040
4040
delete_limit_clause:
4041
4041
          /* empty */
4042
4042
          {
4043
 
            Lex->current_select->select_limit= 0;
 
4043
            Lex.current_select->select_limit= 0;
4044
4044
          }
4045
4045
        | LIMIT limit_option
4046
4046
          {
4047
 
            Select_Lex *sel= Lex->current_select;
 
4047
            Select_Lex *sel= Lex.current_select;
4048
4048
            sel->select_limit= $2;
4049
4049
            sel->explicit_limit= 1;
4050
4050
          }
4069
4069
 
4070
4070
select_var_list_init:
4071
4071
          {
4072
 
            if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
 
4072
            if (not Lex.describe && (not (Lex.result= new select_dumpvar())))
4073
4073
              DRIZZLE_YYABORT;
4074
4074
          }
4075
4075
          select_var_list
4081
4081
        | select_var_ident {}
4082
4082
        ;
4083
4083
 
4084
 
select_var_ident: 
 
4084
select_var_ident:
4085
4085
          '@' user_variable_ident
4086
4086
          {
4087
 
            if (Lex->result)
 
4087
            if (Lex.result)
4088
4088
            {
4089
 
              ((select_dumpvar *)Lex->result)->var_list.push_back( new var($2,0,0,(enum_field_types)0));
 
4089
              ((select_dumpvar *)Lex.result)->var_list.push_back( new var($2,0,0,(enum_field_types)0));
4090
4090
            }
4091
4091
            else
4092
4092
            {
4094
4094
                The parser won't create select_result instance only
4095
4095
                if it's an EXPLAIN.
4096
4096
              */
4097
 
              assert(Lex->describe);
 
4097
              assert(Lex.describe);
4098
4098
            }
4099
4099
          }
4100
4100
        ;
4108
4108
into_destination:
4109
4109
          OUTFILE TEXT_STRING_filesystem
4110
4110
          {
4111
 
            Lex->setCacheable(false);
4112
 
            if (!(Lex->exchange= new file_exchange($2.str, 0)) ||
4113
 
                !(Lex->result= new select_export(Lex->exchange)))
 
4111
            Lex.setCacheable(false);
 
4112
            if (!(Lex.exchange= new file_exchange($2.str, 0)) ||
 
4113
                !(Lex.result= new select_export(Lex.exchange)))
4114
4114
              DRIZZLE_YYABORT;
4115
4115
          }
4116
4116
          opt_field_term opt_line_term
4117
4117
        | DUMPFILE TEXT_STRING_filesystem
4118
4118
          {
4119
 
            if (not Lex->describe)
 
4119
            if (not Lex.describe)
4120
4120
            {
4121
 
              Lex->setCacheable(false);
4122
 
              if (not (Lex->exchange= new file_exchange($2.str,1)))
 
4121
              Lex.setCacheable(false);
 
4122
              if (not (Lex.exchange= new file_exchange($2.str,1)))
4123
4123
                DRIZZLE_YYABORT;
4124
 
              if (not (Lex->result= new select_dump(Lex->exchange)))
 
4124
              if (not (Lex.result= new select_dump(Lex.exchange)))
4125
4125
                DRIZZLE_YYABORT;
4126
4126
            }
4127
4127
          }
4128
4128
        | select_var_list_init
4129
 
          {Lex->setCacheable(false);}
 
4129
          {Lex.setCacheable(false);}
4130
4130
        ;
4131
4131
 
4132
4132
/*
4136
4136
drop:
4137
4137
          DROP CATALOG_SYM catalog_name
4138
4138
          {
4139
 
            Lex->statement= new statement::catalog::Drop(YYSession, $3);
 
4139
            Lex.statement= new statement::catalog::Drop(YYSession, $3);
4140
4140
          }
4141
4141
        | DROP opt_temporary table_or_tables if_exists table_list
4142
4142
          {
4143
4143
            statement::DropTable *statement= new statement::DropTable(YYSession);
4144
 
            Lex->statement= statement;
 
4144
            Lex.statement= statement;
4145
4145
            statement->drop_temporary= $2;
4146
4146
            statement->drop_if_exists= $4;
4147
4147
          }
4148
4148
        | DROP build_method INDEX_SYM ident ON table_ident {}
4149
4149
          {
4150
4150
            statement::DropIndex *statement= new statement::DropIndex(YYSession);
4151
 
            Lex->statement= statement;
 
4151
            Lex.statement= statement;
4152
4152
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
4153
4153
            statement->alter_info.build_method= $2;
4154
4154
            statement->alter_info.drop_list.push_back(AlterDrop(AlterDrop::KEY, $4.str));
4155
 
            if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
 
4155
            if (not Lex.current_select->add_table_to_list(Lex.session, $6, NULL,
4156
4156
                                                          TL_OPTION_UPDATING))
4157
4157
              DRIZZLE_YYABORT;
4158
4158
          }
4159
4159
        | DROP DATABASE if_exists schema_name
4160
4160
          {
4161
4161
            statement::DropSchema *statement= new statement::DropSchema(YYSession);
4162
 
            Lex->statement= statement;
 
4162
            Lex.statement= statement;
4163
4163
            statement->drop_if_exists=$3;
4164
 
            Lex->name= $4;
 
4164
            Lex.name= $4;
4165
4165
          }
4166
4166
        ;
4167
4167
 
4173
4173
table_name:
4174
4174
          table_ident
4175
4175
          {
4176
 
            if (!Lex->current_select->add_table_to_list(YYSession, $1, NULL, TL_OPTION_UPDATING))
 
4176
            if (!Lex.current_select->add_table_to_list(YYSession, $1, NULL, TL_OPTION_UPDATING))
4177
4177
              DRIZZLE_YYABORT;
4178
4178
          }
4179
4179
        ;
4195
4195
execute:
4196
4196
       EXECUTE_SYM execute_var_or_string opt_status opt_concurrent opt_wait
4197
4197
        {
4198
 
          Lex->statement= new statement::Execute(YYSession, $2, $3, $4, $5);
 
4198
          Lex.statement= new statement::Execute(YYSession, $2, $3, $4, $5);
4199
4199
        }
4200
4200
 
4201
4201
 
4231
4231
insert:
4232
4232
          INSERT
4233
4233
          {
4234
 
            Lex->statement= new statement::Insert(YYSession);
4235
 
            Lex->duplicates= DUP_ERROR;
4236
 
            init_select(Lex);
 
4234
            Lex.statement= new statement::Insert(YYSession);
 
4235
            Lex.duplicates= DUP_ERROR;
 
4236
            init_select(&Lex);
4237
4237
            /* for subselects */
4238
 
            Lex->lock_option= TL_READ;
 
4238
            Lex.lock_option= TL_READ;
4239
4239
          }
4240
4240
          opt_ignore insert2
4241
4241
          {
4242
 
            Lex->current_select->set_lock_for_tables(TL_WRITE_CONCURRENT_INSERT);
4243
 
            Lex->current_select= &Lex->select_lex;
 
4242
            Lex.current_select->set_lock_for_tables(TL_WRITE_CONCURRENT_INSERT);
 
4243
            Lex.current_select= &Lex.select_lex;
4244
4244
          }
4245
4245
          insert_field_spec opt_insert_update
4246
4246
          {}
4249
4249
replace:
4250
4250
          REPLACE
4251
4251
          {
4252
 
            Lex->statement= new statement::Replace(YYSession);
4253
 
            Lex->duplicates= DUP_REPLACE;
4254
 
            init_select(Lex);
 
4252
            Lex.statement= new statement::Replace(YYSession);
 
4253
            Lex.duplicates= DUP_REPLACE;
 
4254
            init_select(&Lex);
4255
4255
          }
4256
4256
          insert2
4257
4257
          {
4258
 
            Lex->current_select->set_lock_for_tables(TL_WRITE_DEFAULT);
4259
 
            Lex->current_select= &Lex->select_lex;
 
4258
            Lex.current_select->set_lock_for_tables(TL_WRITE_DEFAULT);
 
4259
            Lex.current_select= &Lex.select_lex;
4260
4260
          }
4261
4261
          insert_field_spec
4262
4262
          {}
4270
4270
insert_table:
4271
4271
          table_name
4272
4272
          {
4273
 
            Lex->field_list.clear();
4274
 
            Lex->many_values.clear();
4275
 
            Lex->insert_list=0;
 
4273
            Lex.field_list.clear();
 
4274
            Lex.many_values.clear();
 
4275
            Lex.insert_list=0;
4276
4276
          };
4277
4277
 
4278
4278
insert_field_spec:
4281
4281
        | '(' fields ')' insert_values {}
4282
4282
        | SET_SYM
4283
4283
          {
4284
 
            if (not (Lex->insert_list = new List_item) ||
4285
 
                Lex->many_values.push_back(Lex->insert_list))
 
4284
            if (not (Lex.insert_list = new List_item) ||
 
4285
                Lex.many_values.push_back(Lex.insert_list))
4286
4286
              DRIZZLE_YYABORT;
4287
4287
          }
4288
4288
          ident_eq_list
4289
4289
        ;
4290
4290
 
4291
4291
fields:
4292
 
          fields ',' insert_ident { Lex->field_list.push_back($3); }
4293
 
        | insert_ident { Lex->field_list.push_back($1); }
 
4292
          fields ',' insert_ident { Lex.field_list.push_back($3); }
 
4293
        | insert_ident { Lex.field_list.push_back($1); }
4294
4294
        ;
4295
4295
 
4296
4296
insert_values:
4298
4298
        | VALUE_SYM values_list {}
4299
4299
        | stored_select
4300
4300
          {
4301
 
            Lex->current_select->set_braces(0);
 
4301
            Lex.current_select->set_braces(0);
4302
4302
          }
4303
4303
          union_clause {}
4304
4304
        | '(' stored_select ')'
4305
4305
          {
4306
 
            Lex->current_select->set_braces(1);
 
4306
            Lex.current_select->set_braces(1);
4307
4307
          }
4308
4308
          union_opt {}
4309
4309
        ;
4321
4321
ident_eq_value:
4322
4322
          simple_ident equal expr_or_default
4323
4323
          {
4324
 
            if (Lex->field_list.push_back($1) ||
4325
 
                Lex->insert_list->push_back($3))
 
4324
            if (Lex.field_list.push_back($1) ||
 
4325
                Lex.insert_list->push_back($3))
4326
4326
              DRIZZLE_YYABORT;
4327
4327
          }
4328
4328
        ;
4340
4340
no_braces:
4341
4341
          '('
4342
4342
          {
4343
 
              if (!(Lex->insert_list = new List_item))
 
4343
              if (!(Lex.insert_list = new List_item))
4344
4344
                DRIZZLE_YYABORT;
4345
4345
          }
4346
4346
          opt_values ')'
4347
4347
          {
4348
 
            if (Lex->many_values.push_back(Lex->insert_list))
 
4348
            if (Lex.many_values.push_back(Lex.insert_list))
4349
4349
              DRIZZLE_YYABORT;
4350
4350
          }
4351
4351
        ;
4358
4358
values:
4359
4359
          values ','  expr_or_default
4360
4360
          {
4361
 
            if (Lex->insert_list->push_back($3))
 
4361
            if (Lex.insert_list->push_back($3))
4362
4362
              DRIZZLE_YYABORT;
4363
4363
          }
4364
4364
        | expr_or_default
4365
4365
          {
4366
 
            if (Lex->insert_list->push_back($1))
 
4366
            if (Lex.insert_list->push_back($1))
4367
4367
              DRIZZLE_YYABORT;
4368
4368
          }
4369
4369
        ;
4370
4370
 
4371
4371
expr_or_default:
4372
4372
          expr { $$= $1;}
4373
 
        | DEFAULT {$$= new Item_default_value(Lex->current_context()); }
 
4373
        | DEFAULT {$$= new Item_default_value(Lex.current_context()); }
4374
4374
        ;
4375
4375
 
4376
4376
opt_insert_update:
4377
4377
          /* empty */
4378
 
        | ON DUPLICATE_SYM { Lex->duplicates= DUP_UPDATE; }
 
4378
        | ON DUPLICATE_SYM { Lex.duplicates= DUP_UPDATE; }
4379
4379
          KEY_SYM UPDATE_SYM insert_update_list
4380
4380
        ;
4381
4381
 
4384
4384
update:
4385
4385
          UPDATE_SYM opt_ignore table_ident SET_SYM update_list
4386
4386
          {
4387
 
            init_select(Lex);
4388
 
            Lex->statement= new statement::Update(YYSession);
4389
 
            Lex->lock_option= TL_UNLOCK; /* Will be set later */
4390
 
            Lex->duplicates= DUP_ERROR;
4391
 
            if (not Lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
 
4387
            init_select(&Lex);
 
4388
            Lex.statement= new statement::Update(YYSession);
 
4389
            Lex.lock_option= TL_UNLOCK; /* Will be set later */
 
4390
            Lex.duplicates= DUP_ERROR;
 
4391
            if (not Lex.select_lex.add_table_to_list(YYSession, $3, NULL,0))
4392
4392
              DRIZZLE_YYABORT;
4393
4393
 
4394
 
            if (Lex->select_lex.get_table_list()->derived)
 
4394
            if (Lex.select_lex.get_table_list()->derived)
4395
4395
            {
4396
4396
              /* it is single table update and it is update of derived table */
4397
4397
              my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
4398
 
                       Lex->select_lex.get_table_list()->alias, "UPDATE");
 
4398
                       Lex.select_lex.get_table_list()->alias, "UPDATE");
4399
4399
              DRIZZLE_YYABORT;
4400
4400
            }
4401
4401
            /*
4403
4403
              be too pessimistic. We will decrease lock level if possible in
4404
4404
              multi_update().
4405
4405
            */
4406
 
            Lex->current_select->set_lock_for_tables(TL_WRITE_DEFAULT);
 
4406
            Lex.current_select->set_lock_for_tables(TL_WRITE_DEFAULT);
4407
4407
          }
4408
4408
          where_clause opt_order_clause delete_limit_clause {}
4409
4409
        ;
4429
4429
insert_update_elem:
4430
4430
          simple_ident equal expr_or_default
4431
4431
          {
4432
 
          if (Lex->update_list.push_back($1) ||
4433
 
              Lex->value_list.push_back($3))
 
4432
          if (Lex.update_list.push_back($1) ||
 
4433
              Lex.value_list.push_back($3))
4434
4434
              DRIZZLE_YYABORT;
4435
4435
          }
4436
4436
        ;
4440
4440
delete:
4441
4441
          DELETE_SYM opt_delete_option FROM table_ident
4442
4442
          {
4443
 
            Lex->statement= new statement::Delete(YYSession);
4444
 
            init_select(Lex);
4445
 
            Lex->lock_option= TL_WRITE_DEFAULT;
4446
 
            Lex->select_lex.init_order();
 
4443
            Lex.statement= new statement::Delete(YYSession);
 
4444
            init_select(&Lex);
 
4445
            Lex.lock_option= TL_WRITE_DEFAULT;
 
4446
            Lex.select_lex.init_order();
4447
4447
 
4448
 
            if (!Lex->current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING,
4449
 
                                           Lex->lock_option))
 
4448
            if (!Lex.current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING,
 
4449
                                           Lex.lock_option))
4450
4450
              DRIZZLE_YYABORT;
4451
4451
          }
4452
4452
          where_clause opt_order_clause
4454
4454
        ;
4455
4455
 
4456
4456
opt_delete_option:
4457
 
           /* empty */ { Lex->ignore= 0; }
4458
 
         | IGNORE_SYM  { Lex->ignore= 1; }
 
4457
           /* empty */ { Lex.ignore= 0; }
 
4458
         | IGNORE_SYM  { Lex.ignore= 1; }
4459
4459
        ;
4460
4460
 
4461
4461
truncate:
4462
4462
          TRUNCATE_SYM opt_table_sym table_name
4463
4463
          {
4464
 
            Lex->statement= new statement::Truncate(YYSession);
4465
 
            Lex->select_lex.options= 0;
4466
 
            Lex->select_lex.init_order();
 
4464
            Lex.statement= new statement::Truncate(YYSession);
 
4465
            Lex.select_lex.options= 0;
 
4466
            Lex.select_lex.init_order();
4467
4467
          }
4468
4468
        ;
4469
4469
 
4477
4477
show:
4478
4478
          SHOW
4479
4479
          {
4480
 
            Lex->lock_option= TL_READ;
4481
 
            init_select(Lex);
4482
 
            Lex->current_select->parsing_place= SELECT_LIST;
 
4480
            Lex.lock_option= TL_READ;
 
4481
            init_select(&Lex);
 
4482
            Lex.current_select->parsing_place= SELECT_LIST;
4483
4483
          }
4484
4484
          show_param
4485
4485
          {}
4583
4583
          /* empty */
4584
4584
        | LIKE TEXT_STRING_sys
4585
4585
          {
4586
 
            Lex->wild= new (YYSession->mem_root) String($2.str, $2.length,
 
4586
            Lex.wild= new (YYSession->mem_root) String($2.str, $2.length,
4587
4587
                                                    system_charset_info);
4588
 
            if (Lex->wild == NULL)
 
4588
            if (Lex.wild == NULL)
4589
4589
              DRIZZLE_YYABORT;
4590
4590
          }
4591
4591
        | WHERE expr
4592
4592
          {
4593
 
            Lex->current_select->where= $2;
 
4593
            Lex.current_select->where= $2;
4594
4594
            if ($2)
4595
4595
              $2->top_level_item();
4596
4596
          }
4607
4607
          }
4608
4608
          opt_describe_column {}
4609
4609
        | describe_command opt_extended_describe
4610
 
          { Lex->describe|= DESCRIBE_NORMAL; }
 
4610
          { Lex.describe|= DESCRIBE_NORMAL; }
4611
4611
          select
4612
4612
          {
4613
 
            Lex->select_lex.options|= SELECT_DESCRIBE;
 
4613
            Lex.select_lex.options|= SELECT_DESCRIBE;
4614
4614
          }
4615
4615
        ;
4616
4616
 
4621
4621
 
4622
4622
opt_extended_describe:
4623
4623
          /* empty */ {}
4624
 
        | EXTENDED_SYM   { Lex->describe|= DESCRIBE_EXTENDED; }
 
4624
        | EXTENDED_SYM   { Lex.describe|= DESCRIBE_EXTENDED; }
4625
4625
        ;
4626
4626
 
4627
4627
opt_describe_column:
4628
4628
          /* empty */ {}
4629
 
        | text_string { Lex->wild= $1; }
 
4629
        | text_string { Lex.wild= $1; }
4630
4630
        | ident
4631
4631
          {
4632
 
            Lex->wild= new (YYSession->mem_root) String((const char*) $1.str,
 
4632
            Lex.wild= new (YYSession->mem_root) String((const char*) $1.str,
4633
4633
                                                    $1.length,
4634
4634
                                                    system_charset_info);
4635
4635
          }
4641
4641
flush:
4642
4642
          FLUSH_SYM
4643
4643
          {
4644
 
            Lex->statement= new statement::Flush(YYSession);
 
4644
            Lex.statement= new statement::Flush(YYSession);
4645
4645
          }
4646
4646
          flush_options
4647
4647
          {}
4655
4655
flush_option:
4656
4656
          table_or_tables
4657
4657
          {
4658
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
 
4658
            statement::Flush *statement= (statement::Flush*)Lex.statement;
4659
4659
            statement->setFlushTables(true);
4660
4660
          }
4661
4661
          opt_table_list {}
4662
4662
        | TABLES WITH READ_SYM LOCK_SYM
4663
4663
          {
4664
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
 
4664
            statement::Flush *statement= (statement::Flush*)Lex.statement;
4665
4665
            statement->setFlushTablesWithReadLock(true);
4666
4666
          }
4667
4667
        | LOGS_SYM
4668
4668
          {
4669
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
 
4669
            statement::Flush *statement= (statement::Flush*)Lex.statement;
4670
4670
            statement->setFlushLog(true);
4671
4671
          }
4672
4672
        | STATUS_SYM
4673
4673
          {
4674
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
 
4674
            statement::Flush *statement= (statement::Flush*)Lex.statement;
4675
4675
            statement->setFlushStatus(true);
4676
4676
          }
4677
4677
        | GLOBAL_SYM STATUS_SYM
4678
4678
          {
4679
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
 
4679
            statement::Flush *statement= (statement::Flush*)Lex.statement;
4680
4680
            statement->setFlushGlobalStatus(true);
4681
4681
          }
4682
4682
        ;
4691
4691
kill:
4692
4692
          KILL_SYM kill_option expr
4693
4693
          {
4694
 
            Lex->statement= new statement::Kill(YYSession, $3, $2);
 
4694
            Lex.statement= new statement::Kill(YYSession, $3, $2);
4695
4695
          }
4696
4696
        ;
4697
4697
 
4706
4706
use:
4707
4707
          USE_SYM schema_name
4708
4708
          {
4709
 
            Lex->statement= new statement::ChangeSchema(YYSession);
4710
 
            Lex->select_lex.db= $2.str;
 
4709
            Lex.statement= new statement::ChangeSchema(YYSession);
 
4710
            Lex.select_lex.db= $2.str;
4711
4711
          }
4712
4712
        ;
4713
4713
 
4717
4717
          LOAD data_file
4718
4718
          {
4719
4719
            statement::Load *statement= new statement::Load(YYSession);
4720
 
            Lex->statement= statement;
 
4720
            Lex.statement= statement;
4721
4721
 
4722
4722
            Lex_input_stream *lip= YYSession->m_lip;
4723
4723
            statement->fname_start= lip->get_ptr();
4724
4724
          }
4725
4725
          load_data_lock INFILE TEXT_STRING_filesystem
4726
4726
          {
4727
 
            Lex->lock_option= $4;
4728
 
            Lex->duplicates= DUP_ERROR;
4729
 
            Lex->ignore= 0;
4730
 
            if (not (Lex->exchange= new file_exchange($6.str, 0, $2)))
 
4727
            Lex.lock_option= $4;
 
4728
            Lex.duplicates= DUP_ERROR;
 
4729
            Lex.ignore= 0;
 
4730
            if (not (Lex.exchange= new file_exchange($6.str, 0, $2)))
4731
4731
              DRIZZLE_YYABORT;
4732
4732
          }
4733
4733
          opt_duplicate INTO
4734
4734
          {
4735
4735
            Lex_input_stream *lip= YYSession->m_lip;
4736
 
            ((statement::Load *)Lex->statement)->fname_end= lip->get_ptr();
 
4736
            ((statement::Load *)Lex.statement)->fname_end= lip->get_ptr();
4737
4737
          }
4738
4738
          TABLE_SYM table_ident
4739
4739
          {
4740
 
            if (!Lex->current_select->add_table_to_list(YYSession,
 
4740
            if (!Lex.current_select->add_table_to_list(YYSession,
4741
4741
                    $12, NULL, TL_OPTION_UPDATING,
4742
 
                    Lex->lock_option))
 
4742
                    Lex.lock_option))
4743
4743
              DRIZZLE_YYABORT;
4744
 
            Lex->field_list.clear();
4745
 
            Lex->update_list.clear();
4746
 
            Lex->value_list.clear();
 
4744
            Lex.field_list.clear();
 
4745
            Lex.update_list.clear();
 
4746
            Lex.value_list.clear();
4747
4747
          }
4748
4748
          opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
4749
4749
          opt_load_data_set_spec
4762
4762
        ;
4763
4763
 
4764
4764
opt_duplicate:
4765
 
          /* empty */ { Lex->duplicates=DUP_ERROR; }
4766
 
        | REPLACE { Lex->duplicates=DUP_REPLACE; }
4767
 
        | IGNORE_SYM { Lex->ignore= 1; }
 
4765
          /* empty */ { Lex.duplicates=DUP_ERROR; }
 
4766
        | REPLACE { Lex.duplicates=DUP_REPLACE; }
 
4767
        | IGNORE_SYM { Lex.ignore= 1; }
4768
4768
        ;
4769
4769
 
4770
4770
opt_duplicate_as:
4771
 
          /* empty */ { Lex->duplicates=DUP_ERROR; }
4772
 
        | AS { Lex->duplicates=DUP_ERROR; }
4773
 
        | REPLACE { Lex->duplicates=DUP_REPLACE; }
4774
 
        | IGNORE_SYM { Lex->ignore= true; }
4775
 
        | REPLACE AS { Lex->duplicates=DUP_REPLACE; }
4776
 
        | IGNORE_SYM AS { Lex->ignore= true; }
 
4771
          /* empty */ { Lex.duplicates=DUP_ERROR; }
 
4772
        | AS { Lex.duplicates=DUP_ERROR; }
 
4773
        | REPLACE { Lex.duplicates=DUP_REPLACE; }
 
4774
        | IGNORE_SYM { Lex.ignore= true; }
 
4775
        | REPLACE AS { Lex.duplicates=DUP_REPLACE; }
 
4776
        | IGNORE_SYM AS { Lex.ignore= true; }
4777
4777
        ;
4778
4778
 
4779
4779
opt_field_term:
4789
4789
field_term:
4790
4790
          TERMINATED BY text_string
4791
4791
          {
4792
 
            assert(Lex->exchange != 0);
4793
 
            Lex->exchange->field_term= $3;
 
4792
            assert(Lex.exchange != 0);
 
4793
            Lex.exchange->field_term= $3;
4794
4794
          }
4795
4795
        | OPTIONALLY ENCLOSED BY text_string
4796
4796
          {
4797
 
            assert(Lex->exchange != 0);
4798
 
            Lex->exchange->enclosed= $4;
4799
 
            Lex->exchange->opt_enclosed= 1;
 
4797
            assert(Lex.exchange != 0);
 
4798
            Lex.exchange->enclosed= $4;
 
4799
            Lex.exchange->opt_enclosed= 1;
4800
4800
          }
4801
4801
        | ENCLOSED BY text_string
4802
4802
          {
4803
 
            assert(Lex->exchange != 0);
4804
 
            Lex->exchange->enclosed= $3;
 
4803
            assert(Lex.exchange != 0);
 
4804
            Lex.exchange->enclosed= $3;
4805
4805
          }
4806
4806
        | ESCAPED BY text_string
4807
4807
          {
4808
 
            assert(Lex->exchange != 0);
4809
 
            Lex->exchange->escaped= $3;
 
4808
            assert(Lex.exchange != 0);
 
4809
            Lex.exchange->escaped= $3;
4810
4810
          }
4811
4811
        ;
4812
4812
 
4823
4823
line_term:
4824
4824
          TERMINATED BY text_string
4825
4825
          {
4826
 
            assert(Lex->exchange != 0);
4827
 
            Lex->exchange->line_term= $3;
 
4826
            assert(Lex.exchange != 0);
 
4827
            Lex.exchange->line_term= $3;
4828
4828
          }
4829
4829
        | STARTING BY text_string
4830
4830
          {
4831
 
            assert(Lex->exchange != 0);
4832
 
            Lex->exchange->line_start= $3;
 
4831
            assert(Lex.exchange != 0);
 
4832
            Lex.exchange->line_start= $3;
4833
4833
          }
4834
4834
        ;
4835
4835
 
4837
4837
          /* empty */
4838
4838
        | IGNORE_SYM NUM lines_or_rows
4839
4839
          {
4840
 
            assert(Lex->exchange != 0);
4841
 
            Lex->exchange->skip_lines= atol($2.str);
 
4840
            assert(Lex.exchange != 0);
 
4841
            Lex.exchange->skip_lines= atol($2.str);
4842
4842
          }
4843
4843
        ;
4844
4844
 
4855
4855
 
4856
4856
fields_or_vars:
4857
4857
          fields_or_vars ',' field_or_var
4858
 
          { Lex->field_list.push_back($3); }
 
4858
          { Lex.field_list.push_back($3); }
4859
4859
        | field_or_var
4860
 
          { Lex->field_list.push_back($1); }
 
4860
          { Lex.field_list.push_back($1); }
4861
4861
        ;
4862
4862
 
4863
4863
field_or_var:
5029
5029
table_wild:
5030
5030
          ident '.' '*'
5031
5031
          {
5032
 
            $$= parser::buildTableWild(Lex, NULL_LEX_STRING, $1);
 
5032
            $$= parser::buildTableWild(&Lex, NULL_LEX_STRING, $1);
5033
5033
          }
5034
5034
        | ident '.' ident '.' '*'
5035
5035
          {
5036
 
            $$= parser::buildTableWild(Lex, $1, $3);
 
5036
            $$= parser::buildTableWild(&Lex, $1, $3);
5037
5037
          }
5038
5038
        ;
5039
5039
 
5044
5044
simple_ident:
5045
5045
          ident
5046
5046
          {
5047
 
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, NULL_LEX_STRING, $1);
 
5047
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, NULL_LEX_STRING, $1);
5048
5048
          }
5049
5049
        | simple_ident_q { $$= $1; }
5050
5050
        ;
5052
5052
simple_ident_q:
5053
5053
          ident '.' ident
5054
5054
          {
5055
 
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
 
5055
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, $1, $3);
5056
5056
          }
5057
5057
        | '.' ident '.' ident
5058
5058
          {
5059
 
            $$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
 
5059
            $$= parser::buildIdent(&Lex, NULL_LEX_STRING, $2, $4);
5060
5060
          }
5061
5061
        | ident '.' ident '.' ident
5062
5062
          {
5063
 
            $$= parser::buildIdent(Lex, $1, $3, $5);
 
5063
            $$= parser::buildIdent(&Lex, $1, $3, $5);
5064
5064
          }
5065
5065
        ;
5066
5066
 
5067
5067
field_ident:
5068
 
          ident 
 
5068
          ident
5069
5069
          {
5070
5070
            $$=$1;
5071
5071
          }
5072
5072
        | ident '.' ident '.' ident
5073
5073
          {
5074
 
            if (not parser::checkFieldIdent(Lex, $1, $3))
 
5074
            if (not parser::checkFieldIdent(&Lex, $1, $3))
5075
5075
              DRIZZLE_YYABORT;
5076
5076
 
5077
5077
            $$=$5;
5078
5078
          }
5079
5079
        | ident '.' ident
5080
5080
          {
5081
 
            if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
 
5081
            if (not parser::checkFieldIdent(&Lex, NULL_LEX_STRING, $1))
5082
5082
              DRIZZLE_YYABORT;
5083
5083
 
5084
5084
            $$=$3;
5085
5085
          }
5086
 
        | '.' ident 
 
5086
        | '.' ident
5087
5087
          { /* For Delphi */
5088
5088
            $$=$2;
5089
5089
          }
5113
5113
        ;
5114
5114
 
5115
5115
IDENT_sys:
5116
 
          IDENT 
 
5116
          IDENT
5117
5117
          {
5118
5118
            $$= $1;
5119
5119
          }
5345
5345
set:
5346
5346
          SET_SYM opt_option
5347
5347
          {
5348
 
            Lex->statement= new statement::SetOption(YYSession);
 
5348
            Lex.statement= new statement::SetOption(YYSession);
5349
5349
          }
5350
5350
          option_value_list
5351
5351
          {}
5376
5376
 
5377
5377
option_type2:
5378
5378
          /* empty */ { $$= OPT_DEFAULT; }
5379
 
        | ONE_SHOT_SYM { ((statement::SetOption *)Lex->statement)->one_shot_set= true; $$= OPT_SESSION; }
 
5379
        | ONE_SHOT_SYM { ((statement::SetOption *)Lex.statement)->one_shot_set= true; $$= OPT_SESSION; }
5380
5380
        ;
5381
5381
 
5382
5382
opt_var_type:
5405
5405
            { /* System variable */
5406
5406
              if ($1)
5407
5407
              {
5408
 
                Lex->option_type= $1;
 
5408
                Lex.option_type= $1;
5409
5409
              }
5410
 
              Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type, $2.var, &$2.base_name, $4)));
 
5410
              Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type, $2.var, &$2.base_name, $4)));
5411
5411
            }
5412
5412
          }
5413
5413
        | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
5414
5414
          {
5415
 
            Lex->option_type= $1;
5416
 
            Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type,
 
5415
            Lex.option_type= $1;
 
5416
            Lex.var_list.push_back(SetVarPtr(new set_var(Lex.option_type,
5417
5417
                                              find_sys_var("tx_isolation"),
5418
5418
                                              &null_lex_str,
5419
5419
                                              new Item_int((int32_t)
5424
5424
option_value:
5425
5425
          '@' user_variable_ident equal expr
5426
5426
          {
5427
 
            Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
 
5427
            Lex.var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
5428
5428
          }
5429
5429
        | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
5430
5430
          {
5431
 
            Lex->var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
 
5431
            Lex.var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
5432
5432
          }
5433
5433
        ;
5434
5434
 
5485
5485
unlock:
5486
5486
          UNLOCK_SYM
5487
5487
          {
5488
 
            Lex->statement= new statement::UnlockTables(YYSession);
 
5488
            Lex.statement= new statement::UnlockTables(YYSession);
5489
5489
          }
5490
5490
          table_or_tables
5491
5491
          {}
5494
5494
begin:
5495
5495
          BEGIN_SYM
5496
5496
          {
5497
 
            Lex->statement= new statement::StartTransaction(YYSession);
 
5497
            Lex.statement= new statement::StartTransaction(YYSession);
5498
5498
          }
5499
5499
          opt_work {}
5500
5500
        ;
5526
5526
commit:
5527
5527
          COMMIT_SYM opt_work opt_chain opt_release
5528
5528
          {
5529
 
            Lex->statement= new statement::Commit(YYSession, $3, $4);
 
5529
            Lex.statement= new statement::Commit(YYSession, $3, $4);
5530
5530
          }
5531
5531
        ;
5532
5532
 
5533
5533
rollback:
5534
5534
          ROLLBACK_SYM opt_work opt_chain opt_release
5535
5535
          {
5536
 
            Lex->statement= new statement::Rollback(YYSession, $3, $4);
 
5536
            Lex.statement= new statement::Rollback(YYSession, $3, $4);
5537
5537
          }
5538
5538
        | ROLLBACK_SYM opt_work TO_SYM opt_savepoint savepoint_ident
5539
5539
          {
5540
 
            Lex->statement= new statement::RollbackToSavepoint(YYSession, $5);
 
5540
            Lex.statement= new statement::RollbackToSavepoint(YYSession, $5);
5541
5541
          }
5542
5542
        ;
5543
5543
 
5544
5544
savepoint:
5545
5545
          SAVEPOINT_SYM savepoint_ident
5546
5546
          {
5547
 
            Lex->statement= new statement::Savepoint(YYSession, $2);
 
5547
            Lex.statement= new statement::Savepoint(YYSession, $2);
5548
5548
          }
5549
5549
        ;
5550
5550
 
5551
5551
release:
5552
5552
          RELEASE_SYM SAVEPOINT_SYM savepoint_ident
5553
5553
          {
5554
 
            Lex->statement= new statement::ReleaseSavepoint(YYSession, $3);
 
5554
            Lex.statement= new statement::ReleaseSavepoint(YYSession, $3);
5555
5555
          }
5556
5556
        ;
5557
5557
 
5572
5572
union_list:
5573
5573
          UNION_SYM union_option
5574
5574
          {
5575
 
            if (parser::add_select_to_union_list(YYSession, Lex, (bool)$2))
 
5575
            if (parser::add_select_to_union_list(YYSession, &Lex, (bool)$2))
5576
5576
              DRIZZLE_YYABORT;
5577
5577
          }
5578
5578
          select_init
5581
5581
              Remove from the name resolution context stack the context of the
5582
5582
              last select in the union.
5583
5583
            */
5584
 
            Lex->pop_context();
 
5584
            Lex.pop_context();
5585
5585
          }
5586
5586
        ;
5587
5587
 
5593
5593
 
5594
5594
union_order_or_limit:
5595
5595
          {
5596
 
            assert(Lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
5597
 
            Select_Lex *sel= Lex->current_select;
 
5596
            assert(Lex.current_select->linkage != GLOBAL_OPTIONS_TYPE);
 
5597
            Select_Lex *sel= Lex.current_select;
5598
5598
            Select_Lex_Unit *unit= sel->master_unit();
5599
5599
            Select_Lex *fake= unit->fake_select_lex;
5600
5600
            if (fake)
5601
5601
            {
5602
5602
              unit->global_parameters= fake;
5603
5603
              fake->no_table_names_allowed= 1;
5604
 
              Lex->current_select= fake;
 
5604
              Lex.current_select= fake;
5605
5605
            }
5606
5606
            YYSession->setWhere("global ORDER clause");
5607
5607
          }
5608
5608
          order_or_limit
5609
5609
          {
5610
 
            YYSession->getLex()->current_select->no_table_names_allowed= 0;
 
5610
            YYSession->lex().current_select->no_table_names_allowed= 0;
5611
5611
            YYSession->setWhere("");
5612
5612
          }
5613
5613
        ;
5626
5626
query_specification:
5627
5627
          SELECT_SYM select_init2_derived
5628
5628
          {
5629
 
            $$= Lex->current_select->master_unit()->first_select();
 
5629
            $$= Lex.current_select->master_unit()->first_select();
5630
5630
          }
5631
5631
        | '(' select_paren_derived ')'
5632
5632
          {
5633
 
            $$= Lex->current_select->master_unit()->first_select();
 
5633
            $$= Lex.current_select->master_unit()->first_select();
5634
5634
          }
5635
5635
        ;
5636
5636
 
5639
5639
        | query_expression_body
5640
5640
          UNION_SYM union_option
5641
5641
          {
5642
 
            if (parser::add_select_to_union_list(YYSession, Lex, (bool)$3))
 
5642
            if (parser::add_select_to_union_list(YYSession, &Lex, (bool)$3))
5643
5643
              DRIZZLE_YYABORT;
5644
5644
          }
5645
5645
          query_specification
5646
5646
          {
5647
 
            Lex->pop_context();
 
5647
            Lex.pop_context();
5648
5648
            $$= $1;
5649
5649
          }
5650
5650
        ;
5659
5659
 
5660
5660
subselect_start:
5661
5661
          {
5662
 
            if (not Lex->expr_allows_subselect)
 
5662
            if (not Lex.expr_allows_subselect)
5663
5663
            {
5664
5664
              parser::my_parse_error(YYSession->m_lip);
5665
5665
              DRIZZLE_YYABORT;
5671
5671
              (SELECT .. ) UNION ...  becomes
5672
5672
              SELECT * FROM ((SELECT ...) UNION ...)
5673
5673
            */
5674
 
            if (new_select(Lex, 1))
 
5674
            if (new_select(&Lex, 1))
5675
5675
              DRIZZLE_YYABORT;
5676
5676
          }
5677
5677
        ;
5678
5678
 
5679
5679
subselect_end:
5680
5680
          {
5681
 
            Lex->pop_context();
5682
 
            Select_Lex *child= Lex->current_select;
5683
 
            Lex->current_select= Lex->current_select->return_after_parsing();
5684
 
            Lex->nest_level--;
5685
 
            Lex->current_select->n_child_sum_items += child->n_sum_items;
 
5681
            Lex.pop_context();
 
5682
            Select_Lex *child= Lex.current_select;
 
5683
            Lex.current_select= Lex.current_select->return_after_parsing();
 
5684
            Lex.nest_level--;
 
5685
            Lex.current_select->n_child_sum_items += child->n_sum_items;
5686
5686
            /*
5687
5687
              A subselect can add fields to an outer select. Reserve space for
5688
5688
              them.
5689
5689
            */
5690
 
            Lex->current_select->select_n_where_fields+=
 
5690
            Lex.current_select->select_n_where_fields+=
5691
5691
            child->select_n_where_fields;
5692
5692
          }
5693
5693
        ;