mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-15975 PL/SQL parser does not understand historical queries
Merging the following features from sql_yacc.yy to sql_yacc_ora.yy: - system versioning - column compression - table value constructor - spatial predicate WITHIN - DELETE_DOMAIN_ID
This commit is contained in:
@ -0,0 +1,9 @@
|
|||||||
|
SET sql_mode=ORACLE;
|
||||||
|
SET column_compression_zlib_wrap=true;
|
||||||
|
CREATE TABLE t1 (a BLOB COMPRESSED);
|
||||||
|
INSERT INTO t1 VALUES (REPEAT('a',10000));
|
||||||
|
SELECT DATA_LENGTH<100 AS c FROM INFORMATION_SCHEMA.TABLES
|
||||||
|
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
|
||||||
|
c
|
||||||
|
1
|
||||||
|
DROP TABLE t1;
|
6
mysql-test/suite/compat/oracle/r/gis.result
Normal file
6
mysql-test/suite/compat/oracle/r/gis.result
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
SELECT WITHIN(POINT(1,1), POINT(1,1));
|
||||||
|
WITHIN(POINT(1,1), POINT(1,1))
|
||||||
|
1
|
||||||
|
SELECT WITHIN(POINT(1,1), POINT(0,0));
|
||||||
|
WITHIN(POINT(1,1), POINT(0,0))
|
||||||
|
0
|
2101
mysql-test/suite/compat/oracle/r/table_value_constr.result
Normal file
2101
mysql-test/suite/compat/oracle/r/table_value_constr.result
Normal file
File diff suppressed because it is too large
Load Diff
16
mysql-test/suite/compat/oracle/r/versioning.result
Normal file
16
mysql-test/suite/compat/oracle/r/versioning.result
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
SET sql_mode=ORACLE;
|
||||||
|
#
|
||||||
|
# MDEV-15975 PL/SQL parser does not understand historical queries
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
|
||||||
|
INSERT INTO t1 VALUES (10);
|
||||||
|
DELETE FROM t1;
|
||||||
|
INSERT INTO t1 VALUES (20);
|
||||||
|
SELECT * FROM t1 FOR SYSTEM_TIME ALL;
|
||||||
|
a
|
||||||
|
10
|
||||||
|
20
|
||||||
|
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (NOW()+INTERVAL 10 YEAR);
|
||||||
|
a
|
||||||
|
20
|
||||||
|
DROP TABLE t1;
|
11
mysql-test/suite/compat/oracle/t/column_compression.test
Normal file
11
mysql-test/suite/compat/oracle/t/column_compression.test
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
--source include/have_csv.inc
|
||||||
|
|
||||||
|
SET sql_mode=ORACLE;
|
||||||
|
|
||||||
|
SET column_compression_zlib_wrap=true;
|
||||||
|
CREATE TABLE t1 (a BLOB COMPRESSED);
|
||||||
|
INSERT INTO t1 VALUES (REPEAT('a',10000));
|
||||||
|
SELECT DATA_LENGTH<100 AS c FROM INFORMATION_SCHEMA.TABLES
|
||||||
|
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
|
||||||
|
DROP TABLE t1;
|
4
mysql-test/suite/compat/oracle/t/gis.test
Normal file
4
mysql-test/suite/compat/oracle/t/gis.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- source include/have_geometry.inc
|
||||||
|
|
||||||
|
SELECT WITHIN(POINT(1,1), POINT(1,1));
|
||||||
|
SELECT WITHIN(POINT(1,1), POINT(0,0));
|
1083
mysql-test/suite/compat/oracle/t/table_value_constr.test
Normal file
1083
mysql-test/suite/compat/oracle/t/table_value_constr.test
Normal file
File diff suppressed because it is too large
Load Diff
13
mysql-test/suite/compat/oracle/t/versioning.test
Normal file
13
mysql-test/suite/compat/oracle/t/versioning.test
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
SET sql_mode=ORACLE;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-15975 PL/SQL parser does not understand historical queries
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
|
||||||
|
INSERT INTO t1 VALUES (10);
|
||||||
|
DELETE FROM t1;
|
||||||
|
INSERT INTO t1 VALUES (20);
|
||||||
|
SELECT * FROM t1 FOR SYSTEM_TIME ALL;
|
||||||
|
SELECT * FROM t1 FOR SYSTEM_TIME AS OF (NOW()+INTERVAL 10 YEAR);
|
||||||
|
DROP TABLE t1;
|
169
sql/sql_lex.cc
169
sql/sql_lex.cc
@ -31,6 +31,7 @@
|
|||||||
#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_partition.h"
|
||||||
|
|
||||||
|
|
||||||
void LEX::parse_error(uint err_number)
|
void LEX::parse_error(uint err_number)
|
||||||
@ -7977,3 +7978,171 @@ bool Lex_ident_sys_st::convert(THD *thd,
|
|||||||
length= tmp.length;
|
length= tmp.length;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Lex_ident_sys_st::to_size_number(THD *thd, ulonglong *to) const
|
||||||
|
{
|
||||||
|
ulonglong number;
|
||||||
|
uint text_shift_number= 0;
|
||||||
|
longlong prefix_number;
|
||||||
|
const char *start_ptr= str;
|
||||||
|
size_t str_len= length;
|
||||||
|
const char *end_ptr= start_ptr + str_len;
|
||||||
|
int error;
|
||||||
|
prefix_number= my_strtoll10(start_ptr, (char**) &end_ptr, &error);
|
||||||
|
if (likely((start_ptr + str_len - 1) == end_ptr))
|
||||||
|
{
|
||||||
|
switch (end_ptr[0])
|
||||||
|
{
|
||||||
|
case 'g':
|
||||||
|
case 'G': text_shift_number+=30; break;
|
||||||
|
case 'm':
|
||||||
|
case 'M': text_shift_number+=20; break;
|
||||||
|
case 'k':
|
||||||
|
case 'K': text_shift_number+=10; break;
|
||||||
|
default:
|
||||||
|
my_error(ER_WRONG_SIZE_NUMBER, MYF(0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (unlikely(prefix_number >> 31))
|
||||||
|
{
|
||||||
|
my_error(ER_SIZE_OVERFLOW_ERROR, MYF(0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
number= prefix_number << text_shift_number;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my_error(ER_WRONG_SIZE_NUMBER, MYF(0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*to= number;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::part_values_current(THD *thd)
|
||||||
|
{
|
||||||
|
partition_element *elem= part_info->curr_part_elem;
|
||||||
|
if (!is_partition_management())
|
||||||
|
{
|
||||||
|
if (unlikely(part_info->part_type != VERSIONING_PARTITION))
|
||||||
|
{
|
||||||
|
my_error(ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(create_last_non_select_table);
|
||||||
|
DBUG_ASSERT(create_last_non_select_table->table_name.str);
|
||||||
|
// FIXME: other ALTER commands?
|
||||||
|
my_error(ER_VERS_WRONG_PARTS, MYF(0),
|
||||||
|
create_last_non_select_table->table_name.str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
elem->type(partition_element::CURRENT);
|
||||||
|
DBUG_ASSERT(part_info->vers_info);
|
||||||
|
part_info->vers_info->now_part= elem;
|
||||||
|
if (unlikely(part_info->init_column_part(thd)))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::part_values_history(THD *thd)
|
||||||
|
{
|
||||||
|
partition_element *elem= part_info->curr_part_elem;
|
||||||
|
if (!is_partition_management())
|
||||||
|
{
|
||||||
|
if (unlikely(part_info->part_type != VERSIONING_PARTITION))
|
||||||
|
{
|
||||||
|
my_error(ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
part_info->vers_init_info(thd);
|
||||||
|
elem->id= UINT_MAX32;
|
||||||
|
}
|
||||||
|
DBUG_ASSERT(part_info->vers_info);
|
||||||
|
if (unlikely(part_info->vers_info->now_part))
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(create_last_non_select_table);
|
||||||
|
DBUG_ASSERT(create_last_non_select_table->table_name.str);
|
||||||
|
my_error(ER_VERS_WRONG_PARTS, MYF(0),
|
||||||
|
create_last_non_select_table->table_name.str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
elem->type(partition_element::HISTORY);
|
||||||
|
if (unlikely(part_info->init_column_part(thd)))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::last_field_generated_always_as_row_start_or_end(Lex_ident *p,
|
||||||
|
const char *type,
|
||||||
|
uint flag)
|
||||||
|
{
|
||||||
|
if (unlikely(p->str))
|
||||||
|
{
|
||||||
|
my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0), type,
|
||||||
|
last_field->field_name.str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
last_field->flags|= (flag | NOT_NULL_FLAG);
|
||||||
|
DBUG_ASSERT(p);
|
||||||
|
*p= last_field->field_name;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::last_field_generated_always_as_row_start()
|
||||||
|
{
|
||||||
|
Vers_parse_info &info= vers_get_info();
|
||||||
|
Lex_ident *p= &info.as_row.start;
|
||||||
|
return last_field_generated_always_as_row_start_or_end(p, "START",
|
||||||
|
VERS_SYS_START_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::last_field_generated_always_as_row_end()
|
||||||
|
{
|
||||||
|
Vers_parse_info &info= vers_get_info();
|
||||||
|
Lex_ident *p= &info.as_row.end;
|
||||||
|
return last_field_generated_always_as_row_start_or_end(p, "END",
|
||||||
|
VERS_SYS_END_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::tvc_finalize()
|
||||||
|
{
|
||||||
|
mysql_init_select(this);
|
||||||
|
if (unlikely(!(current_select->tvc=
|
||||||
|
new (thd->mem_root)
|
||||||
|
table_value_constr(many_values,
|
||||||
|
current_select,
|
||||||
|
current_select->options))))
|
||||||
|
return true;
|
||||||
|
many_values.empty();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LEX::tvc_finalize_derived()
|
||||||
|
{
|
||||||
|
derived_tables|= DERIVED_SUBQUERY;
|
||||||
|
if (unlikely(!expr_allows_subselect || sql_command == (int)SQLCOM_PURGE))
|
||||||
|
{
|
||||||
|
thd->parse_error();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (current_select->linkage == GLOBAL_OPTIONS_TYPE ||
|
||||||
|
unlikely(mysql_new_select(this, 1, NULL)))
|
||||||
|
return true;
|
||||||
|
current_select->linkage= DERIVED_TABLE_TYPE;
|
||||||
|
return tvc_finalize();
|
||||||
|
}
|
||||||
|
@ -143,6 +143,7 @@ public:
|
|||||||
bool convert(THD *thd, const LEX_CSTRING *str, CHARSET_INFO *cs);
|
bool convert(THD *thd, const LEX_CSTRING *str, CHARSET_INFO *cs);
|
||||||
bool copy_or_convert(THD *thd, const Lex_ident_cli_st *str, CHARSET_INFO *cs);
|
bool copy_or_convert(THD *thd, const Lex_ident_cli_st *str, CHARSET_INFO *cs);
|
||||||
bool is_null() const { return str == NULL; }
|
bool is_null() const { return str == NULL; }
|
||||||
|
bool to_size_number(THD *thd, ulonglong *to) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -3262,7 +3263,10 @@ public:
|
|||||||
void restore_backup_query_tables_list(Query_tables_list *backup);
|
void restore_backup_query_tables_list(Query_tables_list *backup);
|
||||||
|
|
||||||
bool table_or_sp_used();
|
bool table_or_sp_used();
|
||||||
|
|
||||||
bool is_partition_management() const;
|
bool is_partition_management() const;
|
||||||
|
bool part_values_current(THD *thd);
|
||||||
|
bool part_values_history(THD *thd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief check if the statement is a single-level join
|
@brief check if the statement is a single-level join
|
||||||
@ -3294,6 +3298,11 @@ public:
|
|||||||
|
|
||||||
void init_last_field(Column_definition *field, const LEX_CSTRING *name,
|
void init_last_field(Column_definition *field, const LEX_CSTRING *name,
|
||||||
const CHARSET_INFO *cs);
|
const CHARSET_INFO *cs);
|
||||||
|
bool last_field_generated_always_as_row_start_or_end(Lex_ident *p,
|
||||||
|
const char *type,
|
||||||
|
uint flags);
|
||||||
|
bool last_field_generated_always_as_row_start();
|
||||||
|
bool last_field_generated_always_as_row_end();
|
||||||
bool set_bincmp(CHARSET_INFO *cs, bool bin);
|
bool set_bincmp(CHARSET_INFO *cs, bool bin);
|
||||||
|
|
||||||
bool get_dynamic_sql_string(LEX_CSTRING *dst, String *buffer);
|
bool get_dynamic_sql_string(LEX_CSTRING *dst, String *buffer);
|
||||||
@ -3919,6 +3928,15 @@ public:
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tvc_start()
|
||||||
|
{
|
||||||
|
field_list.empty();
|
||||||
|
many_values.empty();
|
||||||
|
insert_list= 0;
|
||||||
|
}
|
||||||
|
bool tvc_finalize();
|
||||||
|
bool tvc_finalize_derived();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
246
sql/sql_yacc.yy
246
sql/sql_yacc.yy
@ -1848,7 +1848,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
opt_default_time_precision
|
opt_default_time_precision
|
||||||
case_stmt_body opt_bin_mod opt_for_system_time_clause
|
case_stmt_body opt_bin_mod opt_for_system_time_clause
|
||||||
opt_if_exists_table_element opt_if_not_exists_table_element
|
opt_if_exists_table_element opt_if_not_exists_table_element
|
||||||
opt_recursive opt_format_xid
|
opt_recursive opt_format_xid
|
||||||
|
|
||||||
%type <object_ddl_options>
|
%type <object_ddl_options>
|
||||||
create_or_replace
|
create_or_replace
|
||||||
@ -2082,9 +2082,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
|
|||||||
vcol_opt_attribute_list vcol_attribute
|
vcol_opt_attribute_list vcol_attribute
|
||||||
opt_serial_attribute opt_serial_attribute_list serial_attribute
|
opt_serial_attribute opt_serial_attribute_list serial_attribute
|
||||||
explainable_command
|
explainable_command
|
||||||
opt_lock_wait_timeout
|
opt_lock_wait_timeout
|
||||||
opt_delete_gtid_domain
|
opt_delete_gtid_domain
|
||||||
asrow_attribute
|
asrow_attribute
|
||||||
END_OF_INPUT
|
END_OF_INPUT
|
||||||
|
|
||||||
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
|
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
|
||||||
@ -2105,7 +2105,6 @@ END_OF_INPUT
|
|||||||
|
|
||||||
%type <num> sp_decl_idents sp_decl_idents_init_vars
|
%type <num> sp_decl_idents sp_decl_idents_init_vars
|
||||||
%type <num> sp_handler_type sp_hcond_list
|
%type <num> sp_handler_type sp_hcond_list
|
||||||
%type <num> start_or_end
|
|
||||||
%type <spcondvalue> sp_cond sp_hcond sqlstate signal_value opt_signal_value
|
%type <spcondvalue> sp_cond sp_hcond sqlstate signal_value opt_signal_value
|
||||||
%type <spblock> sp_decls sp_decl sp_decl_body sp_decl_variable_list
|
%type <spblock> sp_decls sp_decl sp_decl_body sp_decl_variable_list
|
||||||
%type <spname> sp_name
|
%type <spname> sp_name
|
||||||
@ -2136,6 +2135,7 @@ END_OF_INPUT
|
|||||||
|
|
||||||
%type <spvar_definition> row_field_name row_field_definition
|
%type <spvar_definition> row_field_name row_field_definition
|
||||||
%type <spvar_definition_list> row_field_definition_list row_type_body
|
%type <spvar_definition_list> row_field_definition_list row_type_body
|
||||||
|
|
||||||
%type <NONE> opt_window_clause window_def_list window_def window_spec
|
%type <NONE> opt_window_clause window_def_list window_def window_spec
|
||||||
%type <lex_str_ptr> window_name
|
%type <lex_str_ptr> window_name
|
||||||
%type <NONE> opt_window_ref opt_window_frame_clause
|
%type <NONE> opt_window_ref opt_window_frame_clause
|
||||||
@ -3613,7 +3613,8 @@ opt_parenthesized_cursor_formal_parameters:
|
|||||||
sp_cursor_stmt_lex:
|
sp_cursor_stmt_lex:
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(thd->lex->sphead);
|
DBUG_ASSERT(thd->lex->sphead);
|
||||||
if (unlikely(!($$= new (thd->mem_root) sp_lex_cursor(thd, thd->lex))))
|
if (unlikely(!($$= new (thd->mem_root)
|
||||||
|
sp_lex_cursor(thd, thd->lex))))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -5138,34 +5139,8 @@ size_number:
|
|||||||
real_ulonglong_num { $$= $1;}
|
real_ulonglong_num { $$= $1;}
|
||||||
| IDENT_sys
|
| IDENT_sys
|
||||||
{
|
{
|
||||||
ulonglong number;
|
if ($1.to_size_number(thd, &$$))
|
||||||
uint text_shift_number= 0;
|
MYSQL_YYABORT;
|
||||||
longlong prefix_number;
|
|
||||||
const char *start_ptr= $1.str;
|
|
||||||
size_t str_len= $1.length;
|
|
||||||
const char *end_ptr= start_ptr + str_len;
|
|
||||||
int error;
|
|
||||||
prefix_number= my_strtoll10(start_ptr, (char**) &end_ptr, &error);
|
|
||||||
if (likely((start_ptr + str_len - 1) == end_ptr))
|
|
||||||
{
|
|
||||||
switch (end_ptr[0])
|
|
||||||
{
|
|
||||||
case 'g':
|
|
||||||
case 'G': text_shift_number+=30; break;
|
|
||||||
case 'm':
|
|
||||||
case 'M': text_shift_number+=20; break;
|
|
||||||
case 'k':
|
|
||||||
case 'K': text_shift_number+=10; break;
|
|
||||||
default:
|
|
||||||
my_yyabort_error((ER_WRONG_SIZE_NUMBER, MYF(0)));
|
|
||||||
}
|
|
||||||
if (unlikely(prefix_number >> 31))
|
|
||||||
my_yyabort_error((ER_SIZE_OVERFLOW_ERROR, MYF(0)));
|
|
||||||
number= prefix_number << text_shift_number;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
my_yyabort_error((ER_WRONG_SIZE_NUMBER, MYF(0)));
|
|
||||||
$$= number;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -5631,55 +5606,12 @@ opt_part_values:
|
|||||||
part_values_in {}
|
part_values_in {}
|
||||||
| CURRENT_SYM
|
| CURRENT_SYM
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->part_values_current(thd))
|
||||||
partition_info *part_info= lex->part_info;
|
|
||||||
partition_element *elem= part_info->curr_part_elem;
|
|
||||||
if (! lex->is_partition_management())
|
|
||||||
{
|
|
||||||
if (unlikely(part_info->part_type != VERSIONING_PARTITION))
|
|
||||||
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(Lex->create_last_non_select_table);
|
|
||||||
DBUG_ASSERT(Lex->create_last_non_select_table->table_name.str);
|
|
||||||
// FIXME: other ALTER commands?
|
|
||||||
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
|
|
||||||
Lex->create_last_non_select_table->
|
|
||||||
table_name.str));
|
|
||||||
}
|
|
||||||
elem->type(partition_element::CURRENT);
|
|
||||||
DBUG_ASSERT(part_info->vers_info);
|
|
||||||
part_info->vers_info->now_part= elem;
|
|
||||||
if (unlikely(part_info->init_column_part(thd)))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| HISTORY_SYM
|
| HISTORY_SYM
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->part_values_history(thd))
|
||||||
partition_info *part_info= lex->part_info;
|
|
||||||
partition_element *elem= part_info->curr_part_elem;
|
|
||||||
if (! lex->is_partition_management())
|
|
||||||
{
|
|
||||||
if (unlikely(part_info->part_type != VERSIONING_PARTITION))
|
|
||||||
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
part_info->vers_init_info(thd);
|
|
||||||
elem->id= UINT_MAX32;
|
|
||||||
}
|
|
||||||
DBUG_ASSERT(part_info->vers_info);
|
|
||||||
if (unlikely(part_info->vers_info->now_part))
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(Lex->create_last_non_select_table);
|
|
||||||
DBUG_ASSERT(Lex->create_last_non_select_table->table_name.str);
|
|
||||||
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
|
|
||||||
Lex->create_last_non_select_table->
|
|
||||||
table_name.str));
|
|
||||||
}
|
|
||||||
elem->type(partition_element::HISTORY);
|
|
||||||
if (unlikely(part_info->init_column_part(thd)))
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| DEFAULT
|
| DEFAULT
|
||||||
@ -5992,7 +5924,6 @@ opt_versioning_rotation:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
opt_versioning_interval_start:
|
opt_versioning_interval_start:
|
||||||
/* empty */
|
/* empty */
|
||||||
@ -6712,46 +6643,16 @@ field_def:
|
|||||||
Lex->last_field->flags&= ~NOT_NULL_FLAG; // undo automatic NOT NULL for timestamps
|
Lex->last_field->flags&= ~NOT_NULL_FLAG; // undo automatic NOT NULL for timestamps
|
||||||
}
|
}
|
||||||
vcol_opt_specifier vcol_opt_attribute
|
vcol_opt_specifier vcol_opt_attribute
|
||||||
| opt_generated_always AS ROW_SYM start_or_end opt_asrow_attribute
|
| opt_generated_always AS ROW_SYM START_SYM opt_asrow_attribute
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->last_field_generated_always_as_row_start())
|
||||||
Vers_parse_info &info= lex->vers_get_info();
|
MYSQL_YYABORT;
|
||||||
const LEX_CSTRING &field_name= lex->last_field->field_name;
|
}
|
||||||
|
| opt_generated_always AS ROW_SYM END opt_asrow_attribute
|
||||||
Lex_ident *p;
|
{
|
||||||
switch ($4)
|
if (Lex->last_field_generated_always_as_row_end())
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
p= &info.as_row.start;
|
|
||||||
if (unlikely(p->str))
|
|
||||||
{
|
|
||||||
my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
|
|
||||||
"START", field_name.str));
|
|
||||||
}
|
|
||||||
lex->last_field->flags|= VERS_SYS_START_FLAG | NOT_NULL_FLAG;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
p= &info.as_row.end;
|
|
||||||
if (unlikely(p->str))
|
|
||||||
{
|
|
||||||
my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
|
|
||||||
"END", field_name.str));
|
|
||||||
}
|
|
||||||
lex->last_field->flags|= VERS_SYS_END_FLAG | NOT_NULL_FLAG;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Not Reachable */
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
break;
|
|
||||||
}
|
|
||||||
DBUG_ASSERT(p);
|
|
||||||
*p= field_name;
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
start_or_end:
|
|
||||||
START_SYM { $$ = 1; }
|
|
||||||
| END { $$ = 0; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_generated_always:
|
opt_generated_always:
|
||||||
@ -6804,7 +6705,7 @@ vcol_attribute:
|
|||||||
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
|
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
|
||||||
| INVISIBLE_SYM
|
| INVISIBLE_SYM
|
||||||
{
|
{
|
||||||
Lex->last_field->invisible= INVISIBLE_USER;
|
Lex->last_field->invisible= INVISIBLE_USER;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -8348,9 +8249,7 @@ alter_list_item:
|
|||||||
lex->select_lex.db= $3->db;
|
lex->select_lex.db= $3->db;
|
||||||
if (lex->select_lex.db.str == NULL &&
|
if (lex->select_lex.db.str == NULL &&
|
||||||
unlikely(lex->copy_db_to(&lex->select_lex.db)))
|
unlikely(lex->copy_db_to(&lex->select_lex.db)))
|
||||||
{
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
if (unlikely(check_table_name($3->table.str,$3->table.length,
|
if (unlikely(check_table_name($3->table.str,$3->table.length,
|
||||||
FALSE)) ||
|
FALSE)) ||
|
||||||
($3->db.str && unlikely(check_db_name((LEX_STRING*) &$3->db))))
|
($3->db.str && unlikely(check_db_name((LEX_STRING*) &$3->db))))
|
||||||
@ -11214,17 +11113,17 @@ window_func_expr:
|
|||||||
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, $3);
|
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, $3);
|
||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
if (Select->add_window_func((Item_window_func *) $$))
|
if (unlikely(Select->add_window_func((Item_window_func *) $$)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
window_func OVER_SYM window_spec
|
window_func OVER_SYM window_spec
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
if (Select->add_window_spec(thd, lex->win_ref,
|
if (unlikely(Select->add_window_spec(thd, lex->win_ref,
|
||||||
Select->group_list,
|
Select->group_list,
|
||||||
Select->order_list,
|
Select->order_list,
|
||||||
lex->win_frame))
|
lex->win_frame)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1,
|
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1,
|
||||||
thd->lex->win_spec);
|
thd->lex->win_spec);
|
||||||
@ -11352,10 +11251,10 @@ inverse_distribution_function:
|
|||||||
'(' opt_window_partition_clause ')'
|
'(' opt_window_partition_clause ')'
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
if (Select->add_window_spec(thd, lex->win_ref,
|
if (unlikely(Select->add_window_spec(thd, lex->win_ref,
|
||||||
Select->group_list,
|
Select->group_list,
|
||||||
Select->order_list,
|
Select->order_list,
|
||||||
NULL))
|
NULL)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1,
|
$$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1,
|
||||||
thd->lex->win_spec);
|
thd->lex->win_spec);
|
||||||
@ -11378,9 +11277,7 @@ percentile_function:
|
|||||||
Item *args= new (thd->mem_root) Item_decimal(thd, "0.5", 3,
|
Item *args= new (thd->mem_root) Item_decimal(thd, "0.5", 3,
|
||||||
thd->charset());
|
thd->charset());
|
||||||
if (unlikely(args == NULL) || unlikely(thd->is_error()))
|
if (unlikely(args == NULL) || unlikely(thd->is_error()))
|
||||||
{
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
Select->prepare_add_window_spec(thd);
|
Select->prepare_add_window_spec(thd);
|
||||||
if (unlikely(add_order_to_list(thd, $3,FALSE)))
|
if (unlikely(add_order_to_list(thd, $3,FALSE)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
@ -11411,7 +11308,7 @@ order_by_single_element_list:
|
|||||||
{
|
{
|
||||||
if (unlikely(add_order_to_list(thd, $3,(bool) $4)))
|
if (unlikely(add_order_to_list(thd, $3,(bool) $4)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -11640,13 +11537,15 @@ when_list:
|
|||||||
$$= new (thd->mem_root) List<Item>;
|
$$= new (thd->mem_root) List<Item>;
|
||||||
if (unlikely($$ == NULL))
|
if (unlikely($$ == NULL))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
$$->push_back($2, thd->mem_root);
|
if (unlikely($$->push_back($2, thd->mem_root) ||
|
||||||
$$->push_back($4, thd->mem_root);
|
$$->push_back($4, thd->mem_root)))
|
||||||
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| when_list WHEN_SYM expr THEN_SYM expr
|
| when_list WHEN_SYM expr THEN_SYM expr
|
||||||
{
|
{
|
||||||
$1->push_back($3, thd->mem_root);
|
if (unlikely($1->push_back($3, thd->mem_root) ||
|
||||||
$1->push_back($5, thd->mem_root);
|
$1->push_back($5, thd->mem_root)))
|
||||||
|
MYSQL_YYABORT;
|
||||||
$$= $1;
|
$$= $1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -11655,7 +11554,8 @@ when_list_opt_else:
|
|||||||
when_list
|
when_list
|
||||||
| when_list ELSE expr
|
| when_list ELSE expr
|
||||||
{
|
{
|
||||||
$1->push_back($3, thd->mem_root);
|
if (unlikely($1->push_back($3, thd->mem_root)))
|
||||||
|
MYSQL_YYABORT;
|
||||||
$$= $1;
|
$$= $1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -12114,34 +12014,12 @@ derived_query_specification:
|
|||||||
derived_table_value_constructor:
|
derived_table_value_constructor:
|
||||||
VALUES
|
VALUES
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
Lex->tvc_start();
|
||||||
lex->field_list.empty();
|
}
|
||||||
lex->many_values.empty();
|
|
||||||
lex->insert_list=0;
|
|
||||||
}
|
|
||||||
values_list
|
values_list
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
if (Lex->tvc_finalize_derived())
|
||||||
lex->derived_tables|= DERIVED_SUBQUERY;
|
|
||||||
if (unlikely(!lex->expr_allows_subselect ||
|
|
||||||
lex->sql_command == (int)SQLCOM_PURGE))
|
|
||||||
{
|
|
||||||
thd->parse_error();
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
|
|
||||||
unlikely(mysql_new_select(lex, 1, NULL)))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
mysql_init_select(lex);
|
|
||||||
lex->current_select->linkage= DERIVED_TABLE_TYPE;
|
|
||||||
|
|
||||||
if (unlikely(!(lex->current_select->tvc=
|
|
||||||
new (lex->thd->mem_root)
|
|
||||||
table_value_constr(lex->many_values,
|
|
||||||
lex->current_select,
|
|
||||||
lex->current_select->options))))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
lex->many_values.empty();
|
|
||||||
$$= NULL;
|
$$= NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -13188,7 +13066,7 @@ table_list:
|
|||||||
table_name:
|
table_name:
|
||||||
table_ident
|
table_ident
|
||||||
{
|
{
|
||||||
if (unlikely(!Select->add_table_to_list(thd, $1, NULL,
|
if (unlikely(!Select->add_table_to_list(thd, $1, NULL,
|
||||||
TL_OPTION_UPDATING,
|
TL_OPTION_UPDATING,
|
||||||
YYPS->m_lock_type,
|
YYPS->m_lock_type,
|
||||||
YYPS->m_mdl_type)))
|
YYPS->m_mdl_type)))
|
||||||
@ -14967,17 +14845,13 @@ NUM_literal:
|
|||||||
$$= new (thd->mem_root) Item_decimal(thd, $1.str, $1.length,
|
$$= new (thd->mem_root) Item_decimal(thd, $1.str, $1.length,
|
||||||
thd->charset());
|
thd->charset());
|
||||||
if (unlikely($$ == NULL) || unlikely(thd->is_error()))
|
if (unlikely($$ == NULL) || unlikely(thd->is_error()))
|
||||||
{
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
| FLOAT_NUM
|
| FLOAT_NUM
|
||||||
{
|
{
|
||||||
$$= new (thd->mem_root) Item_float(thd, $1.str, $1.length);
|
$$= new (thd->mem_root) Item_float(thd, $1.str, $1.length);
|
||||||
if (unlikely($$ == NULL) || unlikely(thd->is_error()))
|
if (unlikely($$ == NULL) || unlikely(thd->is_error()))
|
||||||
{
|
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -15952,13 +15826,13 @@ start_option_value_list_following_option_type:
|
|||||||
option_value_following_option_type
|
option_value_following_option_type
|
||||||
{
|
{
|
||||||
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
option_value_list_continued
|
option_value_list_continued
|
||||||
| TRANSACTION_SYM transaction_characteristics
|
| TRANSACTION_SYM transaction_characteristics
|
||||||
{
|
{
|
||||||
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -15976,7 +15850,7 @@ option_value_list:
|
|||||||
option_value
|
option_value
|
||||||
{
|
{
|
||||||
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
| option_value_list ','
|
| option_value_list ','
|
||||||
{
|
{
|
||||||
@ -15985,7 +15859,7 @@ option_value_list:
|
|||||||
option_value
|
option_value
|
||||||
{
|
{
|
||||||
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY)))
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -16094,7 +15968,7 @@ option_value_no_option_type:
|
|||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
sp_pcontext *spc= lex->spcont;
|
sp_pcontext *spc= lex->spcont;
|
||||||
LEX_CSTRING names= { STRING_WITH_LEN("names") };
|
LEX_CSTRING names= { STRING_WITH_LEN("names") };
|
||||||
if (spc && spc->find_variable(&names, false))
|
if (unlikely(spc && spc->find_variable(&names, false)))
|
||||||
my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
|
my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
|
||||||
else
|
else
|
||||||
thd->parse_error();
|
thd->parse_error();
|
||||||
@ -16171,6 +16045,7 @@ option_value_no_option_type:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
transaction_characteristics:
|
transaction_characteristics:
|
||||||
transaction_access_mode
|
transaction_access_mode
|
||||||
| isolation_level
|
| isolation_level
|
||||||
@ -17135,29 +17010,20 @@ simple_table:
|
|||||||
query_specification { $$= $1; }
|
query_specification { $$= $1; }
|
||||||
| table_value_constructor { $$= $1; }
|
| table_value_constructor { $$= $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
table_value_constructor:
|
table_value_constructor:
|
||||||
VALUES
|
VALUES
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
Lex->tvc_start();
|
||||||
lex->field_list.empty();
|
|
||||||
lex->many_values.empty();
|
|
||||||
lex->insert_list=0;
|
|
||||||
}
|
}
|
||||||
values_list
|
values_list
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
$$= Lex->current_select;
|
||||||
$$= lex->current_select;
|
if (Lex->tvc_finalize())
|
||||||
mysql_init_select(Lex);
|
MYSQL_YYABORT;
|
||||||
if (unlikely(!($$->tvc=
|
|
||||||
new (lex->thd->mem_root)
|
|
||||||
table_value_constr(lex->many_values, $$,
|
|
||||||
$$->options))))
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
lex->many_values.empty();
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Corresponds to the SQL Standard
|
Corresponds to the SQL Standard
|
||||||
<query specification> ::=
|
<query specification> ::=
|
||||||
@ -17181,7 +17047,7 @@ query_term_union_not_ready:
|
|||||||
|
|
||||||
query_term_union_ready:
|
query_term_union_ready:
|
||||||
simple_table opt_select_lock_type { $$= $1; }
|
simple_table opt_select_lock_type { $$= $1; }
|
||||||
| '(' select_paren_derived ')' { $$= $2; }
|
| '(' select_paren_derived ')' { $$= $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
query_expression_body:
|
query_expression_body:
|
||||||
@ -17449,8 +17315,8 @@ trigger_tail:
|
|||||||
}
|
}
|
||||||
table_ident /* $10 */
|
table_ident /* $10 */
|
||||||
FOR_SYM
|
FOR_SYM
|
||||||
remember_name /* $13 */
|
remember_name /* $12 */
|
||||||
{ /* $14 */
|
{ /* $13 */
|
||||||
Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
|
Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
|
||||||
}
|
}
|
||||||
EACH_SYM
|
EACH_SYM
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user