~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Monty Taylor
  • Date: 2010-04-15 19:14:53 UTC
  • mto: This revision was merged to the branch mainline in revision 1476.
  • Revision ID: mordred@inaugust.com-20100415191453-ril2x8qdo78fny9w
Replaced test_authz with a plugin implementing a hard-coded simple
multi-tennancy policy. The policy describes:
- A root user exists which can do anything
- A user may only see a schema that is named the same has his user name
- A user may see data_dictionary and information_schema (data_dictionary
  required for show databases to work)

This way, we can more clearly test the results of the authorization
interface while providing an optional plugin that is actually useful to some
human.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* sql_yacc.yy */
17
17
 
38
38
#define Lex (YYSession->lex)
39
39
 
40
40
#include "config.h"
41
 
#include <cstdio>
42
41
#include "drizzled/parser.h"
43
42
 
44
43
int yylex(void *yylval, void *yysession);
67
66
#define DRIZZLE_YYABORT_UNLESS(A)         \
68
67
  if (!(A))                             \
69
68
  {                                     \
70
 
    struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };\
71
 
    my_parse_error(&pass);\
 
69
    my_parse_error(ER(ER_SYNTAX_ERROR));\
72
70
    DRIZZLE_YYABORT;                      \
73
71
  }
74
72
 
103
101
  parser.
104
102
*/
105
103
 
106
 
struct my_parse_error_st {
107
 
  const char *s;
108
 
  Session *session;
109
 
};
110
 
 
111
 
static void my_parse_error(void *arg)
 
104
static void my_parse_error(const char *s)
112
105
{
113
 
 struct my_parse_error_st *ptr= (struct my_parse_error_st *)arg;
114
 
 
115
 
  const char *s= ptr->s;
116
 
  Session *session= ptr->session;
117
 
 
 
106
  Session *session= current_session;
118
107
  Lex_input_stream *lip= session->m_lip;
119
108
 
120
109
  const char *yytext= lip->get_tok_start();
158
147
  /* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
159
148
  if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
160
149
    s= ER(ER_SYNTAX_ERROR);
161
 
 
162
 
  struct my_parse_error_st pass= { s, session };
163
 
  my_parse_error(&pass);
 
150
  my_parse_error(s);
164
151
}
165
152
 
166
153
/**
252
239
   @return <code>false</code> if successful, <code>true</code> if an error was
253
240
   reported. In the latter case parsing should stop.
254
241
 */
255
 
static bool add_select_to_union_list(Session *session, LEX *lex, bool is_union_distinct)
 
242
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
256
243
{
257
244
  if (lex->result)
258
245
  {
262
249
  }
263
250
  if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
264
251
  {
265
 
    struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
266
 
    my_parse_error(&pass);
 
252
    my_parse_error(ER(ER_SYNTAX_ERROR));
267
253
    return true;
268
254
  }
269
255
  /* This counter shouldn't be incremented for UNION parts */
285
271
   @return false if successful, true if an error was reported. In the latter
286
272
   case parsing should stop.
287
273
 */
288
 
static bool setup_select_in_parentheses(Session *session, LEX *lex)
 
274
static bool setup_select_in_parentheses(LEX *lex)
289
275
{
290
276
  Select_Lex * sel= lex->current_select;
291
277
  if (sel->set_braces(1))
292
278
  {
293
 
    struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
294
 
    my_parse_error(&pass);
 
279
    my_parse_error(ER(ER_SYNTAX_ERROR));
295
280
    return true;
296
281
  }
297
282
  if (sel->linkage == UNION_TYPE &&
299
284
      sel->master_unit()->first_select()->linkage ==
300
285
      UNION_TYPE)
301
286
  {
302
 
    struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
303
 
    my_parse_error(&pass);
 
287
    my_parse_error(ER(ER_SYNTAX_ERROR));
304
288
    return true;
305
289
  }
306
290
  if (sel->linkage == UNION_TYPE &&
317
301
  return false;
318
302
}
319
303
 
320
 
static Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
 
304
static Item* reserved_keyword_function(const std::string &name, List<Item> *item_list)
321
305
{
322
306
  const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
323
307
  Item *item= NULL;
324
308
 
325
309
  if (udf)
326
310
  {
327
 
    item= Create_udf_func::s_singleton.create(session, udf, item_list);
 
311
    item= Create_udf_func::s_singleton.create(current_session, udf, item_list);
328
312
  } else {
329
313
    my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
330
314
  }
358
342
  enum drizzled::sql_var_t var_type;
359
343
  drizzled::Key::Keytype key_type;
360
344
  enum drizzled::ha_key_alg key_alg;
 
345
  enum drizzled::row_type row_type;
361
346
  enum drizzled::column_format_type column_format_type;
362
347
  enum drizzled::ha_rkey_function ha_rkey_mode;
363
348
  enum drizzled::enum_tx_isolation tx_isolation;
372
357
  enum drizzled::index_hint_type index_hint;
373
358
  enum drizzled::enum_filetype filetype;
374
359
  enum drizzled::ha_build_method build_method;
375
 
  drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
376
 
  drizzled::execute_string_t execute_string;
 
360
  enum drizzled::Foreign_key::fk_option m_fk_option;
377
361
}
378
362
 
379
363
%{
388
372
  Currently there are 88 shift/reduce conflicts.
389
373
  We should not introduce new conflicts any more.
390
374
*/
391
 
%expect 95
 
375
%expect 88
392
376
 
393
377
/*
394
378
   Comments for TOKENS.
433
417
%token  BIN_NUM
434
418
%token  BIT_SYM                       /* MYSQL-FUNC */
435
419
%token  BLOB_SYM                      /* SQL-2003-R */
 
420
%token  BLOCK_SIZE_SYM
 
421
%token  BLOCK_SYM
436
422
%token  BOOLEAN_SYM                   /* SQL-2003-R */
437
423
%token  BOOL_SYM
438
424
%token  BOTH                          /* SQL-2003-R */
522
508
%token  ESCAPED
523
509
%token  ESCAPE_SYM                    /* SQL-2003-R */
524
510
%token  EXCLUSIVE_SYM
525
 
%token  EXECUTE_SYM
526
511
%token  EXISTS                        /* SQL-2003-R */
527
512
%token  EXTENDED_SYM
528
513
%token  EXTRACT_SYM                   /* SQL-2003-N */
664
649
%token  READ_WRITE_SYM
665
650
%token  REAL                          /* SQL-2003-R */
666
651
%token  REDUNDANT_SYM
667
 
%token  REGEXP_SYM
668
652
%token  REFERENCES                    /* SQL-2003-R */
669
653
%token  RELEASE_SYM                   /* SQL-2003-R */
670
654
%token  RENAME
699
683
%token  SET_VAR
700
684
%token  SHARE_SYM
701
685
%token  SHOW
 
686
%token  SHUTDOWN
702
687
%token  SIMPLE_SYM                    /* SQL-2003-N */
703
688
%token  SNAPSHOT_SYM
704
689
%token  SPECIFIC_SYM                  /* SQL-2003-R */
763
748
%token  USING                         /* SQL-2003-R */
764
749
%token  UTC_DATE_SYM
765
750
%token  UTC_TIMESTAMP_SYM
766
 
%token  UUID_SYM
767
751
%token  VALUES                        /* SQL-2003-R */
768
752
%token  VALUE_SYM                     /* SQL-2003-R */
769
753
%token  VARBINARY
772
756
%token  VARIANCE_SYM
773
757
%token  VARYING                       /* SQL-2003-R */
774
758
%token  VAR_SAMP_SYM
775
 
%token  WAIT_SYM
776
759
%token  WARNINGS
777
760
%token  WEEK_SYM
778
761
%token  WHEN_SYM                      /* SQL-2003-R */
793
776
%left   XOR
794
777
%left   AND_SYM
795
778
%left   BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
796
 
%left   EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP_SYM IN_SYM
 
779
%left   EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE IN_SYM
797
780
%left   '-' '+'
798
781
%left   '*' '/' '%' DIV_SYM MOD_SYM
799
782
%left   NEG
809
792
        BIN_NUM TEXT_STRING_filesystem ident_or_empty
810
793
        opt_constraint constraint opt_ident
811
794
 
812
 
%type <execute_string>
813
 
        execute_var_or_string
814
 
 
815
795
%type <lex_str_ptr>
816
796
        opt_table_alias
817
797
 
832
812
        union_option
833
813
        start_transaction_opts opt_chain opt_release
834
814
        union_opt select_derived_init option_type2
835
 
        opt_status
836
 
        opt_concurrent
837
 
        opt_wait
838
 
        kill_option
839
815
 
840
816
%type <m_fk_option>
841
817
        delete_option
897
873
 
898
874
%type <interval_time_st> interval_time_stamp
899
875
 
 
876
%type <row_type> row_types
 
877
 
900
878
%type <column_format_type> column_format_types
901
879
 
902
880
%type <tx_isolation> isolation_types
945
923
        subselect_end select_var_list select_var_list_init opt_len
946
924
        opt_extended_describe
947
925
        statement
948
 
        execute
949
926
        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
950
927
        init_key_options key_options key_opts key_opt key_using_alg
951
928
END_OF_INPUT
1017
994
        | delete
1018
995
        | describe
1019
996
        | drop
1020
 
        | execute
1021
997
        | flush
1022
998
        | insert
1023
999
        | kill
1214
1190
opt_create_database_options:
1215
1191
          /* empty */ {}
1216
1192
        | default_collation_schema {}
1217
 
        | opt_database_custom_options {}
1218
 
        ;
1219
 
 
1220
 
opt_database_custom_options:
1221
 
        custom_database_option
1222
 
        | custom_database_option ',' opt_database_custom_options
1223
 
        ;
1224
 
 
1225
 
custom_database_option:
1226
 
          ident_or_text
1227
 
        {
1228
 
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1229
 
          drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1230
 
 
1231
 
          opt->set_name($1.str);
1232
 
        }
1233
 
        | ident_or_text equal ident_or_text
1234
 
        {
1235
 
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1236
 
          drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1237
 
 
1238
 
          opt->set_name($1.str);
1239
 
          opt->set_state($3.str);
1240
 
        }
1241
 
        | ident_or_text equal ulonglong_num
1242
 
        {
1243
 
          statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1244
 
          char number_as_string[22];
1245
 
 
1246
 
          snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1247
 
 
1248
 
          drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1249
 
 
1250
 
          opt->set_name($1.str);
1251
 
          opt->set_state(number_as_string);
1252
 
        }
1253
1193
        ;
1254
1194
 
1255
1195
opt_table_options:
1276
1216
          create_table_option
1277
1217
        | create_table_option     create_table_options
1278
1218
        | create_table_option ',' create_table_options
 
1219
        ;
1279
1220
 
1280
1221
create_table_option:
1281
 
          custom_engine_option;
1282
 
 
1283
 
custom_engine_option:
1284
 
        ENGINE_SYM equal ident_or_text
 
1222
          ENGINE_SYM opt_equal ident_or_text
1285
1223
          {
1286
1224
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1225
            message::Table::StorageEngine *protoengine;
 
1226
            protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
1287
1227
 
1288
1228
            statement->is_engine_set= true;
1289
1229
 
1290
 
            ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->set_name($3.str);
 
1230
            protoengine->set_name($3.str);
 
1231
          }
 
1232
        | BLOCK_SIZE_SYM opt_equal ulong_num
 
1233
          {
 
1234
            message::Table::TableOptions *tableopts;
 
1235
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1236
            tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
 
1237
 
 
1238
            tableopts->set_block_size($3);
 
1239
            statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1291
1240
          }
1292
1241
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1293
1242
          {
1307
1256
            statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1308
1257
            tableopts->set_auto_increment_value($3);
1309
1258
          }
1310
 
        |  ident_or_text equal ident_or_text
1311
 
          {
1312
 
            drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1313
 
 
1314
 
            opt->set_name($1.str);
1315
 
            opt->set_state($3.str);
1316
 
          }
1317
 
        | ident_or_text equal ulonglong_num
1318
 
          {
1319
 
            char number_as_string[22];
1320
 
            snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1321
 
 
1322
 
            drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1323
 
            opt->set_name($1.str);
1324
 
            opt->set_state(number_as_string);
 
1259
        | ROW_FORMAT_SYM opt_equal row_types
 
1260
          {
 
1261
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1262
            message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
 
1263
 
 
1264
            statement->create_info.row_type= $3;
 
1265
            statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
 
1266
            statement->alter_info.flags.set(ALTER_ROW_FORMAT);
 
1267
 
 
1268
            switch(statement->create_info.row_type)
 
1269
            {
 
1270
            case ROW_TYPE_DEFAULT:
 
1271
              /* No use setting a default row type... just adds redundant info to message */
 
1272
              break;
 
1273
            case ROW_TYPE_FIXED:
 
1274
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
 
1275
              break;
 
1276
            case ROW_TYPE_DYNAMIC:
 
1277
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
 
1278
              break;
 
1279
            case ROW_TYPE_COMPRESSED:
 
1280
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
 
1281
              break;
 
1282
            case ROW_TYPE_REDUNDANT:
 
1283
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
 
1284
              break;
 
1285
            case ROW_TYPE_COMPACT:
 
1286
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
 
1287
              break;
 
1288
            case ROW_TYPE_PAGE:
 
1289
              table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
 
1290
              break;
 
1291
            default:
 
1292
              abort();
 
1293
            }
1325
1294
          }
1326
1295
        | default_collation
 
1296
        | KEY_BLOCK_SIZE opt_equal ulong_num
 
1297
          {
 
1298
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1299
 
 
1300
            statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
 
1301
 
 
1302
            message::Table::TableOptions *tableopts;
 
1303
            tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
 
1304
            tableopts->set_key_block_size($3);
 
1305
          }
1327
1306
        ;
1328
1307
 
1329
1308
default_collation:
1360
1339
        | FIXED_SYM   { $$= COLUMN_FORMAT_TYPE_FIXED; }
1361
1340
        | DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1362
1341
 
 
1342
row_types:
 
1343
          DEFAULT        { $$= ROW_TYPE_DEFAULT; }
 
1344
        | FIXED_SYM      { $$= ROW_TYPE_FIXED; }
 
1345
        | DYNAMIC_SYM    { $$= ROW_TYPE_DYNAMIC; }
 
1346
        | COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
 
1347
        | REDUNDANT_SYM  { $$= ROW_TYPE_REDUNDANT; }
 
1348
        | COMPACT_SYM    { $$= ROW_TYPE_COMPACT; }
 
1349
        | PAGE_SYM       { $$= ROW_TYPE_PAGE; }
 
1350
        ;
1363
1351
 
1364
1352
opt_select_from:
1365
1353
          opt_limit_clause {}
1408
1396
          {
1409
1397
            LEX *lex=Lex;
1410
1398
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1411
 
            Key *key= new Foreign_key($1.str ? $1 : $4, lex->col_list,
 
1399
            Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1412
1400
                                      $8,
1413
1401
                                      lex->ref_list,
1414
1402
                                      statement->fk_delete_opt,
1415
1403
                                      statement->fk_update_opt,
1416
1404
                                      statement->fk_match_option);
1417
 
 
1418
1405
            statement->alter_info.key_list.push_back(key);
1419
1406
            key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1420
1407
                         &default_key_create_info, 1,
1693
1680
            if (statement->current_proto_field)
1694
1681
              statement->current_proto_field->set_type(message::Table::Field::ENUM);
1695
1682
          }
1696
 
          | UUID_SYM
1697
 
          {
1698
 
            $$=DRIZZLE_TYPE_UUID;
1699
 
 
1700
 
            statement::CreateTable *statement=
1701
 
              (statement::CreateTable *)Lex->statement;
1702
 
 
1703
 
            if (statement->current_proto_field)
1704
 
              statement->current_proto_field->set_type(message::Table::Field::UUID);
1705
 
          }
1706
1683
        | SERIAL_SYM
1707
1684
          {
1708
1685
            $$=DRIZZLE_TYPE_LONGLONG;
1969
1946
 
1970
1947
opt_match_clause:
1971
1948
          /* empty */
1972
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
 
1949
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1973
1950
        | MATCH FULL
1974
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
 
1951
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1975
1952
        | MATCH PARTIAL
1976
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
 
1953
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1977
1954
        | MATCH SIMPLE_SYM
1978
 
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
 
1955
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1979
1956
        ;
1980
1957
 
1981
1958
opt_on_update_delete:
1982
1959
          /* empty */
1983
1960
          {
1984
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1985
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1961
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
 
1962
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1986
1963
          }
1987
1964
        | ON UPDATE_SYM delete_option
1988
1965
          {
1989
1966
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1990
 
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1967
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1991
1968
          }
1992
1969
        | ON DELETE_SYM delete_option
1993
1970
          {
1994
 
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
 
1971
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1995
1972
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1996
1973
          }
1997
1974
        | ON UPDATE_SYM delete_option
2009
1986
        ;
2010
1987
 
2011
1988
delete_option:
2012
 
          RESTRICT      { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_RESTRICT; }
2013
 
        | CASCADE       { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_CASCADE; }
2014
 
        | SET NULL_SYM  { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_NULL; }
2015
 
        | NO_SYM ACTION { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_NO_ACTION; }
2016
 
        | SET DEFAULT   { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT;  }
 
1989
          RESTRICT      { $$= Foreign_key::FK_OPTION_RESTRICT; }
 
1990
        | CASCADE       { $$= Foreign_key::FK_OPTION_CASCADE; }
 
1991
        | SET NULL_SYM  { $$= Foreign_key::FK_OPTION_SET_NULL; }
 
1992
        | NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
 
1993
        | SET DEFAULT   { $$= Foreign_key::FK_OPTION_DEFAULT;  }
2017
1994
        ;
2018
1995
 
2019
1996
key_type:
2145
2122
              DRIZZLE_YYABORT;
2146
2123
            lex->col_list.empty();
2147
2124
            lex->select_lex.init_order();
2148
 
            lex->select_lex.db= const_cast<char *>(((TableList*) lex->select_lex.table_list.first)->getSchemaName());
 
2125
            lex->select_lex.db=
 
2126
              ((TableList*) lex->select_lex.table_list.first)->db;
 
2127
            statement->create_info.row_type= ROW_TYPE_NOT_USED;
2149
2128
            statement->alter_info.build_method= $2;
2150
2129
          }
2151
2130
          alter_commands
2279
2258
        | DROP FOREIGN KEY_SYM opt_ident
2280
2259
          {
2281
2260
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2282
 
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
2283
 
                                                                    $4.str));
 
2261
 
2284
2262
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
2285
2263
            statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2286
2264
          }
2516
2494
select_paren:
2517
2495
          SELECT_SYM select_part2
2518
2496
          {
2519
 
            if (setup_select_in_parentheses(YYSession, Lex))
 
2497
            if (setup_select_in_parentheses(Lex))
2520
2498
              DRIZZLE_YYABORT;
2521
2499
          }
2522
2500
        | '(' select_paren ')'
2526
2504
select_paren_derived:
2527
2505
          SELECT_SYM select_part2_derived
2528
2506
          {
2529
 
            if (setup_select_in_parentheses(YYSession, Lex))
 
2507
            if (setup_select_in_parentheses(Lex))
2530
2508
              DRIZZLE_YYABORT;
2531
2509
          }
2532
2510
        | '(' select_paren_derived ')'
2539
2517
            Select_Lex * sel= lex->current_select;
2540
2518
            if (lex->current_select->set_braces(0))
2541
2519
            {
2542
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2543
 
              my_parse_error(&pass);
 
2520
              my_parse_error(ER(ER_SYNTAX_ERROR));
2544
2521
              DRIZZLE_YYABORT;
2545
2522
            }
2546
2523
            if (sel->linkage == UNION_TYPE &&
2547
2524
                sel->master_unit()->first_select()->braces)
2548
2525
            {
2549
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2550
 
              my_parse_error(&pass);
 
2526
              my_parse_error(ER(ER_SYNTAX_ERROR));
2551
2527
              DRIZZLE_YYABORT;
2552
2528
            }
2553
2529
          }
2872
2848
            $$= item;
2873
2849
          }
2874
2850
        | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate
2875
 
          {
2876
 
            $$= new Item_func_between($1,$3,$5);
2877
 
          }
 
2851
          { $$= new Item_func_between($1,$3,$5); }
2878
2852
        | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
2879
2853
          {
2880
2854
            Item_func_between *item= new Item_func_between($1,$4,$6);
2882
2856
            $$= item;
2883
2857
          }
2884
2858
        | bit_expr LIKE simple_expr opt_escape
2885
 
          { 
2886
 
            $$= new Item_func_like($1,$3,$4,Lex->escape_used);
2887
 
          }
 
2859
          { $$= new Item_func_like($1,$3,$4,Lex->escape_used); }
2888
2860
        | bit_expr not LIKE simple_expr opt_escape
2889
 
          { 
2890
 
            $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used));
2891
 
          }
2892
 
        | bit_expr REGEXP_SYM bit_expr
2893
 
          { 
2894
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2895
 
            args->push_back($1);
2896
 
            args->push_back($3);
2897
 
            if (! ($$= reserved_keyword_function(YYSession, "regex", args)))
2898
 
            {
2899
 
              DRIZZLE_YYABORT;
2900
 
            }
2901
 
          }
2902
 
        | bit_expr not REGEXP_SYM bit_expr
2903
 
          { 
2904
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
2905
 
            args->push_back($1);
2906
 
            args->push_back($4);
2907
 
            args->push_back(new (YYSession->mem_root) Item_int(1));
2908
 
            if (! ($$= reserved_keyword_function(YYSession, "regex", args)))
2909
 
            {
2910
 
              DRIZZLE_YYABORT;
2911
 
            }
2912
 
          }
 
2861
          { $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used)); }
2913
2862
        | bit_expr
2914
2863
        ;
2915
2864
 
2925
2874
        | bit_expr '*' bit_expr %prec '*'
2926
2875
          { $$= new Item_func_mul($1,$3); }
2927
2876
        | bit_expr '/' bit_expr %prec '/'
2928
 
          { $$= new Item_func_div(YYSession,$1,$3); }
 
2877
          { $$= new Item_func_div($1,$3); }
2929
2878
        | bit_expr '%' bit_expr %prec '%'
2930
2879
          { $$= new Item_func_mod($1,$3); }
2931
2880
        | bit_expr DIV_SYM bit_expr %prec DIV_SYM
2978
2927
        | literal
2979
2928
        | variable
2980
2929
        | sum_expr
2981
 
          {
2982
 
            Lex->setSumExprUsed();
2983
 
          }
2984
2930
        | '+' simple_expr %prec NEG { $$= $2; }
2985
2931
        | '-' simple_expr %prec NEG
2986
2932
          { $$= new (YYSession->mem_root) Item_func_neg($2); }
3053
2999
        | CURRENT_USER optional_braces
3054
3000
          {
3055
3001
            std::string user_str("user");
3056
 
            if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
 
3002
            if (! ($$= reserved_keyword_function(user_str, NULL)))
3057
3003
            {
3058
3004
              DRIZZLE_YYABORT;
3059
3005
            }
3060
 
            Lex->setCacheable(false);
3061
3006
          }
3062
3007
        | DATE_SYM '(' expr ')'
3063
3008
          { $$= new (YYSession->mem_root) Item_date_typecast($3); }
3066
3011
        | HOUR_SYM '(' expr ')'
3067
3012
          { $$= new (YYSession->mem_root) Item_func_hour($3); }
3068
3013
        | INSERT '(' expr ',' expr ',' expr ',' expr ')'
3069
 
          { $$= new (YYSession->mem_root) Item_func_insert(*YYSession, $3, $5, $7, $9); }
 
3014
          { $$= new (YYSession->mem_root) Item_func_insert($3,$5,$7,$9); }
3070
3015
        | INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3071
3016
          {
3072
3017
            Session *session= YYSession;
3115
3060
        | USER '(' ')'
3116
3061
          {
3117
3062
            std::string user_str("user");
3118
 
            if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
 
3063
            if (! ($$= reserved_keyword_function(user_str, NULL)))
3119
3064
            {
3120
3065
              DRIZZLE_YYABORT;
3121
3066
            }
3122
 
            Lex->setCacheable(false);
3123
3067
          }
3124
3068
        | YEAR_SYM '(' expr ')'
3125
3069
          { $$= new (YYSession->mem_root) Item_func_year($3); }
3147
3091
        | CURDATE optional_braces
3148
3092
          {
3149
3093
            $$= new (YYSession->mem_root) Item_func_curdate_local();
3150
 
            Lex->setCacheable(false);
3151
3094
          }
3152
3095
        | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3153
3096
          { $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3158
3101
        | NOW_SYM optional_braces
3159
3102
          {
3160
3103
            $$= new (YYSession->mem_root) Item_func_now_local();
3161
 
            Lex->setCacheable(false);
3162
3104
          }
3163
3105
        | NOW_SYM '(' expr ')'
3164
3106
          {
3165
3107
            $$= new (YYSession->mem_root) Item_func_now_local($3);
3166
 
            Lex->setCacheable(false);
3167
3108
          }
3168
3109
        | POSITION_SYM '(' bit_expr IN_SYM expr ')'
3169
3110
          { $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
3181
3122
            args->push_back($3);
3182
3123
            args->push_back($5);
3183
3124
            args->push_back($7);
3184
 
            if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
 
3125
            if (! ($$= reserved_keyword_function(reverse_str, args)))
3185
3126
            {
3186
3127
              DRIZZLE_YYABORT;
3187
3128
            }
3192
3133
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3193
3134
            args->push_back($3);
3194
3135
            args->push_back($5);
3195
 
            if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
 
3136
            if (! ($$= reserved_keyword_function(reverse_str, args)))
3196
3137
            {
3197
3138
              DRIZZLE_YYABORT;
3198
3139
            }
3204
3145
            args->push_back($3);
3205
3146
            args->push_back($5);
3206
3147
            args->push_back($7);
3207
 
            if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
 
3148
            if (! ($$= reserved_keyword_function(reverse_str, args)))
3208
3149
            {
3209
3150
              DRIZZLE_YYABORT;
3210
3151
            }
3215
3156
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3216
3157
            args->push_back($3);
3217
3158
            args->push_back($5);
3218
 
            if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
 
3159
            if (! ($$= reserved_keyword_function(reverse_str, args)))
3219
3160
            {
3220
3161
              DRIZZLE_YYABORT;
3221
3162
            }
3222
3163
          }
3223
3164
        | SYSDATE optional_braces
3224
 
          { 
3225
 
            $$= new (YYSession->mem_root) Item_func_sysdate_local(); 
3226
 
            Lex->setCacheable(false);
3227
 
          }
 
3165
          { $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
3228
3166
        | SYSDATE '(' expr ')'
3229
 
          { 
3230
 
            $$= new (YYSession->mem_root) Item_func_sysdate_local($3); 
3231
 
            Lex->setCacheable(false);
3232
 
          }
 
3167
          { $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
3233
3168
        | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
3234
3169
          { $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
3235
3170
        | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3237
3172
        | UTC_DATE_SYM optional_braces
3238
3173
          {
3239
3174
            $$= new (YYSession->mem_root) Item_func_curdate_utc();
3240
 
            Lex->setCacheable(false);
3241
3175
          }
3242
3176
        | UTC_TIMESTAMP_SYM optional_braces
3243
3177
          {
3244
3178
            $$= new (YYSession->mem_root) Item_func_now_utc();
3245
 
            Lex->setCacheable(false);
3246
3179
          }
3247
3180
        ;
3248
3181
 
3259
3192
        | DATABASE '(' ')'
3260
3193
          {
3261
3194
            std::string database_str("database");
3262
 
            if (! ($$= reserved_keyword_function(YYSession, database_str, NULL)))
 
3195
            if (! ($$= reserved_keyword_function(database_str, NULL)))
3263
3196
            {
3264
3197
              DRIZZLE_YYABORT;
3265
3198
            }
3266
 
            Lex->setCacheable(false);
3267
3199
          }
3268
 
        | EXECUTE_SYM '(' expr ')' opt_wait
3269
 
          {
3270
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3271
 
            args->push_back($3);
3272
 
 
3273
 
            if ($5)
3274
 
            {
3275
 
              args->push_back(new (YYSession->mem_root) Item_int(1));
3276
 
            }
3277
 
 
3278
 
            if (! ($$= reserved_keyword_function(YYSession, "execute", args)))
3279
 
            {
3280
 
              DRIZZLE_YYABORT;
3281
 
            }
3282
 
          }
3283
3200
        | IF '(' expr ',' expr ',' expr ')'
3284
3201
          { $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
3285
 
        | KILL_SYM kill_option '(' expr ')'
3286
 
          {
3287
 
            std::string kill_str("kill");
3288
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3289
 
            args->push_back($4);
3290
 
 
3291
 
            if ($2)
3292
 
            {
3293
 
              args->push_back(new (YYSession->mem_root) Item_uint(1));
3294
 
            }
3295
 
 
3296
 
            if (! ($$= reserved_keyword_function(YYSession, kill_str, args)))
3297
 
            {
3298
 
              DRIZZLE_YYABORT;
3299
 
            }
3300
 
          }
3301
3202
        | MICROSECOND_SYM '(' expr ')'
3302
3203
          { $$= new (YYSession->mem_root) Item_func_microsecond($3); }
3303
3204
        | MOD_SYM '(' expr ',' expr ')'
3305
3206
        | QUARTER_SYM '(' expr ')'
3306
3207
          { $$ = new (YYSession->mem_root) Item_func_quarter($3); }
3307
3208
        | REPEAT_SYM '(' expr ',' expr ')'
3308
 
          { $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
 
3209
          { $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
3309
3210
        | REPLACE '(' expr ',' expr ',' expr ')'
3310
 
          { $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
 
3211
          { $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3311
3212
        | REVERSE_SYM '(' expr ')'
3312
3213
          {
3313
3214
            std::string reverse_str("reverse");
3314
3215
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3315
3216
            args->push_back($3);
3316
 
            if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
 
3217
            if (! ($$= reserved_keyword_function(reverse_str, args)))
3317
3218
            {
3318
3219
              DRIZZLE_YYABORT;
3319
3220
            }
3320
3221
          }
3321
3222
        | TRUNCATE_SYM '(' expr ',' expr ')'
3322
3223
          { $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
3323
 
        | WAIT_SYM '(' expr ')'
3324
 
          {
3325
 
            std::string wait_str("wait");
3326
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3327
 
            args->push_back($3);
3328
 
            if (! ($$= reserved_keyword_function(YYSession, wait_str, args)))
3329
 
            {
3330
 
              DRIZZLE_YYABORT;
3331
 
            }
3332
 
          }
3333
 
        | UUID_SYM '(' ')'
3334
 
          {
3335
 
            if (! ($$= reserved_keyword_function(YYSession, "uuid", NULL)))
3336
 
            {
3337
 
              DRIZZLE_YYABORT;
3338
 
            }
3339
 
            Lex->setCacheable(false);
3340
 
          }
3341
 
        | WAIT_SYM '(' expr ',' expr ')'
3342
 
          {
3343
 
            std::string wait_str("wait");
3344
 
            List<Item> *args= new (YYSession->mem_root) List<Item>;
3345
 
            args->push_back($3);
3346
 
            args->push_back($5);
3347
 
            if (! ($$= reserved_keyword_function(YYSession, wait_str, args)))
3348
 
            {
3349
 
              DRIZZLE_YYABORT;
3350
 
            }
3351
 
          }
3352
3224
        ;
3353
3225
 
3354
3226
/*
3404
3276
            {
3405
3277
              DRIZZLE_YYABORT;
3406
3278
            }
3407
 
            Lex->setCacheable(false);
3408
3279
          }
3409
3280
        ;
3410
3281
 
3513
3384
          ident_or_text SET_VAR expr
3514
3385
          {
3515
3386
            $$= new Item_func_set_user_var($1, $3);
3516
 
            Lex->setCacheable(false);
3517
3387
          }
3518
3388
        | ident_or_text
3519
3389
          {
3520
 
            $$= new Item_func_get_user_var(*YYSession, $1);
3521
 
            Lex->setCacheable(false);
 
3390
            $$= new Item_func_get_user_var($1);
3522
3391
          }
3523
3392
        | '@' opt_var_ident_type ident_or_text opt_component
3524
3393
          {
3525
3394
            /* disallow "SELECT @@global.global.variable" */
3526
3395
            if ($3.str && $4.str && check_reserved_words(&$3))
3527
3396
            {
3528
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3529
 
              my_parse_error(&pass);
 
3397
              my_parse_error(ER(ER_SYNTAX_ERROR));
3530
3398
              DRIZZLE_YYABORT;
3531
3399
            }
3532
3400
            if (!($$= get_system_var(YYSession, $2, $3, $4)))
3568
3436
            LEX *lex= Lex;
3569
3437
            if (lex->current_select->inc_in_sum_expr())
3570
3438
            {
3571
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3572
 
              my_parse_error(&pass);
 
3439
              my_parse_error(ER(ER_SYNTAX_ERROR));
3573
3440
              DRIZZLE_YYABORT;
3574
3441
            }
3575
3442
          }
3684
3551
            left-associative joins.
3685
3552
          */
3686
3553
          table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3687
 
          { 
3688
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
3689
 
            Lex->is_cross= false;
3690
 
          }
 
3554
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); }
3691
3555
        | table_ref STRAIGHT_JOIN table_factor
3692
 
          { 
3693
 
            DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; 
3694
 
          }
 
3556
          { DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
3695
3557
        | table_ref normal_join table_ref
3696
3558
          ON
3697
3559
          {
3698
3560
            DRIZZLE_YYABORT_UNLESS($1 && $3);
3699
 
            DRIZZLE_YYABORT_UNLESS( not Lex->is_cross );
3700
3561
            /* Change the current name resolution context to a local context. */
3701
3562
            if (push_new_name_resolution_context(YYSession, $1, $3))
3702
3563
              DRIZZLE_YYABORT;
3816
3677
normal_join:
3817
3678
          JOIN_SYM {}
3818
3679
        | INNER_SYM JOIN_SYM {}
3819
 
        | CROSS JOIN_SYM { Lex->is_cross= true; }
 
3680
        | CROSS JOIN_SYM {}
3820
3681
        ;
3821
3682
 
3822
3683
/*
3829
3690
/* Warning - may return NULL in case of incomplete SELECT */
3830
3691
table_factor:
3831
3692
          {
 
3693
            Select_Lex *sel= Lex->current_select;
 
3694
            sel->table_join_options= 0;
3832
3695
          }
3833
3696
          table_ident opt_table_alias opt_key_definition
3834
3697
          {
3835
3698
            if (!($$= Lex->current_select->add_table_to_list(YYSession, $2, $3,
3836
 
                             0,
 
3699
                             Lex->current_select->get_table_join_options(),
3837
3700
                             Lex->lock_option,
3838
3701
                             Lex->current_select->pop_index_hints())))
3839
3702
              DRIZZLE_YYABORT;
3847
3710
            {
3848
3711
              if (sel->set_braces(1))
3849
3712
              {
3850
 
                struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3851
 
                my_parse_error(&pass);
 
3713
                my_parse_error(ER(ER_SYNTAX_ERROR));
3852
3714
                DRIZZLE_YYABORT;
3853
3715
              }
3854
3716
              /* select in braces, can't contain global parameters */
3885
3747
            /* Use $2 instead of Lex->current_select as derived table will
3886
3748
               alter value of Lex->current_select. */
3887
3749
            if (!($3 || $5) && $2->embedding &&
3888
 
                !$2->embedding->getNestedJoin()->join_list.elements)
 
3750
                !$2->embedding->nested_join->join_list.elements)
3889
3751
            {
3890
3752
              /* we have a derived table ($3 == NULL) but no alias,
3891
3753
                 Since we are nested in further parentheses so we
3913
3775
            else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3914
3776
            {
3915
3777
              /* simple nested joins cannot have aliases or unions */
3916
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3917
 
              my_parse_error(&pass);
 
3778
              my_parse_error(ER(ER_SYNTAX_ERROR));
3918
3779
              DRIZZLE_YYABORT;
3919
3780
            }
3920
3781
            else
3928
3789
          UNION_SYM
3929
3790
          union_option
3930
3791
          {
3931
 
            if (add_select_to_union_list(YYSession, Lex, (bool)$3))
 
3792
            if (add_select_to_union_list(Lex, (bool)$3))
3932
3793
              DRIZZLE_YYABORT;
3933
3794
          }
3934
3795
          query_specification
3950
3811
            Select_Lex * sel= lex->current_select;
3951
3812
            if (lex->current_select->set_braces(0))
3952
3813
            {
3953
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3954
 
              my_parse_error(&pass);
 
3814
              my_parse_error(ER(ER_SYNTAX_ERROR));
3955
3815
              DRIZZLE_YYABORT;
3956
3816
            }
3957
3817
            if (sel->linkage == UNION_TYPE &&
3958
3818
                sel->master_unit()->first_select()->braces)
3959
3819
            {
3960
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3961
 
              my_parse_error(&pass);
 
3820
              my_parse_error(ER(ER_SYNTAX_ERROR));
3962
3821
              DRIZZLE_YYABORT;
3963
3822
            }
3964
3823
          }
3998
3857
              DRIZZLE_YYABORT;
3999
3858
            if (!$3 && $$)
4000
3859
            {
4001
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4002
 
              my_parse_error(&pass);
 
3860
              my_parse_error(ER(ER_SYNTAX_ERROR));
4003
3861
              DRIZZLE_YYABORT;
4004
3862
            }
4005
3863
          }
4011
3869
            lex->derived_tables|= DERIVED_SUBQUERY;
4012
3870
            if (!lex->expr_allows_subselect)
4013
3871
            {
4014
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4015
 
              my_parse_error(&pass);
 
3872
              my_parse_error(ER(ER_SYNTAX_ERROR));
4016
3873
              DRIZZLE_YYABORT;
4017
3874
            }
4018
3875
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
4043
3900
            if (!sel->embedding || sel->end_nested_join(lex->session))
4044
3901
            {
4045
3902
              /* we are not in parentheses */
4046
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4047
 
              my_parse_error(&pass);
 
3903
              my_parse_error(ER(ER_SYNTAX_ERROR));
4048
3904
              DRIZZLE_YYABORT;
4049
3905
            }
4050
3906
            embedding= Lex->current_select->embedding;
4051
3907
            $$= embedding &&
4052
 
                !embedding->getNestedJoin()->join_list.elements;
 
3908
                !embedding->nested_join->join_list.elements;
4053
3909
            /* return true if we are deeply nested */
4054
3910
          }
4055
3911
        ;
4484
4340
          OUTFILE TEXT_STRING_filesystem
4485
4341
          {
4486
4342
            LEX *lex= Lex;
4487
 
            lex->setCacheable(false);
4488
4343
            if (!(lex->exchange= new file_exchange($2.str, 0)) ||
4489
4344
                !(lex->result= new select_export(lex->exchange)))
4490
4345
              DRIZZLE_YYABORT;
4495
4350
            LEX *lex=Lex;
4496
4351
            if (!lex->describe)
4497
4352
            {
4498
 
              lex->setCacheable(false);
4499
4353
              if (!(lex->exchange= new file_exchange($2.str,1)))
4500
4354
                DRIZZLE_YYABORT;
4501
4355
              if (!(lex->result= new select_dump(lex->exchange)))
4503
4357
            }
4504
4358
          }
4505
4359
        | select_var_list_init
4506
 
          {Lex->setCacheable(false);}
 
4360
          { }
4507
4361
        ;
4508
4362
 
4509
4363
/*
4570
4424
          /* empty */ { $$= 0; }
4571
4425
        | TEMPORARY_SYM { $$= 1; }
4572
4426
        ;
4573
 
 
4574
 
/*
4575
 
  Execute a string as dynamic SQL.
4576
 
  */
4577
 
 
4578
 
execute:
4579
 
       EXECUTE_SYM execute_var_or_string opt_status opt_concurrent opt_wait
4580
 
       {
4581
 
          LEX *lex= Lex;
4582
 
          statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession, $2, $3, $4, $5);
4583
 
          lex->statement= statement;
4584
 
          if (lex->statement == NULL)
4585
 
            DRIZZLE_YYABORT;
4586
 
       }
4587
 
 
4588
 
 
4589
 
execute_var_or_string:
4590
 
         ident_or_text
4591
 
         {
4592
 
            $$.set($1);
4593
 
         }
4594
 
        | '@' ident_or_text
4595
 
        {
4596
 
            $$.set($2, true);
4597
 
        }
4598
 
 
4599
 
opt_status:
4600
 
          /* empty */ { $$= 0; }
4601
 
        | WITH NO_SYM RETURN_SYM { $$= 1; }
4602
 
        ;
4603
 
 
4604
 
opt_concurrent:
4605
 
          /* empty */ { $$= 0; }
4606
 
        | CONCURRENT { $$= 1; }
4607
 
        ;
4608
 
 
4609
 
opt_wait:
4610
 
          /* empty */ { $$= 0; }
4611
 
        | WAIT_SYM { $$= 1; }
4612
 
        ;
4613
 
 
4614
4427
/*
4615
4428
** Insert : add new data to table
4616
4429
*/
4909
4722
          {}
4910
4723
        ;
4911
4724
 
4912
 
/* SHOW SCHEMAS */
4913
4725
show_param:
4914
4726
           DATABASES show_wild
4915
4727
           {
4918
4730
 
4919
4731
             lex->sql_command= SQLCOM_SELECT;
4920
4732
             lex->statement=
4921
 
               new(std::nothrow) statement::Show(session);
 
4733
               new(std::nothrow) statement::Select(session);
4922
4734
             if (lex->statement == NULL)
4923
4735
               DRIZZLE_YYABORT;
4924
4736
 
4947
4759
 
4948
4760
             if (session->add_item_to_list(my_field))
4949
4761
               DRIZZLE_YYABORT;
4950
 
 
4951
 
              if (session->add_order_to_list(my_field, true))
4952
 
                DRIZZLE_YYABORT;
4953
4762
           }
4954
 
           /* SHOW TABLES */
4955
4763
         | TABLES opt_db show_wild
4956
4764
           {
4957
4765
             LEX *lex= Lex;
4959
4767
 
4960
4768
             lex->sql_command= SQLCOM_SELECT;
4961
4769
 
4962
 
             statement::Show *select=
4963
 
               new(std::nothrow) statement::Show(YYSession);
 
4770
             statement::Select *select=
 
4771
               new(std::nothrow) statement::Select(YYSession);
4964
4772
 
4965
4773
             lex->statement= select;
4966
4774
 
4970
4778
 
4971
4779
              std::string column_name= "Tables_in_";
4972
4780
 
4973
 
              util::string::const_shared_ptr schema(session->schema());
4974
4781
              if ($2)
4975
4782
              {
4976
4783
                SchemaIdentifier identifier($2);
4982
4789
                }
4983
4790
                select->setShowPredicate($2, "");
4984
4791
              }
4985
 
              else if (schema and not schema->empty())
 
4792
              else if (not session->db.empty())
4986
4793
              {
4987
 
                column_name.append(*schema);
4988
 
                select->setShowPredicate(*schema, "");
 
4794
                column_name.append(session->db);
 
4795
                select->setShowPredicate(session->db, "");
4989
4796
              }
4990
4797
              else
4991
4798
              {
4992
 
                my_error(ER_NO_DB_ERROR, MYF(0));
4993
 
                DRIZZLE_YYABORT;
 
4799
                 my_error(ER_NO_DB_ERROR, MYF(0));
4994
4800
              }
4995
4801
 
4996
4802
 
5010
4816
 
5011
4817
             if (session->add_item_to_list(my_field))
5012
4818
               DRIZZLE_YYABORT;
5013
 
 
5014
 
              if (session->add_order_to_list(my_field, true))
5015
 
                DRIZZLE_YYABORT;
5016
4819
           }
5017
 
           /* SHOW TEMPORARY TABLES */
5018
4820
         | TEMPORARY_SYM TABLES show_wild
5019
4821
           {
5020
4822
             LEX *lex= Lex;
5022
4824
 
5023
4825
             lex->sql_command= SQLCOM_SELECT;
5024
4826
 
5025
 
             statement::Show *select=
5026
 
               new(std::nothrow) statement::Show(YYSession);
 
4827
             statement::Select *select=
 
4828
               new(std::nothrow) statement::Select(YYSession);
5027
4829
 
5028
4830
             lex->statement= select;
5029
4831
 
5041
4843
             (session->lex->current_select->with_wild)++;
5042
4844
 
5043
4845
           }
5044
 
           /* SHOW TABLE STATUS */
5045
4846
         | TABLE_SYM STATUS_SYM opt_db show_wild
5046
4847
           {
5047
4848
             LEX *lex= Lex;
5048
4849
             lex->sql_command= SQLCOM_SELECT;
5049
 
             statement::Show *select=
5050
 
               new(std::nothrow) statement::Show(YYSession);
 
4850
             statement::Select *select=
 
4851
               new(std::nothrow) statement::Select(YYSession);
5051
4852
 
5052
4853
             lex->statement= select;
5053
4854
 
5058
4859
 
5059
4860
             std::string column_name= "Tables_in_";
5060
4861
 
5061
 
             util::string::const_shared_ptr schema(session->schema());
5062
4862
             if ($3)
5063
4863
             {
5064
4864
               lex->select_lex.db= $3;
5071
4871
 
5072
4872
               select->setShowPredicate($3, "");
5073
4873
             }
5074
 
             else if (schema)
5075
 
             {
5076
 
               select->setShowPredicate(*schema, "");
5077
 
             }
5078
4874
             else
5079
4875
             {
5080
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5081
 
               DRIZZLE_YYABORT;
 
4876
               select->setShowPredicate(session->db, "");
5082
4877
             }
5083
4878
 
5084
4879
             if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
5090
4885
               DRIZZLE_YYABORT;
5091
4886
             (session->lex->current_select->with_wild)++;
5092
4887
           }
5093
 
           /* SHOW COLUMNS FROM table_name */
5094
4888
        | COLUMNS from_or_in table_ident opt_db show_wild
5095
4889
          {
5096
4890
             LEX *lex= Lex;
5097
4891
             Session *session= YYSession;
5098
 
             statement::Show *select;
 
4892
             statement::Select *select;
5099
4893
 
5100
4894
             lex->sql_command= SQLCOM_SELECT;
5101
4895
 
5102
 
             select= new(std::nothrow) statement::Show(session);
 
4896
             select= new(std::nothrow) statement::Select(session);
5103
4897
 
5104
4898
             lex->statement= select;
5105
4899
 
5106
4900
             if (lex->statement == NULL)
5107
4901
               DRIZZLE_YYABORT;
5108
4902
 
5109
 
             util::string::const_shared_ptr schema(session->schema());
5110
4903
             if ($4)
5111
 
             {
5112
4904
              select->setShowPredicate($4, $3->table.str);
5113
 
             }
5114
4905
             else if ($3->db.str)
5115
 
             {
5116
4906
              select->setShowPredicate($3->db.str, $3->table.str);
5117
 
             }
5118
 
             else if (schema)
5119
 
             {
5120
 
               select->setShowPredicate(*schema, $3->table.str);
5121
 
             }
5122
4907
             else
5123
 
             {
5124
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5125
 
               DRIZZLE_YYABORT;
5126
 
             }
 
4908
              select->setShowPredicate(session->db, $3->table.str);
5127
4909
 
5128
4910
             {
5129
4911
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5145
4927
             (session->lex->current_select->with_wild)++;
5146
4928
 
5147
4929
          }
5148
 
          /* SHOW INDEXES from table */
5149
4930
        | keys_or_index from_or_in table_ident opt_db where_clause
5150
4931
          {
5151
4932
             LEX *lex= Lex;
5152
4933
             Session *session= YYSession;
5153
 
             statement::Show *select;
 
4934
             statement::Select *select;
5154
4935
 
5155
4936
             lex->sql_command= SQLCOM_SELECT;
5156
4937
 
5157
 
             select= new(std::nothrow) statement::Show(session);
 
4938
             select= new(std::nothrow) statement::Select(session);
5158
4939
 
5159
4940
             lex->statement= select;
5160
4941
 
5161
4942
             if (lex->statement == NULL)
5162
4943
               DRIZZLE_YYABORT;
5163
4944
 
5164
 
             util::string::const_shared_ptr schema(session->schema());
5165
4945
             if ($4)
5166
 
             {
5167
4946
              select->setShowPredicate($4, $3->table.str);
5168
 
             }
5169
4947
             else if ($3->db.str)
5170
 
             {
5171
4948
              select->setShowPredicate($3->db.str, $3->table.str);
5172
 
             }
5173
 
             else if (schema)
5174
 
             {
5175
 
               select->setShowPredicate(*schema, $3->table.str);
5176
 
             }
5177
4949
             else
5178
 
             {
5179
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5180
 
               DRIZZLE_YYABORT;
5181
 
             }
 
4950
              select->setShowPredicate(session->db, $3->table.str);
5182
4951
 
5183
4952
             {
5184
4953
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5203
4972
          {
5204
4973
            (void) create_select_for_variable("warning_count");
5205
4974
            LEX *lex= Lex;
5206
 
            lex->statement= new(std::nothrow) statement::Show(YYSession);
 
4975
            lex->statement= new(std::nothrow) statement::Select(YYSession);
5207
4976
            if (lex->statement == NULL)
5208
4977
              DRIZZLE_YYABORT;
5209
4978
          }
5211
4980
          {
5212
4981
            (void) create_select_for_variable("error_count");
5213
4982
            LEX *lex= Lex;
5214
 
            lex->statement= new(std::nothrow) statement::Show(YYSession);
 
4983
            lex->statement= new(std::nothrow) statement::Select(YYSession);
5215
4984
            if (lex->statement == NULL)
5216
4985
              DRIZZLE_YYABORT;
5217
4986
          }
5234
5003
             LEX *lex= Lex;
5235
5004
             lex->sql_command= SQLCOM_SELECT;
5236
5005
             lex->statement=
5237
 
               new(std::nothrow) statement::Show(YYSession);
 
5006
               new(std::nothrow) statement::Select(YYSession);
5238
5007
             if (lex->statement == NULL)
5239
5008
               DRIZZLE_YYABORT;
5240
5009
 
5268
5037
             if (session->add_item_to_list(my_field))
5269
5038
               DRIZZLE_YYABORT;
5270
5039
           }
5271
 
        | CREATE TABLE_SYM table_ident
5272
 
           {
5273
 
             LEX *lex= Lex;
5274
 
             lex->sql_command= SQLCOM_SELECT;
5275
 
             statement::Show *select=
5276
 
               new(std::nothrow) statement::Show(YYSession);
5277
 
 
5278
 
             lex->statement= select;
5279
 
 
5280
 
             if (lex->statement == NULL)
5281
 
               DRIZZLE_YYABORT;
5282
 
 
5283
 
             Session *session= YYSession;
5284
 
 
5285
 
             if (prepare_new_schema_table(session, lex, "TABLE_SQL_DEFINITION"))
5286
 
               DRIZZLE_YYABORT;
5287
 
 
5288
 
             util::string::const_shared_ptr schema(session->schema());
5289
 
             if ($3->db.str)
5290
 
             {
5291
 
               select->setShowPredicate($3->db.str, $3->table.str);
5292
 
             }
5293
 
             else if (schema)
5294
 
             {
5295
 
               select->setShowPredicate(*schema, $3->table.str);
5296
 
             }
5297
 
             else
5298
 
             {
5299
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5300
 
               DRIZZLE_YYABORT;
5301
 
             }
5302
 
 
5303
 
             std::string key("Table");
5304
 
             std::string value("Create Table");
5305
 
 
5306
 
             Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5307
 
             my_field->is_autogenerated_name= false;
5308
 
             my_field->set_name(key.c_str(), key.length(), system_charset_info);
5309
 
 
5310
 
             if (session->add_item_to_list(my_field))
5311
 
               DRIZZLE_YYABORT;
5312
 
 
5313
 
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5314
 
             my_field->is_autogenerated_name= false;
5315
 
             my_field->set_name(value.c_str(), value.length(), system_charset_info);
5316
 
 
5317
 
             if (session->add_item_to_list(my_field))
5318
 
               DRIZZLE_YYABORT;
5319
 
           }
5320
5040
        | PROCESSLIST_SYM
5321
5041
          {
5322
5042
           {
5323
5043
             LEX *lex= Lex;
5324
5044
             lex->sql_command= SQLCOM_SELECT;
5325
5045
             lex->statement=
5326
 
               new(std::nothrow) statement::Show(YYSession);
 
5046
               new(std::nothrow) statement::Select(YYSession);
5327
5047
             if (lex->statement == NULL)
5328
5048
               DRIZZLE_YYABORT;
5329
5049
 
5344
5064
             LEX *lex= Lex;
5345
5065
             lex->sql_command= SQLCOM_SELECT;
5346
5066
             lex->statement=
5347
 
               new(std::nothrow) statement::Show(YYSession);
 
5067
               new(std::nothrow) statement::Select(YYSession);
5348
5068
             if (lex->statement == NULL)
5349
5069
               DRIZZLE_YYABORT;
5350
5070
 
5379
5099
               DRIZZLE_YYABORT;
5380
5100
           }
5381
5101
        | CREATE DATABASE opt_if_not_exists ident
5382
 
           {
5383
 
             LEX *lex= Lex;
5384
 
             lex->sql_command= SQLCOM_SELECT;
5385
 
             statement::Show *select=
5386
 
               new(std::nothrow) statement::Show(YYSession);
5387
 
 
5388
 
             lex->statement= select;
5389
 
 
5390
 
             if (lex->statement == NULL)
5391
 
               DRIZZLE_YYABORT;
5392
 
 
5393
 
             Session *session= YYSession;
5394
 
 
5395
 
             if (prepare_new_schema_table(session, lex, "SCHEMA_SQL_DEFINITION"))
5396
 
               DRIZZLE_YYABORT;
5397
 
 
5398
 
             util::string::const_shared_ptr schema(session->schema());
5399
 
             if ($4.str)
5400
 
             {
5401
 
              select->setShowPredicate($4.str);
5402
 
             }
5403
 
             else if (schema)
5404
 
             {
5405
 
               select->setShowPredicate(*schema);
5406
 
             }
5407
 
             else
5408
 
             {
5409
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5410
 
               DRIZZLE_YYABORT;
5411
 
             }
5412
 
 
5413
 
             std::string key("Database");
5414
 
             std::string value("Create Database");
5415
 
 
5416
 
             Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5417
 
             my_field->is_autogenerated_name= false;
5418
 
             my_field->set_name(key.c_str(), key.length(), system_charset_info);
5419
 
 
5420
 
             if (session->add_item_to_list(my_field))
5421
 
               DRIZZLE_YYABORT;
5422
 
 
5423
 
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5424
 
             my_field->is_autogenerated_name= false;
5425
 
             my_field->set_name(value.c_str(), value.length(), system_charset_info);
5426
 
 
5427
 
             if (session->add_item_to_list(my_field))
5428
 
               DRIZZLE_YYABORT;
5429
 
           }
 
5102
          {
 
5103
            Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
 
5104
            statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
 
5105
            Lex->statement= statement;
 
5106
            if (Lex->statement == NULL)
 
5107
              DRIZZLE_YYABORT;
 
5108
            statement->is_if_not_exists= $3;
 
5109
            Lex->name= $4;
 
5110
          }
 
5111
        | CREATE TABLE_SYM table_ident
 
5112
          {
 
5113
            LEX *lex= Lex;
 
5114
            lex->sql_command = SQLCOM_SHOW_CREATE;
 
5115
            lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
 
5116
            if (lex->statement == NULL)
 
5117
              DRIZZLE_YYABORT;
 
5118
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
 
5119
              DRIZZLE_YYABORT;
 
5120
          }
5430
5121
 
5431
5122
opt_db:
5432
5123
          /* empty */  { $$= 0; }
5460
5151
          describe_command table_ident
5461
5152
          {
5462
5153
            Session *session= YYSession;
5463
 
            statement::Show *select;
 
5154
            statement::Select *select;
5464
5155
            LEX *lex= Lex;
5465
5156
            lex->lock_option= TL_READ;
5466
5157
            mysql_init_select(lex);
5467
5158
            lex->current_select->parsing_place= SELECT_LIST;
5468
5159
            lex->sql_command= SQLCOM_SELECT;
5469
 
            select= new(std::nothrow) statement::Show(session);
 
5160
            select= new(std::nothrow) statement::Select(session);
5470
5161
            lex->statement= select;
5471
5162
            if (lex->statement == NULL)
5472
5163
              DRIZZLE_YYABORT;
5473
5164
            lex->select_lex.db= 0;
5474
5165
 
5475
 
             util::string::const_shared_ptr schema(session->schema());
5476
5166
             if ($2->db.str)
5477
 
             {
5478
 
               select->setShowPredicate($2->db.str, $2->table.str);
5479
 
             }
5480
 
             else if (schema)
5481
 
             {
5482
 
               select->setShowPredicate(*schema, $2->table.str);
5483
 
             }
 
5167
              select->setShowPredicate($2->db.str, $2->table.str);
5484
5168
             else
5485
 
             {
5486
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5487
 
               DRIZZLE_YYABORT;
5488
 
             }
 
5169
              select->setShowPredicate(session->db, $2->table.str);
5489
5170
 
5490
5171
             {
5491
5172
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $2->table.str);
5503
5184
             if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5504
5185
                                                           context,
5505
5186
                                                           NULL, NULL, "*")))
5506
 
             {
5507
5187
               DRIZZLE_YYABORT;
5508
 
             }
5509
5188
             (session->lex->current_select->with_wild)++;
5510
5189
 
5511
5190
          }
5584
5263
            statement::Flush *statement= (statement::Flush*)Lex->statement;
5585
5264
            statement->setFlushStatus(true);
5586
5265
          }
5587
 
        | GLOBAL_SYM STATUS_SYM
5588
 
          {
5589
 
            statement::Flush *statement= (statement::Flush*)Lex->statement;
5590
 
            statement->setFlushGlobalStatus(true);
5591
 
          }
5592
5266
        ;
5593
5267
 
5594
5268
opt_table_list:
5602
5276
          KILL_SYM kill_option expr
5603
5277
          {
5604
5278
            LEX *lex=Lex;
5605
 
 
5606
 
            if ($2)
5607
 
            {
5608
 
              Lex->type= ONLY_KILL_QUERY;
5609
 
            }
5610
 
            else
5611
 
            {
5612
 
              Lex->type= 0;
5613
 
            }
5614
 
 
5615
5279
            lex->value_list.empty();
5616
5280
            lex->value_list.push_front($3);
5617
5281
            lex->sql_command= SQLCOM_KILL;
5622
5286
        ;
5623
5287
 
5624
5288
kill_option:
5625
 
          /* empty */ { $$= 0; }
5626
 
        | CONNECTION_SYM { $$= 0; }
5627
 
        | QUERY_SYM      { $$= 1; }
 
5289
          /* empty */ { Lex->type= 0; }
 
5290
        | CONNECTION_SYM { Lex->type= 0; }
 
5291
        | QUERY_SYM      { Lex->type= ONLY_KILL_QUERY; }
5628
5292
        ;
5629
5293
 
5630
5294
/* change database */
6023
5687
          {
6024
5688
            TableList *table=
6025
5689
              reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
6026
 
            if (my_strcasecmp(table_alias_charset, $1.str, table->getSchemaName()))
 
5690
            if (my_strcasecmp(table_alias_charset, $1.str, table->db))
6027
5691
            {
6028
5692
              my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
6029
5693
              DRIZZLE_YYABORT;
6030
5694
            }
6031
5695
            if (my_strcasecmp(table_alias_charset, $3.str,
6032
 
                              table->getTableName()))
 
5696
                              table->table_name))
6033
5697
            {
6034
5698
              my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
6035
5699
              DRIZZLE_YYABORT;
6153
5817
        | AVG_ROW_LENGTH           {}
6154
5818
        | AVG_SYM                  {}
6155
5819
        | BIT_SYM                  {}
 
5820
        | BLOCK_SIZE_SYM           {}
 
5821
        | BLOCK_SYM                {}
6156
5822
        | BOOL_SYM                 {}
6157
5823
        | BOOLEAN_SYM              {}
6158
5824
        | BTREE_SYM                {}
6254
5920
        | SESSION_SYM              {}
6255
5921
        | SIMPLE_SYM               {}
6256
5922
        | SHARE_SYM                {}
 
5923
        | SHUTDOWN                 {}
6257
5924
        | SNAPSHOT_SYM             {}
6258
5925
        | SQL_BUFFER_RESULT        {}
6259
5926
        | STATUS_SYM               {}
6372
6039
            LEX *lex=Lex;
6373
6040
            lex->option_type= $1;
6374
6041
            lex->var_list.push_back(new set_var(lex->option_type,
6375
 
                                                find_sys_var("tx_isolation"),
 
6042
                                                find_sys_var(YYSession, "tx_isolation"),
6376
6043
                                                &null_lex_str,
6377
6044
                                                new Item_int((int32_t) $5)));
6378
6045
          }
6393
6060
internal_variable_name:
6394
6061
          ident
6395
6062
          {
 
6063
            Session *session= YYSession;
 
6064
 
6396
6065
            /* We have to lookup here since local vars can shadow sysvars */
6397
6066
            {
6398
6067
              /* Not an SP local variable */
6399
 
              sys_var *tmp=find_sys_var($1.str, $1.length);
 
6068
              sys_var *tmp=find_sys_var(session, $1.str, $1.length);
6400
6069
              if (!tmp)
6401
6070
                DRIZZLE_YYABORT;
6402
6071
              $$.var= tmp;
6549
6218
union_list:
6550
6219
          UNION_SYM union_option
6551
6220
          {
6552
 
            if (add_select_to_union_list(YYSession, Lex, (bool)$2))
 
6221
            if (add_select_to_union_list(Lex, (bool)$2))
6553
6222
              DRIZZLE_YYABORT;
6554
6223
          }
6555
6224
          select_init
6619
6288
        | query_expression_body
6620
6289
          UNION_SYM union_option
6621
6290
          {
6622
 
            if (add_select_to_union_list(YYSession, Lex, (bool)$3))
 
6291
            if (add_select_to_union_list(Lex, (bool)$3))
6623
6292
              DRIZZLE_YYABORT;
6624
6293
          }
6625
6294
          query_specification
6642
6311
            LEX *lex=Lex;
6643
6312
            if (!lex->expr_allows_subselect)
6644
6313
            {
6645
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
6646
 
              my_parse_error(&pass);
 
6314
              my_parse_error(ER(ER_SYNTAX_ERROR));
6647
6315
              DRIZZLE_YYABORT;
6648
6316
            }
6649
6317
            /*