MDEV-13197 Parser refactoring for CREATE VIEW,TRIGGER,SP,UDF,EVENT
This commit is contained in:
parent
505a11d9ac
commit
96d1cdecbe
@ -6501,3 +6501,14 @@ DROP VIEW v;
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
#
|
||||
# Start of 10.3 tests
|
||||
#
|
||||
#
|
||||
# MDEV-13197 Parser refactoring for CREATE VIEW,TRIGGER,SP,UDF,EVENT
|
||||
#
|
||||
ALTER VIEW IF NOT EXISTS v1 AS SELECT 1;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS v1 AS SELECT 1' at line 1
|
||||
#
|
||||
# End of 10.3 tests
|
||||
#
|
||||
|
@ -6213,3 +6213,19 @@ DROP VIEW v;
|
||||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.3 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-13197 Parser refactoring for CREATE VIEW,TRIGGER,SP,UDF,EVENT
|
||||
--echo #
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
ALTER VIEW IF NOT EXISTS v1 AS SELECT 1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.3 tests
|
||||
--echo #
|
||||
|
@ -689,6 +689,7 @@ void LEX::start(THD *thd_arg)
|
||||
curr_with_clause= 0;
|
||||
with_clauses_list= 0;
|
||||
with_clauses_list_last_next= &with_clauses_list;
|
||||
create_view= NULL;
|
||||
value_list.empty();
|
||||
update_list.empty();
|
||||
set_var_list.empty();
|
||||
@ -7057,3 +7058,49 @@ bool LEX::sp_add_cfetch(THD *thd, const LEX_CSTRING *name)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LEX::create_or_alter_view_finalize(THD *thd, Table_ident *table_ident)
|
||||
{
|
||||
sql_command= SQLCOM_CREATE_VIEW;
|
||||
/* first table in list is target VIEW name */
|
||||
if (!select_lex.add_table_to_list(thd, table_ident, NULL,
|
||||
TL_OPTION_UPDATING,
|
||||
TL_IGNORE,
|
||||
MDL_EXCLUSIVE))
|
||||
return true;
|
||||
query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LEX::add_alter_view(THD *thd, uint16 algorithm,
|
||||
enum_view_suid suid,
|
||||
Table_ident *table_ident)
|
||||
{
|
||||
if (sphead)
|
||||
{
|
||||
my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW");
|
||||
return true;
|
||||
}
|
||||
if (!(create_view= new (thd->mem_root)
|
||||
Create_view_info(VIEW_ALTER, algorithm, suid)))
|
||||
return true;
|
||||
return create_or_alter_view_finalize(thd, table_ident);
|
||||
}
|
||||
|
||||
|
||||
bool LEX::add_create_view(THD *thd, DDL_options_st ddl,
|
||||
uint16 algorithm, enum_view_suid suid,
|
||||
Table_ident *table_ident)
|
||||
{
|
||||
if (set_create_options_with_check(ddl))
|
||||
return true;
|
||||
if (!(create_view= new (thd->mem_root)
|
||||
Create_view_info(ddl.or_replace() ?
|
||||
VIEW_CREATE_OR_REPLACE :
|
||||
VIEW_CREATE_NEW,
|
||||
algorithm, suid)))
|
||||
return true;
|
||||
return create_or_alter_view_finalize(thd, table_ident);
|
||||
}
|
||||
|
@ -75,6 +75,14 @@ enum sub_select_type
|
||||
GLOBAL_OPTIONS_TYPE, DERIVED_TABLE_TYPE, OLAP_TYPE
|
||||
};
|
||||
enum unit_common_op {OP_MIX, OP_UNION, OP_INTERSECT, OP_EXCEPT};
|
||||
|
||||
enum enum_view_suid
|
||||
{
|
||||
VIEW_SUID_INVOKER= 0,
|
||||
VIEW_SUID_DEFINER= 1,
|
||||
VIEW_SUID_DEFAULT= 2
|
||||
};
|
||||
|
||||
/* These may not be declared yet */
|
||||
class Table_ident;
|
||||
class sql_exchange;
|
||||
@ -98,7 +106,6 @@ struct sql_digest_state;
|
||||
class With_clause;
|
||||
class my_var;
|
||||
|
||||
|
||||
#define ALLOC_ROOT_SET 1024
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
@ -239,6 +246,27 @@ enum enum_view_create_mode
|
||||
VIEW_CREATE_OR_REPLACE // check only that there are not such table
|
||||
};
|
||||
|
||||
|
||||
class Create_view_info: public Sql_alloc
|
||||
{
|
||||
public:
|
||||
LEX_CSTRING select; // The SELECT statement of CREATE VIEW
|
||||
enum enum_view_create_mode mode;
|
||||
uint16 algorithm;
|
||||
uint8 check;
|
||||
enum enum_view_suid suid;
|
||||
Create_view_info(enum_view_create_mode mode_arg,
|
||||
uint16 algorithm_arg,
|
||||
enum_view_suid suid_arg)
|
||||
:select(null_clex_str),
|
||||
mode(mode_arg),
|
||||
algorithm(algorithm_arg),
|
||||
check(VIEW_CHECK_NONE),
|
||||
suid(suid_arg)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
enum enum_drop_mode
|
||||
{
|
||||
DROP_DEFAULT, // mode is not specified
|
||||
@ -2607,6 +2635,8 @@ struct LEX: public Query_tables_list
|
||||
*/
|
||||
With_clause **with_clauses_list_last_next;
|
||||
|
||||
Create_view_info *create_view;
|
||||
|
||||
/* Query Plan Footprint of a currently running select */
|
||||
Explain_query *explain;
|
||||
|
||||
@ -2630,9 +2660,6 @@ struct LEX: public Query_tables_list
|
||||
DYNAMIC_ARRAY plugins;
|
||||
plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
|
||||
|
||||
/** SELECT of CREATE VIEW statement */
|
||||
LEX_CSTRING create_view_select;
|
||||
|
||||
uint number_of_selects; // valid only for view
|
||||
|
||||
/** Start of 'ON table', in trigger statements. */
|
||||
@ -2759,7 +2786,6 @@ public:
|
||||
bool with_persistent_for_clause; // uses PERSISTENT FOR clause (in ANALYZE)
|
||||
};
|
||||
enum enum_var_type option_type;
|
||||
enum enum_view_create_mode create_view_mode;
|
||||
enum enum_drop_mode drop_mode;
|
||||
|
||||
uint profile_query_id;
|
||||
@ -2785,8 +2811,6 @@ public:
|
||||
DERIVED_SUBQUERY and DERIVED_VIEW).
|
||||
*/
|
||||
uint8 derived_tables;
|
||||
uint16 create_view_algorithm;
|
||||
uint8 create_view_check;
|
||||
uint8 context_analysis_only;
|
||||
bool local_file;
|
||||
bool check_exists;
|
||||
@ -2827,10 +2851,6 @@ public:
|
||||
rexecuton
|
||||
*/
|
||||
bool empty_field_list_on_rset;
|
||||
/*
|
||||
view created to be run from definer (standard behaviour)
|
||||
*/
|
||||
uint8 create_view_suid;
|
||||
/* Characterstics of trigger being created */
|
||||
st_trg_chistics trg_chistics;
|
||||
/*
|
||||
@ -3582,6 +3602,11 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool set_create_options_with_check(DDL_options_st options)
|
||||
{
|
||||
create_info.set(options);
|
||||
return check_create_options(create_info);
|
||||
}
|
||||
bool add_create_options_with_check(DDL_options_st options)
|
||||
{
|
||||
create_info.add(options);
|
||||
@ -3613,6 +3638,12 @@ public:
|
||||
SELECT_LEX *exclude_last_select();
|
||||
bool add_unit_in_brackets(SELECT_LEX *nselect);
|
||||
void check_automatic_up(enum sub_select_type type);
|
||||
bool create_or_alter_view_finalize(THD *thd, Table_ident *table_ident);
|
||||
bool add_alter_view(THD *thd, uint16 algorithm, enum_view_suid suid,
|
||||
Table_ident *table_ident);
|
||||
bool add_create_view(THD *thd, DDL_options_st ddl,
|
||||
uint16 algorithm, enum_view_suid suid,
|
||||
Table_ident *table_ident);
|
||||
};
|
||||
|
||||
|
||||
|
@ -6033,10 +6033,10 @@ end_with_restore_list:
|
||||
{
|
||||
/*
|
||||
Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands
|
||||
as specified through the thd->lex->create_view_mode flag.
|
||||
as specified through the thd->lex->create_view->mode flag.
|
||||
*/
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
|
||||
res= mysql_create_view(thd, first_table, thd->lex->create_view_mode);
|
||||
res= mysql_create_view(thd, first_table, thd->lex->create_view->mode);
|
||||
break;
|
||||
}
|
||||
case SQLCOM_DROP_VIEW:
|
||||
|
@ -2072,7 +2072,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
|
||||
TABLE_LIST *view= lex->unlink_first_table(&link_to_local);
|
||||
TABLE_LIST *tables= lex->query_tables;
|
||||
|
||||
if (create_view_precheck(thd, tables, view, lex->create_view_mode))
|
||||
if (create_view_precheck(thd, tables, view, lex->create_view->mode))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
@ -2448,7 +2448,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
|
||||
}
|
||||
break;
|
||||
case SQLCOM_CREATE_VIEW:
|
||||
if (lex->create_view_mode == VIEW_ALTER)
|
||||
if (lex->create_view->mode == VIEW_ALTER)
|
||||
{
|
||||
my_message(ER_UNSUPPORTED_PS, ER_THD(thd, ER_UNSUPPORTED_PS), MYF(0));
|
||||
goto error;
|
||||
|
@ -225,10 +225,10 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view)
|
||||
view->definer.user= decoy.definer.user;
|
||||
lex->definer= &view->definer;
|
||||
}
|
||||
if (lex->create_view_algorithm == VIEW_ALGORITHM_INHERIT)
|
||||
lex->create_view_algorithm= (uint8) decoy.algorithm;
|
||||
if (lex->create_view_suid == VIEW_SUID_DEFAULT)
|
||||
lex->create_view_suid= decoy.view_suid ?
|
||||
if (lex->create_view->algorithm == VIEW_ALGORITHM_INHERIT)
|
||||
lex->create_view->algorithm= (uint8) decoy.algorithm;
|
||||
if (lex->create_view->suid == VIEW_SUID_DEFAULT)
|
||||
lex->create_view->suid= decoy.view_suid ?
|
||||
VIEW_SUID_DEFINER : VIEW_SUID_INVOKER;
|
||||
|
||||
return FALSE;
|
||||
@ -647,8 +647,8 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
|
||||
{ C_STRING_WITH_LEN("ALTER ") },
|
||||
{ C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
|
||||
|
||||
buff.append(command[thd->lex->create_view_mode].str,
|
||||
command[thd->lex->create_view_mode].length);
|
||||
buff.append(command[thd->lex->create_view->mode].str,
|
||||
command[thd->lex->create_view->mode].length);
|
||||
view_store_options(thd, views, &buff);
|
||||
buff.append(STRING_WITH_LEN("VIEW "));
|
||||
|
||||
@ -934,7 +934,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
|
||||
DBUG_PRINT("info", ("View: %.*s", view_query.length(), view_query.ptr()));
|
||||
|
||||
/* fill structure */
|
||||
view->source= thd->lex->create_view_select;
|
||||
view->source= thd->lex->create_view->select;
|
||||
|
||||
if (!thd->make_lex_string(&view->select_stmt, view_query.ptr(),
|
||||
view_query.length()))
|
||||
@ -959,18 +959,18 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
|
||||
}
|
||||
view->md5.length= 32;
|
||||
can_be_merged= lex->can_be_merged();
|
||||
if (lex->create_view_algorithm == VIEW_ALGORITHM_MERGE &&
|
||||
if (lex->create_view->algorithm == VIEW_ALGORITHM_MERGE &&
|
||||
!lex->can_be_merged())
|
||||
{
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_VIEW_MERGE,
|
||||
ER_THD(thd, ER_WARN_VIEW_MERGE));
|
||||
lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
|
||||
lex->create_view->algorithm= DTYPE_ALGORITHM_UNDEFINED;
|
||||
}
|
||||
view->algorithm= lex->create_view_algorithm;
|
||||
view->algorithm= lex->create_view->algorithm;
|
||||
view->definer.user= lex->definer->user;
|
||||
view->definer.host= lex->definer->host;
|
||||
view->view_suid= lex->create_view_suid;
|
||||
view->with_check= lex->create_view_check;
|
||||
view->view_suid= lex->create_view->suid;
|
||||
view->with_check= lex->create_view->check;
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_register_view_failure",
|
||||
{
|
||||
|
279
sql/sql_yacc.yy
279
sql/sql_yacc.yy
@ -828,6 +828,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
|
||||
st_trg_execution_order trg_execution_order;
|
||||
|
||||
/* enums */
|
||||
enum enum_view_suid view_suid;
|
||||
enum sub_select_type unit_type;
|
||||
enum Condition_information_item::Name cond_info_item_name;
|
||||
enum enum_diag_condition_item_name diag_condition_item_name;
|
||||
@ -1679,7 +1680,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
opt_recursive
|
||||
|
||||
%type <object_ddl_options>
|
||||
create_or_replace
|
||||
create_or_replace
|
||||
opt_if_not_exists
|
||||
opt_if_exists
|
||||
|
||||
@ -1886,11 +1887,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
statement sp_suid
|
||||
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa
|
||||
opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
|
||||
view_algorithm view_or_trigger_or_sp_or_event
|
||||
definer_tail no_definer_tail
|
||||
view_suid view_tail view_list_opt view_list view_select
|
||||
view_check_option trigger_tail sp_tail sf_tail event_tail
|
||||
udf_tail udf_tail2
|
||||
view_list_opt view_list view_select
|
||||
trigger_tail sp_tail sf_tail event_tail
|
||||
udf_tail create_function_tail
|
||||
install uninstall partition_entry binlog_base64_event
|
||||
normal_key_options normal_key_opts all_key_opt
|
||||
spatial_key_options fulltext_key_options normal_key_opt
|
||||
@ -1919,6 +1918,9 @@ END_OF_INPUT
|
||||
%type <NONE> case_stmt_specification
|
||||
%type <NONE> loop_body while_body repeat_body
|
||||
|
||||
%type <num> view_algorithm view_check_option
|
||||
%type <view_suid> view_suid opt_view_suid
|
||||
|
||||
%type <num> sp_decl_idents sp_decl_idents_init_vars
|
||||
%type <num> sp_handler_type sp_hcond_list
|
||||
%type <spcondvalue> sp_cond sp_hcond sqlstate signal_value opt_signal_value
|
||||
@ -2580,15 +2582,50 @@ create:
|
||||
MYSQL_YYABORT;
|
||||
lex->name= $4;
|
||||
}
|
||||
| create_or_replace
|
||||
| create_or_replace definer_opt opt_view_suid VIEW_SYM
|
||||
opt_if_not_exists table_ident
|
||||
{
|
||||
if (Lex->add_create_view(thd, $1 | $5,
|
||||
DTYPE_ALGORITHM_UNDEFINED, $3, $6))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
{ }
|
||||
| create_or_replace view_algorithm definer_opt opt_view_suid VIEW_SYM
|
||||
opt_if_not_exists table_ident
|
||||
{
|
||||
if (Lex->add_create_view(thd, $1 | $6, $2, $4, $7))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
{ }
|
||||
| create_or_replace definer_opt TRIGGER_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
trigger_tail
|
||||
{ }
|
||||
| create_or_replace definer_opt PROCEDURE_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
sp_tail
|
||||
{ }
|
||||
| create_or_replace definer_opt EVENT_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
event_tail
|
||||
{ }
|
||||
| create_or_replace definer FUNCTION_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
sf_tail
|
||||
{ }
|
||||
| create_or_replace no_definer FUNCTION_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
create_function_tail
|
||||
{ }
|
||||
| create_or_replace no_definer AGGREGATE_SYM FUNCTION_SYM
|
||||
{
|
||||
Lex->create_info.set($1);
|
||||
Lex->create_view_mode= ($1.or_replace() ? VIEW_CREATE_OR_REPLACE :
|
||||
VIEW_CREATE_NEW);
|
||||
Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
|
||||
Lex->create_view_suid= TRUE;
|
||||
Lex->udf.type= UDFTYPE_AGGREGATE;
|
||||
}
|
||||
view_or_trigger_or_sp_or_event { }
|
||||
udf_tail
|
||||
{ }
|
||||
| create_or_replace USER_SYM opt_if_not_exists clear_privileges grant_list
|
||||
opt_require_clause opt_resource_options
|
||||
{
|
||||
@ -2614,6 +2651,11 @@ create:
|
||||
{ }
|
||||
;
|
||||
|
||||
create_function_tail:
|
||||
sf_tail { }
|
||||
| udf_tail { Lex->udf.type= UDFTYPE_FUNCTION; }
|
||||
;
|
||||
|
||||
opt_sequence:
|
||||
/* empty */ { }
|
||||
| sequence_defs
|
||||
@ -2767,16 +2809,16 @@ server_option:
|
||||
;
|
||||
|
||||
event_tail:
|
||||
remember_name EVENT_SYM opt_if_not_exists sp_name
|
||||
remember_name opt_if_not_exists sp_name
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
|
||||
lex->stmt_definition_begin= $1;
|
||||
if (lex->add_create_options_with_check($3))
|
||||
if (lex->add_create_options_with_check($2))
|
||||
MYSQL_YYABORT;
|
||||
if (!(lex->event_parse_data= Event_parse_data::new_instance(thd)))
|
||||
MYSQL_YYABORT;
|
||||
lex->event_parse_data->identifier= $4;
|
||||
lex->event_parse_data->identifier= $3;
|
||||
lex->event_parse_data->on_completion=
|
||||
Event_parse_data::ON_COMPLETION_DROP;
|
||||
|
||||
@ -7223,31 +7265,24 @@ alter:
|
||||
lex->sql_command= SQLCOM_ALTER_FUNCTION;
|
||||
lex->spname= $3;
|
||||
}
|
||||
| ALTER view_algorithm definer_opt
|
||||
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"));
|
||||
lex->create_view_mode= VIEW_ALTER;
|
||||
if (Lex->add_alter_view(thd, $2, $4, $6))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_tail
|
||||
view_list_opt AS view_select
|
||||
{}
|
||||
| ALTER definer_opt
|
||||
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident
|
||||
/*
|
||||
We have two separate rules for ALTER VIEW rather that
|
||||
optional view_algorithm above, to resolve the ambiguity
|
||||
with the ALTER EVENT below.
|
||||
*/
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"));
|
||||
lex->create_view_algorithm= VIEW_ALGORITHM_INHERIT;
|
||||
lex->create_view_mode= VIEW_ALTER;
|
||||
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_tail
|
||||
view_list_opt AS view_select
|
||||
{}
|
||||
| ALTER definer_opt remember_name EVENT_SYM sp_name
|
||||
{
|
||||
@ -16364,38 +16399,6 @@ query_expression_option:
|
||||
| ALL { Select->options|= SELECT_ALL; }
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
CREATE VIEW | TRIGGER | PROCEDURE statements.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
view_or_trigger_or_sp_or_event:
|
||||
definer definer_tail
|
||||
{}
|
||||
| no_definer no_definer_tail
|
||||
{}
|
||||
| view_algorithm definer_opt view_tail
|
||||
{}
|
||||
;
|
||||
|
||||
definer_tail:
|
||||
view_tail
|
||||
| trigger_tail
|
||||
| sp_tail
|
||||
| sf_tail
|
||||
| event_tail
|
||||
;
|
||||
|
||||
no_definer_tail:
|
||||
view_tail
|
||||
| trigger_tail
|
||||
| sp_tail
|
||||
| sf_tail
|
||||
| udf_tail
|
||||
| event_tail
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
DEFINER clause support.
|
||||
@ -16438,39 +16441,19 @@ definer:
|
||||
**************************************************************************/
|
||||
|
||||
view_algorithm:
|
||||
ALGORITHM_SYM '=' UNDEFINED_SYM
|
||||
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
|
||||
| ALGORITHM_SYM '=' MERGE_SYM
|
||||
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
|
||||
| ALGORITHM_SYM '=' TEMPTABLE_SYM
|
||||
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
|
||||
ALGORITHM_SYM '=' UNDEFINED_SYM { $$= DTYPE_ALGORITHM_UNDEFINED; }
|
||||
| ALGORITHM_SYM '=' MERGE_SYM { $$= VIEW_ALGORITHM_MERGE; }
|
||||
| ALGORITHM_SYM '=' TEMPTABLE_SYM { $$= VIEW_ALGORITHM_TMPTABLE; }
|
||||
;
|
||||
|
||||
opt_view_suid:
|
||||
/* empty */ { $$= VIEW_SUID_DEFAULT; }
|
||||
| view_suid { $$= $1; }
|
||||
;
|
||||
|
||||
view_suid:
|
||||
/* empty */
|
||||
{ Lex->create_view_suid= VIEW_SUID_DEFAULT; }
|
||||
| SQL_SYM SECURITY_SYM DEFINER_SYM
|
||||
{ Lex->create_view_suid= VIEW_SUID_DEFINER; }
|
||||
| SQL_SYM SECURITY_SYM INVOKER_SYM
|
||||
{ Lex->create_view_suid= VIEW_SUID_INVOKER; }
|
||||
;
|
||||
|
||||
view_tail:
|
||||
view_suid VIEW_SYM opt_if_not_exists table_ident
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
if (lex->add_create_options_with_check($3))
|
||||
MYSQL_YYABORT;
|
||||
lex->sql_command= SQLCOM_CREATE_VIEW;
|
||||
/* first table in list is target VIEW name */
|
||||
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
|
||||
TL_OPTION_UPDATING,
|
||||
TL_IGNORE,
|
||||
MDL_EXCLUSIVE))
|
||||
MYSQL_YYABORT;
|
||||
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
SQL_SYM SECURITY_SYM DEFINER_SYM { $$= VIEW_SUID_DEFINER; }
|
||||
| SQL_SYM SECURITY_SYM INVOKER_SYM { $$= VIEW_SUID_INVOKER; }
|
||||
;
|
||||
|
||||
view_list_opt:
|
||||
@ -16498,19 +16481,20 @@ view_select:
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->parsing_options.allows_variable= FALSE;
|
||||
lex->create_view_select.str= (char *) YYLIP->get_cpp_ptr();
|
||||
lex->create_view->select.str= (char *) YYLIP->get_cpp_ptr();
|
||||
}
|
||||
opt_with_clause query_expression_body_view view_check_option
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str;
|
||||
uint len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
|
||||
uint not_used;
|
||||
void *create_view_select= thd->memdup(lex->create_view_select.str, len);
|
||||
lex->create_view_select.length= len;
|
||||
lex->create_view_select.str= (char *) create_view_select;
|
||||
void *create_view_select= thd->memdup(lex->create_view->select.str, len);
|
||||
lex->create_view->select.length= len;
|
||||
lex->create_view->select.str= (char *) create_view_select;
|
||||
trim_whitespace(thd->charset(),
|
||||
&lex->create_view_select,
|
||||
&lex->create_view->select,
|
||||
¬_used);
|
||||
lex->create_view->check= $4;
|
||||
lex->parsing_options.allows_variable= TRUE;
|
||||
lex->current_select->set_with_clause($2);
|
||||
}
|
||||
@ -16528,14 +16512,10 @@ query_expression_body_view:
|
||||
;
|
||||
|
||||
view_check_option:
|
||||
/* empty */
|
||||
{ Lex->create_view_check= VIEW_CHECK_NONE; }
|
||||
| WITH CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
|
||||
| WITH CASCADED CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
|
||||
| WITH LOCAL_SYM CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_LOCAL; }
|
||||
/* empty */ { $$= VIEW_CHECK_NONE; }
|
||||
| WITH CHECK_SYM OPTION { $$= VIEW_CHECK_CASCADED; }
|
||||
| WITH CASCADED CHECK_SYM OPTION { $$= VIEW_CHECK_CASCADED; }
|
||||
| WITH LOCAL_SYM CHECK_SYM OPTION { $$= VIEW_CHECK_LOCAL; }
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
@ -16567,25 +16547,24 @@ trigger_follows_precedes_clause:
|
||||
;
|
||||
|
||||
trigger_tail:
|
||||
TRIGGER_SYM
|
||||
remember_name
|
||||
opt_if_not_exists
|
||||
{
|
||||
if (Lex->add_create_options_with_check($3))
|
||||
if (Lex->add_create_options_with_check($2))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_name
|
||||
trg_action_time
|
||||
trg_event
|
||||
ON
|
||||
remember_name /* $9 */
|
||||
{ /* $10 */
|
||||
remember_name /* $8 */
|
||||
{ /* $9 */
|
||||
Lex->raw_trg_on_table_name_begin= YYLIP->get_tok_start();
|
||||
}
|
||||
table_ident /* $11 */
|
||||
table_ident /* $10 */
|
||||
FOR_SYM
|
||||
remember_name /* $13 */
|
||||
{ /* $14 */
|
||||
remember_name /* $12 */
|
||||
{ /* $13 */
|
||||
Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
|
||||
}
|
||||
EACH_SYM
|
||||
@ -16593,28 +16572,28 @@ trigger_tail:
|
||||
{
|
||||
Lex->trg_chistics.ordering_clause_begin= YYLIP->get_cpp_ptr();
|
||||
}
|
||||
trigger_follows_precedes_clause /* $18 */
|
||||
{ /* $19 */
|
||||
trigger_follows_precedes_clause /* $17 */
|
||||
{ /* $18 */
|
||||
LEX *lex= thd->lex;
|
||||
Lex_input_stream *lip= YYLIP;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER"));
|
||||
|
||||
lex->stmt_definition_begin= $2;
|
||||
lex->ident.str= $9;
|
||||
lex->ident.length= $13 - $9;
|
||||
lex->spname= $5;
|
||||
(*static_cast<st_trg_execution_order*>(&lex->trg_chistics))= ($18);
|
||||
lex->stmt_definition_begin= $1;
|
||||
lex->ident.str= $8;
|
||||
lex->ident.length= $12 - $8;
|
||||
lex->spname= $4;
|
||||
(*static_cast<st_trg_execution_order*>(&lex->trg_chistics))= ($17);
|
||||
lex->trg_chistics.ordering_clause_end= lip->get_cpp_ptr();
|
||||
|
||||
if (!lex->make_sp_head(thd, $5, TYPE_ENUM_TRIGGER))
|
||||
if (!lex->make_sp_head(thd, $4, TYPE_ENUM_TRIGGER))
|
||||
MYSQL_YYABORT;
|
||||
|
||||
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
|
||||
}
|
||||
sp_proc_stmt /* $20 */
|
||||
{ /* $21 */
|
||||
sp_proc_stmt /* $19 */
|
||||
{ /* $20 */
|
||||
LEX *lex= Lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
|
||||
@ -16630,7 +16609,7 @@ trigger_tail:
|
||||
sp_proc_stmt alternatives are not saving/restoring LEX, so
|
||||
lex->query_tables can be wiped out.
|
||||
*/
|
||||
if (!lex->select_lex.add_table_to_list(thd, $11,
|
||||
if (!lex->select_lex.add_table_to_list(thd, $10,
|
||||
(LEX_CSTRING*) 0,
|
||||
TL_OPTION_UPDATING,
|
||||
TL_READ_NO_INSERT,
|
||||
@ -16646,57 +16625,51 @@ trigger_tail:
|
||||
**************************************************************************/
|
||||
|
||||
udf_tail:
|
||||
AGGREGATE_SYM udf_tail2 { thd->lex->udf.type= UDFTYPE_AGGREGATE; }
|
||||
| udf_tail2 { thd->lex->udf.type= UDFTYPE_FUNCTION; }
|
||||
;
|
||||
|
||||
udf_tail2:
|
||||
FUNCTION_SYM opt_if_not_exists ident
|
||||
opt_if_not_exists ident
|
||||
RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
if (lex->add_create_options_with_check($2))
|
||||
if (lex->add_create_options_with_check($1))
|
||||
MYSQL_YYABORT;
|
||||
if (is_native_function(thd, & $3))
|
||||
my_yyabort_error((ER_NATIVE_FCT_NAME_COLLISION, MYF(0), $3.str));
|
||||
if (is_native_function(thd, & $2))
|
||||
my_yyabort_error((ER_NATIVE_FCT_NAME_COLLISION, MYF(0), $2.str));
|
||||
lex->sql_command= SQLCOM_CREATE_FUNCTION;
|
||||
lex->udf.name= $3;
|
||||
lex->udf.returns= (Item_result) $5;
|
||||
lex->udf.dl= $7.str;
|
||||
lex->udf.name= $2;
|
||||
lex->udf.returns= (Item_result) $4;
|
||||
lex->udf.dl= $6.str;
|
||||
}
|
||||
;
|
||||
|
||||
sf_tail:
|
||||
FUNCTION_SYM /* $1 */
|
||||
opt_if_not_exists /* $2 */
|
||||
sp_name /* $3 */
|
||||
{ /* $4 */
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
|
||||
opt_if_not_exists /* $1 */
|
||||
sp_name /* $2 */
|
||||
{ /* $3 */
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
|
||||
TYPE_ENUM_FUNCTION))
|
||||
MYSQL_YYABORT;
|
||||
Lex->spname= $3;
|
||||
Lex->spname= $2;
|
||||
}
|
||||
sp_parenthesized_fdparam_list /* $5 */
|
||||
RETURNS_SYM /* $6 */
|
||||
{ /* $7 */
|
||||
sp_parenthesized_fdparam_list /* $4 */
|
||||
RETURNS_SYM /* $5 */
|
||||
{ /* $6 */
|
||||
LEX *lex= Lex;
|
||||
lex->init_last_field(&lex->sphead->m_return_field_def,
|
||||
&empty_clex_str,
|
||||
thd->variables.collation_database);
|
||||
}
|
||||
type_with_opt_collate /* $8 */
|
||||
{ /* $9 */
|
||||
type_with_opt_collate /* $7 */
|
||||
{ /* $8 */
|
||||
if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_c_chistics /* $10 */
|
||||
{ /* $11 */
|
||||
sp_c_chistics /* $9 */
|
||||
{ /* $10 */
|
||||
LEX *lex= thd->lex;
|
||||
Lex_input_stream *lip= YYLIP;
|
||||
|
||||
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
|
||||
}
|
||||
sp_proc_stmt_in_returns_clause /* $12 */
|
||||
sp_proc_stmt_in_returns_clause /* $11 */
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
@ -16715,12 +16688,12 @@ sf_tail:
|
||||
;
|
||||
|
||||
sp_tail:
|
||||
PROCEDURE_SYM opt_if_not_exists sp_name
|
||||
opt_if_not_exists sp_name
|
||||
{
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
|
||||
TYPE_ENUM_PROCEDURE))
|
||||
MYSQL_YYABORT;
|
||||
Lex->spname= $3;
|
||||
Lex->spname= $2;
|
||||
}
|
||||
sp_parenthesized_pdparam_list
|
||||
sp_c_chistics
|
||||
|
@ -237,6 +237,7 @@ void ORAerror(THD *thd, const char *s)
|
||||
st_trg_execution_order trg_execution_order;
|
||||
|
||||
/* enums */
|
||||
enum enum_view_suid view_suid;
|
||||
enum sub_select_type unit_type;
|
||||
enum Condition_information_item::Name cond_info_item_name;
|
||||
enum enum_diag_condition_item_name diag_condition_item_name;
|
||||
@ -1097,7 +1098,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
type_or_rowtype
|
||||
|
||||
%type <object_ddl_options>
|
||||
create_or_replace
|
||||
create_or_replace
|
||||
opt_if_not_exists
|
||||
opt_if_exists
|
||||
|
||||
@ -1312,11 +1313,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
statement sp_suid
|
||||
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa
|
||||
opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
|
||||
view_algorithm view_or_trigger_or_sp_or_event
|
||||
definer_tail no_definer_tail
|
||||
view_suid view_tail view_list_opt view_list view_select
|
||||
view_check_option trigger_tail sp_tail sf_tail event_tail
|
||||
udf_tail udf_tail2
|
||||
view_list_opt view_list view_select
|
||||
trigger_tail sp_tail sf_tail event_tail
|
||||
udf_tail create_function_tail
|
||||
install uninstall partition_entry binlog_base64_event
|
||||
normal_key_options normal_key_opts all_key_opt
|
||||
spatial_key_options fulltext_key_options normal_key_opt
|
||||
@ -1351,6 +1350,9 @@ END_OF_INPUT
|
||||
%type <NONE> case_stmt_specification
|
||||
%type <NONE> loop_body while_body repeat_body
|
||||
|
||||
%type <num> view_algorithm view_check_option
|
||||
%type <view_suid> view_suid opt_view_suid
|
||||
|
||||
%type <num> sp_decl_idents sp_handler_type sp_hcond_list
|
||||
%type <spcondvalue> sp_cond sp_hcond sqlstate signal_value opt_signal_value
|
||||
%type <spblock> sp_decl_body_list opt_sp_decl_body_list
|
||||
@ -2021,15 +2023,50 @@ create:
|
||||
MYSQL_YYABORT;
|
||||
lex->name= $4;
|
||||
}
|
||||
| create_or_replace
|
||||
| create_or_replace definer_opt opt_view_suid VIEW_SYM
|
||||
opt_if_not_exists table_ident
|
||||
{
|
||||
if (Lex->add_create_view(thd, $1 | $5,
|
||||
DTYPE_ALGORITHM_UNDEFINED, $3, $6))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
{ }
|
||||
| create_or_replace view_algorithm definer_opt opt_view_suid VIEW_SYM
|
||||
opt_if_not_exists table_ident
|
||||
{
|
||||
if (Lex->add_create_view(thd, $1 | $6, $2, $4, $7))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
{ }
|
||||
| create_or_replace definer_opt TRIGGER_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
trigger_tail
|
||||
{ }
|
||||
| create_or_replace definer_opt PROCEDURE_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
sp_tail_standalone
|
||||
{ }
|
||||
| create_or_replace definer_opt EVENT_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
event_tail
|
||||
{ }
|
||||
| create_or_replace definer FUNCTION_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
sf_tail_standalone
|
||||
{ }
|
||||
| create_or_replace no_definer FUNCTION_SYM
|
||||
{ Lex->create_info.set($1); }
|
||||
create_function_tail
|
||||
{ }
|
||||
| create_or_replace no_definer AGGREGATE_SYM FUNCTION_SYM
|
||||
{
|
||||
Lex->create_info.set($1);
|
||||
Lex->create_view_mode= ($1.or_replace() ? VIEW_CREATE_OR_REPLACE :
|
||||
VIEW_CREATE_NEW);
|
||||
Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
|
||||
Lex->create_view_suid= TRUE;
|
||||
Lex->udf.type= UDFTYPE_AGGREGATE;
|
||||
}
|
||||
view_or_trigger_or_sp_or_event { }
|
||||
udf_tail
|
||||
{ }
|
||||
| create_or_replace USER_SYM opt_if_not_exists clear_privileges grant_list
|
||||
opt_require_clause opt_resource_options
|
||||
{
|
||||
@ -2055,6 +2092,11 @@ create:
|
||||
{ }
|
||||
;
|
||||
|
||||
create_function_tail:
|
||||
sf_tail_standalone { }
|
||||
| udf_tail { Lex->udf.type= UDFTYPE_FUNCTION; }
|
||||
;
|
||||
|
||||
opt_sequence:
|
||||
/* empty */ { }
|
||||
| sequence_defs
|
||||
@ -2208,16 +2250,16 @@ server_option:
|
||||
;
|
||||
|
||||
event_tail:
|
||||
remember_name EVENT_SYM opt_if_not_exists sp_name
|
||||
remember_name opt_if_not_exists sp_name
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
|
||||
lex->stmt_definition_begin= $1;
|
||||
if (lex->add_create_options_with_check($3))
|
||||
if (lex->add_create_options_with_check($2))
|
||||
MYSQL_YYABORT;
|
||||
if (!(lex->event_parse_data= Event_parse_data::new_instance(thd)))
|
||||
MYSQL_YYABORT;
|
||||
lex->event_parse_data->identifier= $4;
|
||||
lex->event_parse_data->identifier= $3;
|
||||
lex->event_parse_data->on_completion=
|
||||
Event_parse_data::ON_COMPLETION_DROP;
|
||||
|
||||
@ -7203,31 +7245,24 @@ alter:
|
||||
lex->sql_command= SQLCOM_ALTER_FUNCTION;
|
||||
lex->spname= $3;
|
||||
}
|
||||
| ALTER view_algorithm definer_opt
|
||||
| ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"));
|
||||
lex->create_view_mode= VIEW_ALTER;
|
||||
if (Lex->add_alter_view(thd, $2, $4, $6))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_tail
|
||||
view_list_opt AS view_select
|
||||
{}
|
||||
| ALTER definer_opt
|
||||
| ALTER definer_opt opt_view_suid VIEW_SYM table_ident
|
||||
/*
|
||||
We have two separate rules for ALTER VIEW rather that
|
||||
optional view_algorithm above, to resolve the ambiguity
|
||||
with the ALTER EVENT below.
|
||||
*/
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"));
|
||||
lex->create_view_algorithm= VIEW_ALGORITHM_INHERIT;
|
||||
lex->create_view_mode= VIEW_ALTER;
|
||||
if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
view_tail
|
||||
view_list_opt AS view_select
|
||||
{}
|
||||
| ALTER definer_opt remember_name EVENT_SYM sp_name
|
||||
{
|
||||
@ -16600,38 +16635,6 @@ query_expression_option:
|
||||
| ALL { Select->options|= SELECT_ALL; }
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
CREATE VIEW | TRIGGER | PROCEDURE statements.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
view_or_trigger_or_sp_or_event:
|
||||
definer definer_tail
|
||||
{}
|
||||
| no_definer no_definer_tail
|
||||
{}
|
||||
| view_algorithm definer_opt view_tail
|
||||
{}
|
||||
;
|
||||
|
||||
definer_tail:
|
||||
view_tail
|
||||
| trigger_tail
|
||||
| sp_tail_standalone
|
||||
| sf_tail_standalone
|
||||
| event_tail
|
||||
;
|
||||
|
||||
no_definer_tail:
|
||||
view_tail
|
||||
| trigger_tail
|
||||
| sp_tail_standalone
|
||||
| sf_tail_standalone
|
||||
| udf_tail
|
||||
| event_tail
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
DEFINER clause support.
|
||||
@ -16674,39 +16677,19 @@ definer:
|
||||
**************************************************************************/
|
||||
|
||||
view_algorithm:
|
||||
ALGORITHM_SYM '=' UNDEFINED_SYM
|
||||
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
|
||||
| ALGORITHM_SYM '=' MERGE_SYM
|
||||
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
|
||||
| ALGORITHM_SYM '=' TEMPTABLE_SYM
|
||||
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
|
||||
ALGORITHM_SYM '=' UNDEFINED_SYM { $$= DTYPE_ALGORITHM_UNDEFINED; }
|
||||
| ALGORITHM_SYM '=' MERGE_SYM { $$= VIEW_ALGORITHM_MERGE; }
|
||||
| ALGORITHM_SYM '=' TEMPTABLE_SYM { $$= VIEW_ALGORITHM_TMPTABLE; }
|
||||
;
|
||||
|
||||
opt_view_suid:
|
||||
/* empty */ { $$= VIEW_SUID_DEFAULT; }
|
||||
| view_suid { $$= $1; }
|
||||
;
|
||||
|
||||
view_suid:
|
||||
/* empty */
|
||||
{ Lex->create_view_suid= VIEW_SUID_DEFAULT; }
|
||||
| SQL_SYM SECURITY_SYM DEFINER_SYM
|
||||
{ Lex->create_view_suid= VIEW_SUID_DEFINER; }
|
||||
| SQL_SYM SECURITY_SYM INVOKER_SYM
|
||||
{ Lex->create_view_suid= VIEW_SUID_INVOKER; }
|
||||
;
|
||||
|
||||
view_tail:
|
||||
view_suid VIEW_SYM opt_if_not_exists table_ident
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
if (lex->add_create_options_with_check($3))
|
||||
MYSQL_YYABORT;
|
||||
lex->sql_command= SQLCOM_CREATE_VIEW;
|
||||
/* first table in list is target VIEW name */
|
||||
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
|
||||
TL_OPTION_UPDATING,
|
||||
TL_IGNORE,
|
||||
MDL_EXCLUSIVE))
|
||||
MYSQL_YYABORT;
|
||||
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
|
||||
}
|
||||
view_list_opt AS view_select
|
||||
SQL_SYM SECURITY_SYM DEFINER_SYM { $$= VIEW_SUID_DEFINER; }
|
||||
| SQL_SYM SECURITY_SYM INVOKER_SYM { $$= VIEW_SUID_INVOKER; }
|
||||
;
|
||||
|
||||
view_list_opt:
|
||||
@ -16734,19 +16717,20 @@ view_select:
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->parsing_options.allows_variable= FALSE;
|
||||
lex->create_view_select.str= (char *) YYLIP->get_cpp_ptr();
|
||||
lex->create_view->select.str= (char *) YYLIP->get_cpp_ptr();
|
||||
}
|
||||
opt_with_clause query_expression_body_view view_check_option
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str;
|
||||
uint len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
|
||||
uint not_used;
|
||||
void *create_view_select= thd->memdup(lex->create_view_select.str, len);
|
||||
lex->create_view_select.length= len;
|
||||
lex->create_view_select.str= (char *) create_view_select;
|
||||
void *create_view_select= thd->memdup(lex->create_view->select.str, len);
|
||||
lex->create_view->select.length= len;
|
||||
lex->create_view->select.str= (char *) create_view_select;
|
||||
trim_whitespace(thd->charset(),
|
||||
&lex->create_view_select,
|
||||
&lex->create_view->select,
|
||||
¬_used);
|
||||
lex->create_view->check= $4;
|
||||
lex->parsing_options.allows_variable= TRUE;
|
||||
lex->current_select->set_with_clause($2);
|
||||
}
|
||||
@ -16764,14 +16748,10 @@ query_expression_body_view:
|
||||
;
|
||||
|
||||
view_check_option:
|
||||
/* empty */
|
||||
{ Lex->create_view_check= VIEW_CHECK_NONE; }
|
||||
| WITH CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
|
||||
| WITH CASCADED CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
|
||||
| WITH LOCAL_SYM CHECK_SYM OPTION
|
||||
{ Lex->create_view_check= VIEW_CHECK_LOCAL; }
|
||||
/* empty */ { $$= VIEW_CHECK_NONE; }
|
||||
| WITH CHECK_SYM OPTION { $$= VIEW_CHECK_CASCADED; }
|
||||
| WITH CASCADED CHECK_SYM OPTION { $$= VIEW_CHECK_CASCADED; }
|
||||
| WITH LOCAL_SYM CHECK_SYM OPTION { $$= VIEW_CHECK_LOCAL; }
|
||||
;
|
||||
|
||||
/**************************************************************************
|
||||
@ -16803,25 +16783,24 @@ trigger_follows_precedes_clause:
|
||||
;
|
||||
|
||||
trigger_tail:
|
||||
TRIGGER_SYM
|
||||
remember_name
|
||||
opt_if_not_exists
|
||||
{
|
||||
if (Lex->add_create_options_with_check($3))
|
||||
if (Lex->add_create_options_with_check($2))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_name
|
||||
trg_action_time
|
||||
trg_event
|
||||
ON
|
||||
remember_name /* $9 */
|
||||
{ /* $10 */
|
||||
remember_name /* $8 */
|
||||
{ /* $9 */
|
||||
Lex->raw_trg_on_table_name_begin= YYLIP->get_tok_start();
|
||||
}
|
||||
table_ident /* $11 */
|
||||
table_ident /* $10 */
|
||||
FOR_SYM
|
||||
remember_name /* $13 */
|
||||
{ /* $14 */
|
||||
remember_name /* $12 */
|
||||
{ /* $13 */
|
||||
Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
|
||||
}
|
||||
EACH_SYM
|
||||
@ -16829,28 +16808,28 @@ trigger_tail:
|
||||
{
|
||||
Lex->trg_chistics.ordering_clause_begin= YYLIP->get_cpp_ptr();
|
||||
}
|
||||
trigger_follows_precedes_clause /* $18 */
|
||||
{ /* $19 */
|
||||
trigger_follows_precedes_clause /* $17 */
|
||||
{ /* $18 */
|
||||
LEX *lex= thd->lex;
|
||||
Lex_input_stream *lip= YYLIP;
|
||||
|
||||
if (lex->sphead)
|
||||
my_yyabort_error((ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER"));
|
||||
|
||||
lex->stmt_definition_begin= $2;
|
||||
lex->ident.str= $9;
|
||||
lex->ident.length= $13 - $9;
|
||||
lex->spname= $5;
|
||||
(*static_cast<st_trg_execution_order*>(&lex->trg_chistics))= ($18);
|
||||
lex->stmt_definition_begin= $1;
|
||||
lex->ident.str= $8;
|
||||
lex->ident.length= $12 - $8;
|
||||
lex->spname= $4;
|
||||
(*static_cast<st_trg_execution_order*>(&lex->trg_chistics))= ($17);
|
||||
lex->trg_chistics.ordering_clause_end= lip->get_cpp_ptr();
|
||||
|
||||
if (!lex->make_sp_head(thd, $5, TYPE_ENUM_TRIGGER))
|
||||
if (!lex->make_sp_head(thd, $4, TYPE_ENUM_TRIGGER))
|
||||
MYSQL_YYABORT;
|
||||
|
||||
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
|
||||
}
|
||||
sp_proc_stmt /* $20 */
|
||||
{ /* $21 */
|
||||
sp_proc_stmt /* $19 */
|
||||
{ /* $20 */
|
||||
LEX *lex= Lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
if (sp->check_unresolved_goto())
|
||||
@ -16868,7 +16847,7 @@ trigger_tail:
|
||||
sp_proc_stmt alternatives are not saving/restoring LEX, so
|
||||
lex->query_tables can be wiped out.
|
||||
*/
|
||||
if (!lex->select_lex.add_table_to_list(thd, $11,
|
||||
if (!lex->select_lex.add_table_to_list(thd, $10,
|
||||
(LEX_CSTRING*) 0,
|
||||
TL_OPTION_UPDATING,
|
||||
TL_READ_NO_INSERT,
|
||||
@ -16884,58 +16863,52 @@ trigger_tail:
|
||||
**************************************************************************/
|
||||
|
||||
udf_tail:
|
||||
AGGREGATE_SYM udf_tail2 { thd->lex->udf.type= UDFTYPE_AGGREGATE; }
|
||||
| udf_tail2 { thd->lex->udf.type= UDFTYPE_FUNCTION; }
|
||||
;
|
||||
|
||||
udf_tail2:
|
||||
FUNCTION_SYM opt_if_not_exists ident
|
||||
opt_if_not_exists ident
|
||||
RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
if (lex->add_create_options_with_check($2))
|
||||
if (lex->add_create_options_with_check($1))
|
||||
MYSQL_YYABORT;
|
||||
if (is_native_function(thd, & $3))
|
||||
my_yyabort_error((ER_NATIVE_FCT_NAME_COLLISION, MYF(0), $3.str));
|
||||
if (is_native_function(thd, & $2))
|
||||
my_yyabort_error((ER_NATIVE_FCT_NAME_COLLISION, MYF(0), $2.str));
|
||||
lex->sql_command= SQLCOM_CREATE_FUNCTION;
|
||||
lex->udf.name= $3;
|
||||
lex->udf.returns= (Item_result) $5;
|
||||
lex->udf.dl= $7.str;
|
||||
lex->udf.name= $2;
|
||||
lex->udf.returns= (Item_result) $4;
|
||||
lex->udf.dl= $6.str;
|
||||
}
|
||||
;
|
||||
|
||||
sf_tail:
|
||||
FUNCTION_SYM /* $1 */
|
||||
opt_if_not_exists /* $2 */
|
||||
sp_name /* $3 */
|
||||
{ /* $4 */
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
|
||||
opt_if_not_exists /* $1 */
|
||||
sp_name /* $2 */
|
||||
{ /* $3 */
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
|
||||
TYPE_ENUM_FUNCTION))
|
||||
MYSQL_YYABORT;
|
||||
Lex->spname= $3;
|
||||
Lex->spname= $2;
|
||||
}
|
||||
opt_sp_parenthesized_fdparam_list /* $5 */
|
||||
RETURN_SYM /* $6 */
|
||||
{ /* $7 */
|
||||
opt_sp_parenthesized_fdparam_list /* $4 */
|
||||
RETURN_SYM /* $5 */
|
||||
{ /* $6 */
|
||||
LEX *lex= Lex;
|
||||
lex->init_last_field(&lex->sphead->m_return_field_def,
|
||||
&empty_clex_str,
|
||||
thd->variables.collation_database);
|
||||
}
|
||||
sp_param_type_with_opt_collate /* $8 */
|
||||
{ /* $9 */
|
||||
sp_param_type_with_opt_collate /* $7 */
|
||||
{ /* $8 */
|
||||
if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_c_chistics /* $10 */
|
||||
{ /* $11 */
|
||||
sp_c_chistics /* $9 */
|
||||
{ /* $10 */
|
||||
LEX *lex= thd->lex;
|
||||
Lex_input_stream *lip= YYLIP;
|
||||
|
||||
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
|
||||
}
|
||||
sp_tail_is /* $12 */
|
||||
sp_body /* $13 */
|
||||
sp_tail_is /* $11 */
|
||||
sp_body /* $12 */
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
@ -16956,12 +16929,12 @@ sf_tail:
|
||||
;
|
||||
|
||||
sp_tail:
|
||||
PROCEDURE_SYM opt_if_not_exists sp_name
|
||||
opt_if_not_exists sp_name
|
||||
{
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
|
||||
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
|
||||
TYPE_ENUM_PROCEDURE))
|
||||
MYSQL_YYABORT;
|
||||
Lex->spname= $3;
|
||||
Lex->spname= $2;
|
||||
}
|
||||
opt_sp_parenthesized_pdparam_list
|
||||
sp_c_chistics
|
||||
|
@ -1626,10 +1626,6 @@ class IS_table_read_plan;
|
||||
#define JOIN_TYPE_RIGHT 2U
|
||||
#define JOIN_TYPE_OUTER 4U /* Marker that this is an outer join */
|
||||
|
||||
#define VIEW_SUID_INVOKER 0
|
||||
#define VIEW_SUID_DEFINER 1
|
||||
#define VIEW_SUID_DEFAULT 2
|
||||
|
||||
/* view WITH CHECK OPTION parameter options */
|
||||
#define VIEW_CHECK_NONE 0
|
||||
#define VIEW_CHECK_LOCAL 1
|
||||
|
@ -1331,8 +1331,8 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
|
||||
{ C_STRING_WITH_LEN("ALTER ") },
|
||||
{ C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
|
||||
|
||||
buff.append(command[thd->lex->create_view_mode].str,
|
||||
command[thd->lex->create_view_mode].length);
|
||||
buff.append(command[thd->lex->create_view->mode].str,
|
||||
command[thd->lex->create_view->mode].length);
|
||||
|
||||
LEX_USER *definer;
|
||||
|
||||
@ -1360,9 +1360,9 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
|
||||
return 1;
|
||||
}
|
||||
|
||||
views->algorithm = lex->create_view_algorithm;
|
||||
views->view_suid = lex->create_view_suid;
|
||||
views->with_check = lex->create_view_check;
|
||||
views->algorithm = lex->create_view->algorithm;
|
||||
views->view_suid = lex->create_view->suid;
|
||||
views->with_check = lex->create_view->check;
|
||||
|
||||
view_store_options(thd, views, &buff);
|
||||
buff.append(STRING_WITH_LEN("VIEW "));
|
||||
@ -1391,8 +1391,8 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
|
||||
}
|
||||
buff.append(STRING_WITH_LEN(" AS "));
|
||||
//buff.append(views->source.str, views->source.length);
|
||||
buff.append(thd->lex->create_view_select.str,
|
||||
thd->lex->create_view_select.length);
|
||||
buff.append(thd->lex->create_view->select.str,
|
||||
thd->lex->create_view->select.length);
|
||||
//int errcode= query_error_code(thd, TRUE);
|
||||
//if (thd->binlog_query(THD::STMT_QUERY_TYPE,
|
||||
// buff.ptr(), buff.length(), FALSE, FALSE, FALSE, errcod
|
||||
|
Loading…
x
Reference in New Issue
Block a user