mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-18806 Synchronize ALTER TABLE EXCHANGE PARTITION and PURGE grammar in sql_yacc.yy and sql_yacc_ora.yy
This commit is contained in:
@ -31,8 +31,10 @@
|
|||||||
#include "sql_select.h"
|
#include "sql_select.h"
|
||||||
#include "sql_cte.h"
|
#include "sql_cte.h"
|
||||||
#include "sql_signal.h"
|
#include "sql_signal.h"
|
||||||
|
#include "sql_truncate.h" // Sql_cmd_truncate_table
|
||||||
|
#include "sql_admin.h" // Sql_cmd_analyze/Check..._table
|
||||||
#include "sql_partition.h"
|
#include "sql_partition.h"
|
||||||
|
#include "sql_partition_admin.h" // Sql_cmd_alter_table_*_part
|
||||||
|
|
||||||
void LEX::parse_error(uint err_number)
|
void LEX::parse_error(uint err_number)
|
||||||
{
|
{
|
||||||
@ -8756,7 +8758,7 @@ bool LEX::tvc_finalize()
|
|||||||
bool LEX::tvc_finalize_derived()
|
bool LEX::tvc_finalize_derived()
|
||||||
{
|
{
|
||||||
derived_tables|= DERIVED_SUBQUERY;
|
derived_tables|= DERIVED_SUBQUERY;
|
||||||
if (unlikely(!expr_allows_subselect || sql_command == (int)SQLCOM_PURGE))
|
if (unlikely(!expr_allows_subselect))
|
||||||
{
|
{
|
||||||
thd->parse_error();
|
thd->parse_error();
|
||||||
return true;
|
return true;
|
||||||
@ -9004,7 +9006,7 @@ Item *LEX::create_item_query_expression(THD *thd,
|
|||||||
const char *tok_start,
|
const char *tok_start,
|
||||||
st_select_lex_unit *unit)
|
st_select_lex_unit *unit)
|
||||||
{
|
{
|
||||||
if (!expr_allows_subselect || sql_command == SQLCOM_PURGE)
|
if (!expr_allows_subselect)
|
||||||
{
|
{
|
||||||
thd->parse_error(ER_SYNTAX_ERROR, tok_start);
|
thd->parse_error(ER_SYNTAX_ERROR, tok_start);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -9247,8 +9249,7 @@ SELECT_LEX_UNIT *LEX::parsed_body_unit_tail(SELECT_LEX_UNIT *unit,
|
|||||||
|
|
||||||
SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit, char *place)
|
SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit, char *place)
|
||||||
{
|
{
|
||||||
if (!expr_allows_subselect ||
|
if (!expr_allows_subselect)
|
||||||
sql_command == (int)SQLCOM_PURGE)
|
|
||||||
{
|
{
|
||||||
thd->parse_error(ER_SYNTAX_ERROR, place);
|
thd->parse_error(ER_SYNTAX_ERROR, place);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -10263,3 +10264,41 @@ void LEX::stmt_deallocate_prepare(const Lex_ident_sys_st &ident)
|
|||||||
sql_command= SQLCOM_DEALLOCATE_PREPARE;
|
sql_command= SQLCOM_DEALLOCATE_PREPARE;
|
||||||
prepared_stmt.set(ident, NULL, NULL);
|
prepared_stmt.set(ident, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::stmt_alter_table_exchange_partition(Table_ident *table)
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(sql_command == SQLCOM_ALTER_TABLE);
|
||||||
|
first_select_lex()->db= table->db;
|
||||||
|
if (first_select_lex()->db.str == NULL &&
|
||||||
|
copy_db_to(&first_select_lex()->db))
|
||||||
|
return true;
|
||||||
|
name= table->table;
|
||||||
|
alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE;
|
||||||
|
if (!first_select_lex()->add_table_to_list(thd, table, NULL,
|
||||||
|
TL_OPTION_UPDATING,
|
||||||
|
TL_READ_NO_INSERT,
|
||||||
|
MDL_SHARED_NO_WRITE))
|
||||||
|
return true;
|
||||||
|
DBUG_ASSERT(!m_sql_cmd);
|
||||||
|
m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_exchange_partition();
|
||||||
|
return m_sql_cmd == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LEX::stmt_purge_to(const LEX_CSTRING &to)
|
||||||
|
{
|
||||||
|
type= 0;
|
||||||
|
sql_command= SQLCOM_PURGE;
|
||||||
|
to_log= to.str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::stmt_purge_before(Item *item)
|
||||||
|
{
|
||||||
|
type= 0;
|
||||||
|
sql_command= SQLCOM_PURGE_BEFORE;
|
||||||
|
value_list.empty();
|
||||||
|
value_list.push_front(item, thd->mem_root);
|
||||||
|
return check_main_unit_semantics();
|
||||||
|
}
|
||||||
|
@ -4451,6 +4451,11 @@ public:
|
|||||||
bool stmt_execute(const Lex_ident_sys_st &ident, List<Item> *params);
|
bool stmt_execute(const Lex_ident_sys_st &ident, List<Item> *params);
|
||||||
bool stmt_execute_immediate(Item *code, List<Item> *params);
|
bool stmt_execute_immediate(Item *code, List<Item> *params);
|
||||||
void stmt_deallocate_prepare(const Lex_ident_sys_st &ident);
|
void stmt_deallocate_prepare(const Lex_ident_sys_st &ident);
|
||||||
|
|
||||||
|
bool stmt_alter_table_exchange_partition(Table_ident *table);
|
||||||
|
|
||||||
|
void stmt_purge_to(const LEX_CSTRING &to);
|
||||||
|
bool stmt_purge_before(Item *item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1856,7 +1856,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
|
|
||||||
%type <item>
|
%type <item>
|
||||||
literal insert_ident order_ident temporal_literal
|
literal insert_ident order_ident temporal_literal
|
||||||
simple_ident expr prepare_src sum_expr in_sum_expr
|
simple_ident expr expr_no_subselect sum_expr in_sum_expr
|
||||||
variable variable_aux bool_pri
|
variable variable_aux bool_pri
|
||||||
predicate bit_expr parenthesized_expr
|
predicate bit_expr parenthesized_expr
|
||||||
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
|
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
|
||||||
@ -2318,14 +2318,14 @@ deallocate_or_drop:
|
|||||||
;
|
;
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
PREPARE_SYM ident FROM prepare_src
|
PREPARE_SYM ident FROM expr_no_subselect
|
||||||
{
|
{
|
||||||
if (Lex->stmt_prepare($2, $4))
|
if (Lex->stmt_prepare($2, $4))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
prepare_src:
|
expr_no_subselect:
|
||||||
{ Lex->expr_allows_subselect= false; }
|
{ Lex->expr_allows_subselect= false; }
|
||||||
expr
|
expr
|
||||||
{
|
{
|
||||||
@ -2340,7 +2340,7 @@ execute:
|
|||||||
if (Lex->stmt_execute($2, $3))
|
if (Lex->stmt_execute($2, $3))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| EXECUTE_SYM IMMEDIATE_SYM prepare_src execute_using
|
| EXECUTE_SYM IMMEDIATE_SYM expr_no_subselect execute_using
|
||||||
{
|
{
|
||||||
if (Lex->stmt_execute_immediate($3, $4))
|
if (Lex->stmt_execute_immediate($3, $4))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
@ -8182,23 +8182,7 @@ alter_commands:
|
|||||||
| EXCHANGE_SYM PARTITION_SYM alt_part_name_item
|
| EXCHANGE_SYM PARTITION_SYM alt_part_name_item
|
||||||
WITH TABLE_SYM table_ident have_partitioning
|
WITH TABLE_SYM table_ident have_partitioning
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_alter_table_exchange_partition($6))
|
||||||
lex->first_select_lex()->db=$6->db;
|
|
||||||
if (lex->first_select_lex()->db.str == NULL &&
|
|
||||||
lex->copy_db_to(&lex->first_select_lex()->db))
|
|
||||||
{
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
lex->name= $6->table;
|
|
||||||
lex->alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE;
|
|
||||||
if (!lex->first_select_lex()->
|
|
||||||
add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING,
|
|
||||||
TL_READ_NO_INSERT, MDL_SHARED_NO_WRITE))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
DBUG_ASSERT(!lex->m_sql_cmd);
|
|
||||||
lex->m_sql_cmd= new (thd->mem_root)
|
|
||||||
Sql_cmd_alter_table_exchange_partition();
|
|
||||||
if (unlikely(lex->m_sql_cmd == NULL))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -14715,36 +14699,18 @@ master_reset_options:
|
|||||||
;
|
;
|
||||||
|
|
||||||
purge:
|
purge:
|
||||||
PURGE
|
PURGE master_or_binary LOGS_SYM TO_SYM TEXT_STRING_sys
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
Lex->stmt_purge_to($5);
|
||||||
lex->type=0;
|
|
||||||
lex->sql_command = SQLCOM_PURGE;
|
|
||||||
}
|
}
|
||||||
purge_options
|
| PURGE master_or_binary LOGS_SYM BEFORE_SYM expr_no_subselect
|
||||||
{}
|
|
||||||
;
|
|
||||||
|
|
||||||
purge_options:
|
|
||||||
master_or_binary LOGS_SYM purge_option
|
|
||||||
;
|
|
||||||
|
|
||||||
purge_option:
|
|
||||||
TO_SYM TEXT_STRING_sys
|
|
||||||
{
|
{
|
||||||
Lex->to_log = $2.str;
|
if (Lex->stmt_purge_before($5))
|
||||||
}
|
|
||||||
| BEFORE_SYM expr
|
|
||||||
{
|
|
||||||
LEX *lex= Lex;
|
|
||||||
lex->value_list.empty();
|
|
||||||
lex->value_list.push_front($2, thd->mem_root);
|
|
||||||
lex->sql_command= SQLCOM_PURGE_BEFORE;
|
|
||||||
if (Lex->check_main_unit_semantics())
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/* kill threads */
|
/* kill threads */
|
||||||
|
|
||||||
kill:
|
kill:
|
||||||
|
@ -1357,7 +1357,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
|
|
||||||
%type <item>
|
%type <item>
|
||||||
literal insert_ident order_ident temporal_literal
|
literal insert_ident order_ident temporal_literal
|
||||||
simple_ident expr prepare_src sum_expr in_sum_expr
|
simple_ident expr expr_no_subselect sum_expr in_sum_expr
|
||||||
variable variable_aux bool_pri
|
variable variable_aux bool_pri
|
||||||
predicate bit_expr parenthesized_expr
|
predicate bit_expr parenthesized_expr
|
||||||
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
|
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
|
||||||
@ -1839,14 +1839,14 @@ deallocate_or_drop:
|
|||||||
;
|
;
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
PREPARE_SYM ident FROM prepare_src
|
PREPARE_SYM ident FROM expr_no_subselect
|
||||||
{
|
{
|
||||||
if (Lex->stmt_prepare($2, $4))
|
if (Lex->stmt_prepare($2, $4))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
prepare_src:
|
expr_no_subselect:
|
||||||
{ Lex->expr_allows_subselect= false; }
|
{ Lex->expr_allows_subselect= false; }
|
||||||
expr
|
expr
|
||||||
{
|
{
|
||||||
@ -1861,7 +1861,7 @@ execute:
|
|||||||
if (Lex->stmt_execute($2, $3))
|
if (Lex->stmt_execute($2, $3))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| EXECUTE_SYM IMMEDIATE_SYM prepare_src execute_using
|
| EXECUTE_SYM IMMEDIATE_SYM expr_no_subselect execute_using
|
||||||
{
|
{
|
||||||
if (Lex->stmt_execute_immediate($3, $4))
|
if (Lex->stmt_execute_immediate($3, $4))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
@ -8274,20 +8274,7 @@ alter_commands:
|
|||||||
| EXCHANGE_SYM PARTITION_SYM alt_part_name_item
|
| EXCHANGE_SYM PARTITION_SYM alt_part_name_item
|
||||||
WITH TABLE_SYM table_ident have_partitioning
|
WITH TABLE_SYM table_ident have_partitioning
|
||||||
{
|
{
|
||||||
LEX *lex= thd->lex;
|
if (Lex->stmt_alter_table_exchange_partition($6))
|
||||||
if (lex->first_select_lex()->db.str == NULL &&
|
|
||||||
lex->copy_db_to(&lex->first_select_lex()->db))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
lex->name= $6->table;
|
|
||||||
lex->alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE;
|
|
||||||
if (!lex->first_select_lex()->
|
|
||||||
add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING,
|
|
||||||
TL_READ_NO_INSERT, MDL_SHARED_NO_WRITE))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
DBUG_ASSERT(!lex->m_sql_cmd);
|
|
||||||
lex->m_sql_cmd= new (thd->mem_root)
|
|
||||||
Sql_cmd_alter_table_exchange_partition();
|
|
||||||
if (unlikely(lex->m_sql_cmd == NULL))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -14832,33 +14819,17 @@ master_reset_options:
|
|||||||
;
|
;
|
||||||
|
|
||||||
purge:
|
purge:
|
||||||
PURGE
|
PURGE master_or_binary LOGS_SYM TO_SYM TEXT_STRING_sys
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
Lex->stmt_purge_to($5);
|
||||||
lex->type=0;
|
}
|
||||||
lex->sql_command = SQLCOM_PURGE;
|
| PURGE master_or_binary LOGS_SYM BEFORE_SYM expr_no_subselect
|
||||||
|
{
|
||||||
|
if (Lex->stmt_purge_before($5))
|
||||||
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
purge_options
|
|
||||||
{}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
purge_options:
|
|
||||||
master_or_binary LOGS_SYM purge_option
|
|
||||||
;
|
|
||||||
|
|
||||||
purge_option:
|
|
||||||
TO_SYM TEXT_STRING_sys
|
|
||||||
{
|
|
||||||
Lex->to_log = $2.str;
|
|
||||||
}
|
|
||||||
| BEFORE_SYM expr
|
|
||||||
{
|
|
||||||
LEX *lex= Lex;
|
|
||||||
lex->value_list.empty();
|
|
||||||
lex->value_list.push_front($2, thd->mem_root);
|
|
||||||
lex->sql_command= SQLCOM_PURGE_BEFORE;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
/* kill threads */
|
/* kill threads */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user