mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
@ -1,32 +1,32 @@
|
|||||||
create table t (a int) with system versioning;
|
create table t (a int) with system versioning;
|
||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a= 2;
|
update t set a= 2;
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp NOW
|
versioning_asof_timestamp CURRENT
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp NOW
|
versioning_asof_timestamp CURRENT
|
||||||
select * from t;
|
select * from t;
|
||||||
a
|
a
|
||||||
2
|
2
|
||||||
set versioning_current_timestamp = '2031-1-1 0:0:0';
|
set versioning_asof_timestamp= '2031-1-1 0:0:0';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 2031-01-01 00:00:00.000000
|
versioning_asof_timestamp 2031-01-01 00:00:00.000000
|
||||||
select * from t;
|
select * from t;
|
||||||
a
|
a
|
||||||
2
|
2
|
||||||
set versioning_current_timestamp = '2011-1-1 0:0:0';
|
set versioning_asof_timestamp= '2011-1-1 0:0:0';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 2011-01-01 00:00:00.000000
|
versioning_asof_timestamp 2011-01-01 00:00:00.000000
|
||||||
select * from t;
|
select * from t;
|
||||||
a
|
a
|
||||||
set versioning_current_timestamp = 'all';
|
set versioning_asof_timestamp= ALL;
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp ALL
|
versioning_asof_timestamp ALL
|
||||||
select * from t;
|
select * from t;
|
||||||
a
|
a
|
||||||
2
|
2
|
||||||
@ -41,62 +41,68 @@ select * from (select * from t) as tt;
|
|||||||
a
|
a
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
set global versioning_current_timestamp= 'alley';
|
set global versioning_asof_timestamp= 'alley';
|
||||||
ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'alley'
|
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'alley'
|
||||||
set global versioning_current_timestamp= null;
|
set global versioning_asof_timestamp= null;
|
||||||
ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'NULL'
|
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'NULL'
|
||||||
set global versioning_current_timestamp= 1;
|
set global versioning_asof_timestamp= 1;
|
||||||
ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp'
|
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
|
||||||
set global versioning_current_timestamp= 1.1;
|
set global versioning_asof_timestamp= 1.1;
|
||||||
ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp'
|
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
|
||||||
set versioning_current_timestamp= 'alley';
|
set versioning_asof_timestamp= 'alley';
|
||||||
ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'alley'
|
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'alley'
|
||||||
set versioning_current_timestamp= null;
|
set versioning_asof_timestamp= null;
|
||||||
ERROR 42000: Variable 'versioning_current_timestamp' can't be set to the value of 'NULL'
|
ERROR 42000: Variable 'versioning_asof_timestamp' can't be set to the value of 'NULL'
|
||||||
set versioning_current_timestamp= 1;
|
set versioning_asof_timestamp= 1;
|
||||||
ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp'
|
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
|
||||||
set versioning_current_timestamp= 1.1;
|
set versioning_asof_timestamp= 1.1;
|
||||||
ERROR 42000: Incorrect argument type to variable 'versioning_current_timestamp'
|
ERROR 42000: Incorrect argument type to variable 'versioning_asof_timestamp'
|
||||||
set global versioning_current_timestamp= '1911-11-11 11:11:11.1111119';
|
set global versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
|
||||||
show global variables like 'versioning_current_timestamp';
|
|
||||||
Variable_name Value
|
|
||||||
versioning_current_timestamp 1911-11-11 11:11:11.111111
|
|
||||||
set global versioning_current_timestamp= '1900-01-01 00:00:00';
|
|
||||||
show global variables like 'versioning_current_timestamp';
|
|
||||||
Variable_name Value
|
|
||||||
versioning_current_timestamp 1900-01-01 00:00:00.000000
|
|
||||||
set global versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
show global variables like 'versioning_current_timestamp';
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
|
show global variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 1911-11-11 11:11:11.111111
|
versioning_asof_timestamp 1911-11-11 11:11:11.111111
|
||||||
set @ts= timestamp'1900-01-01 00:00:00';
|
set global versioning_asof_timestamp= '1900-01-01 00:00:00';
|
||||||
set global versioning_current_timestamp= @ts;
|
show global variables like 'versioning_asof_timestamp';
|
||||||
show global variables like 'versioning_current_timestamp';
|
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 1900-01-01 00:00:00.000000
|
versioning_asof_timestamp 1900-01-01 00:00:00.000000
|
||||||
set versioning_current_timestamp= '1911-11-11 11:11:11.1111119';
|
set global versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
||||||
show variables like 'versioning_current_timestamp';
|
|
||||||
Variable_name Value
|
|
||||||
versioning_current_timestamp 1911-11-11 11:11:11.111111
|
|
||||||
set versioning_current_timestamp= '1900-01-01 00:00:00';
|
|
||||||
show variables like 'versioning_current_timestamp';
|
|
||||||
Variable_name Value
|
|
||||||
versioning_current_timestamp 1900-01-01 00:00:00.000000
|
|
||||||
set versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
show variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 1911-11-11 11:11:11.111111
|
versioning_asof_timestamp 1911-11-11 11:11:11.111111
|
||||||
set @ts= timestamp'1900-01-01 00:00:00';
|
set @ts= timestamp'1900-01-01 00:00:00';
|
||||||
set versioning_current_timestamp= @ts;
|
set global versioning_asof_timestamp= @ts;
|
||||||
show variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_current_timestamp 1900-01-01 00:00:00.000000
|
versioning_asof_timestamp 1900-01-01 00:00:00.000000
|
||||||
set global versioning_current_timestamp= 'now';
|
set versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
|
||||||
set versioning_current_timestamp= 'now';
|
Warnings:
|
||||||
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
Variable_name Value
|
||||||
|
versioning_asof_timestamp 1911-11-11 11:11:11.111111
|
||||||
|
set versioning_asof_timestamp= '1900-01-01 00:00:00';
|
||||||
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
Variable_name Value
|
||||||
|
versioning_asof_timestamp 1900-01-01 00:00:00.000000
|
||||||
|
set versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
||||||
|
Warnings:
|
||||||
|
Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
|
||||||
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
Variable_name Value
|
||||||
|
versioning_asof_timestamp 1911-11-11 11:11:11.111111
|
||||||
|
set @ts= timestamp'1900-01-01 00:00:00';
|
||||||
|
set versioning_asof_timestamp= @ts;
|
||||||
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
Variable_name Value
|
||||||
|
versioning_asof_timestamp 1900-01-01 00:00:00.000000
|
||||||
|
set global versioning_asof_timestamp= CURRENT;
|
||||||
|
set versioning_asof_timestamp= CURRENT;
|
||||||
show variables where variable_name = "versioning_hide";
|
show variables where variable_name = "versioning_hide";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
versioning_hide IMPLICIT
|
versioning_hide IMPLICIT
|
||||||
|
@ -2,20 +2,20 @@ create table t (a int) with system versioning;
|
|||||||
insert into t values (1);
|
insert into t values (1);
|
||||||
update t set a= 2;
|
update t set a= 2;
|
||||||
|
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
select * from t;
|
select * from t;
|
||||||
|
|
||||||
set versioning_current_timestamp = '2031-1-1 0:0:0';
|
set versioning_asof_timestamp= '2031-1-1 0:0:0';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
select * from t;
|
select * from t;
|
||||||
|
|
||||||
set versioning_current_timestamp = '2011-1-1 0:0:0';
|
set versioning_asof_timestamp= '2011-1-1 0:0:0';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
select * from t;
|
select * from t;
|
||||||
|
|
||||||
set versioning_current_timestamp = 'all';
|
set versioning_asof_timestamp= ALL;
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
select * from t;
|
select * from t;
|
||||||
|
|
||||||
create view vt as select * from t;
|
create view vt as select * from t;
|
||||||
@ -26,54 +26,54 @@ select * from (select * from t) as tt;
|
|||||||
|
|
||||||
# global
|
# global
|
||||||
--error ER_WRONG_VALUE_FOR_VAR
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
set global versioning_current_timestamp= 'alley';
|
set global versioning_asof_timestamp= 'alley';
|
||||||
--error ER_WRONG_VALUE_FOR_VAR
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
set global versioning_current_timestamp= null;
|
set global versioning_asof_timestamp= null;
|
||||||
--error ER_WRONG_TYPE_FOR_VAR
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
set global versioning_current_timestamp= 1;
|
set global versioning_asof_timestamp= 1;
|
||||||
--error ER_WRONG_TYPE_FOR_VAR
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
set global versioning_current_timestamp= 1.1;
|
set global versioning_asof_timestamp= 1.1;
|
||||||
|
|
||||||
# session
|
# session
|
||||||
--error ER_WRONG_VALUE_FOR_VAR
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
set versioning_current_timestamp= 'alley';
|
set versioning_asof_timestamp= 'alley';
|
||||||
--error ER_WRONG_VALUE_FOR_VAR
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
set versioning_current_timestamp= null;
|
set versioning_asof_timestamp= null;
|
||||||
--error ER_WRONG_TYPE_FOR_VAR
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
set versioning_current_timestamp= 1;
|
set versioning_asof_timestamp= 1;
|
||||||
--error ER_WRONG_TYPE_FOR_VAR
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
set versioning_current_timestamp= 1.1;
|
set versioning_asof_timestamp= 1.1;
|
||||||
|
|
||||||
# global
|
# global
|
||||||
set global versioning_current_timestamp= '1911-11-11 11:11:11.1111119';
|
set global versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set global versioning_current_timestamp= '1900-01-01 00:00:00';
|
set global versioning_asof_timestamp= '1900-01-01 00:00:00';
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set global versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
set global versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set @ts= timestamp'1900-01-01 00:00:00';
|
set @ts= timestamp'1900-01-01 00:00:00';
|
||||||
set global versioning_current_timestamp= @ts;
|
set global versioning_asof_timestamp= @ts;
|
||||||
show global variables like 'versioning_current_timestamp';
|
show global variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
# session
|
# session
|
||||||
set versioning_current_timestamp= '1911-11-11 11:11:11.1111119';
|
set versioning_asof_timestamp= '1911-11-11 11:11:11.1111119';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set versioning_current_timestamp= '1900-01-01 00:00:00';
|
set versioning_asof_timestamp= '1900-01-01 00:00:00';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set versioning_current_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
set versioning_asof_timestamp= timestamp'1911-11-11 11:11:11.1111119';
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set @ts= timestamp'1900-01-01 00:00:00';
|
set @ts= timestamp'1900-01-01 00:00:00';
|
||||||
set versioning_current_timestamp= @ts;
|
set versioning_asof_timestamp= @ts;
|
||||||
show variables like 'versioning_current_timestamp';
|
show variables like 'versioning_asof_timestamp';
|
||||||
|
|
||||||
set global versioning_current_timestamp= 'now';
|
set global versioning_asof_timestamp= CURRENT;
|
||||||
set versioning_current_timestamp= 'now';
|
set versioning_asof_timestamp= CURRENT;
|
||||||
|
|
||||||
show variables where variable_name = "versioning_hide";
|
show variables where variable_name = "versioning_hide";
|
||||||
select * from t for system_time all;
|
select * from t for system_time all;
|
||||||
|
@ -9450,15 +9450,27 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument)
|
|||||||
WSREP_SYNC_WAIT_BEFORE_READ);
|
WSREP_SYNC_WAIT_BEFORE_READ);
|
||||||
break;
|
break;
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
case OPT_VERS_CURRENT_TIME:
|
case OPT_VERS_ASOF_TIMESTAMP:
|
||||||
sys_var *var= static_cast<sys_var*>(opt->app_type);
|
int type= find_type(argument, opt->typelib, FIND_TYPE_BASIC);
|
||||||
DBUG_ASSERT(var);
|
st_vers_asof_timestamp &out= global_system_variables.vers_asof_timestamp;
|
||||||
if (var->option_updated())
|
if (type)
|
||||||
{
|
{
|
||||||
sql_print_error("Can't start server: "
|
out.type= type - 1;
|
||||||
"cannot process --vers-current-time=%.*s",
|
DBUG_ASSERT(out.type < FOR_SYSTEM_TIME_AS_OF);
|
||||||
FN_REFLEN, argument);
|
}
|
||||||
return 1;
|
else
|
||||||
|
{
|
||||||
|
out.type= FOR_SYSTEM_TIME_AS_OF;
|
||||||
|
MYSQL_TIME_STATUS status;
|
||||||
|
bool err= str_to_datetime(argument, strlen(argument), &out.ltime, 0, &status);
|
||||||
|
if (err || (status.warnings & ~MYSQL_TIME_NOTE_TRUNCATED))
|
||||||
|
{
|
||||||
|
sql_print_error("Can't start server: "
|
||||||
|
"cannot process --%s=%.*s",
|
||||||
|
opt->name,
|
||||||
|
FN_REFLEN, argument);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
21
sql/mysqld.h
21
sql/mysqld.h
@ -184,25 +184,24 @@ extern const char *log_backup_output_str;
|
|||||||
enum vers_range_type_t
|
enum vers_range_type_t
|
||||||
{
|
{
|
||||||
FOR_SYSTEM_TIME_UNSPECIFIED = 0,
|
FOR_SYSTEM_TIME_UNSPECIFIED = 0,
|
||||||
|
FOR_SYSTEM_TIME_ALL,
|
||||||
FOR_SYSTEM_TIME_AS_OF,
|
FOR_SYSTEM_TIME_AS_OF,
|
||||||
FOR_SYSTEM_TIME_FROM_TO,
|
FOR_SYSTEM_TIME_FROM_TO,
|
||||||
FOR_SYSTEM_TIME_BETWEEN,
|
FOR_SYSTEM_TIME_BETWEEN,
|
||||||
FOR_SYSTEM_TIME_ALL,
|
|
||||||
FOR_SYSTEM_TIME_BEFORE
|
FOR_SYSTEM_TIME_BEFORE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Used only for @@versioning_current_time sysvar. This struct must be POD
|
struct st_vers_asof_timestamp
|
||||||
* because of str_value, which is used as interface to user.
|
|
||||||
* So no virtual-anything! */
|
|
||||||
struct st_vers_current_time
|
|
||||||
{
|
{
|
||||||
char *str_value; // must be first
|
const char *getopt_value;
|
||||||
vers_range_type_t type;
|
ulong type;
|
||||||
MYSQL_TIME ltime;
|
MYSQL_TIME ltime;
|
||||||
st_vers_current_time() :
|
st_vers_asof_timestamp() :
|
||||||
str_value(NULL),
|
getopt_value(NULL),
|
||||||
type(FOR_SYSTEM_TIME_UNSPECIFIED)
|
type(FOR_SYSTEM_TIME_UNSPECIFIED)
|
||||||
{}
|
{
|
||||||
|
DBUG_ASSERT((void *)this == &this->getopt_value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum vers_hide_enum
|
enum vers_hide_enum
|
||||||
@ -702,7 +701,7 @@ enum options_mysqld
|
|||||||
OPT_SSL_KEY,
|
OPT_SSL_KEY,
|
||||||
OPT_THREAD_CONCURRENCY,
|
OPT_THREAD_CONCURRENCY,
|
||||||
OPT_WANT_CORE,
|
OPT_WANT_CORE,
|
||||||
OPT_VERS_CURRENT_TIME,
|
OPT_VERS_ASOF_TIMESTAMP,
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
OPT_WSREP_CAUSAL_READS,
|
OPT_WSREP_CAUSAL_READS,
|
||||||
OPT_WSREP_SYNC_WAIT,
|
OPT_WSREP_SYNC_WAIT,
|
||||||
|
@ -224,13 +224,6 @@ private:
|
|||||||
virtual bool session_update(THD *thd, set_var *var) = 0;
|
virtual bool session_update(THD *thd, set_var *var) = 0;
|
||||||
virtual bool global_update(THD *thd, set_var *var) = 0;
|
virtual bool global_update(THD *thd, set_var *var) = 0;
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool option_updated()
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
A pointer to a value of the variable for SHOW.
|
A pointer to a value of the variable for SHOW.
|
||||||
|
@ -703,7 +703,7 @@ typedef struct system_variables
|
|||||||
uint column_compression_zlib_level;
|
uint column_compression_zlib_level;
|
||||||
ulong in_subquery_conversion_threshold;
|
ulong in_subquery_conversion_threshold;
|
||||||
|
|
||||||
st_vers_current_time vers_current_time;
|
st_vers_asof_timestamp vers_asof_timestamp;
|
||||||
my_bool vers_force;
|
my_bool vers_force;
|
||||||
ulong vers_hide;
|
ulong vers_hide;
|
||||||
my_bool vers_innodb_algorithm_simple;
|
my_bool vers_innodb_algorithm_simple;
|
||||||
|
@ -673,8 +673,8 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
|
|||||||
|
|
||||||
bool vers_select_conds_t::init_from_sysvar(THD *thd)
|
bool vers_select_conds_t::init_from_sysvar(THD *thd)
|
||||||
{
|
{
|
||||||
st_vers_current_time &in= thd->variables.vers_current_time;
|
st_vers_asof_timestamp &in= thd->variables.vers_asof_timestamp;
|
||||||
type= in.type;
|
type= (vers_range_type_t) in.type;
|
||||||
unit_start= UNIT_TIMESTAMP;
|
unit_start= UNIT_TIMESTAMP;
|
||||||
if (type != FOR_SYSTEM_TIME_UNSPECIFIED && type != FOR_SYSTEM_TIME_ALL)
|
if (type != FOR_SYSTEM_TIME_UNSPECIFIED && type != FOR_SYSTEM_TIME_ALL)
|
||||||
{
|
{
|
||||||
|
@ -387,23 +387,25 @@ static Sys_var_charptr Sys_my_bind_addr(
|
|||||||
READ_ONLY GLOBAL_VAR(my_bind_addr_str), CMD_LINE(REQUIRED_ARG),
|
READ_ONLY GLOBAL_VAR(my_bind_addr_str), CMD_LINE(REQUIRED_ARG),
|
||||||
IN_FS_CHARSET, DEFAULT(0));
|
IN_FS_CHARSET, DEFAULT(0));
|
||||||
|
|
||||||
static Sys_var_vers_asof Sys_vers_current_time(
|
const char *Sys_var_vers_asof::asof_keywords[]= {"CURRENT", "ALL", NULL};
|
||||||
"versioning_current_timestamp", "Default AS OF value for versioned tables",
|
static Sys_var_vers_asof Sys_vers_asof_timestamp(
|
||||||
SESSION_VAR(vers_current_time), CMD_LINE(REQUIRED_ARG, OPT_VERS_CURRENT_TIME),
|
"versioning_asof_timestamp", "Default AS OF value for versioned queries",
|
||||||
IN_FS_CHARSET, DEFAULT("now"));
|
SESSION_VAR(vers_asof_timestamp.getopt_value), CMD_LINE(REQUIRED_ARG, OPT_VERS_ASOF_TIMESTAMP),
|
||||||
|
Sys_var_vers_asof::asof_keywords, DEFAULT(FOR_SYSTEM_TIME_UNSPECIFIED));
|
||||||
|
|
||||||
static Sys_var_mybool Sys_vers_force(
|
static Sys_var_mybool Sys_vers_force(
|
||||||
"versioning_force", "Force system versioning for all created tables",
|
"versioning_force", "Force system versioning for all created tables",
|
||||||
SESSION_VAR(vers_force), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
SESSION_VAR(vers_force), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||||
|
|
||||||
static const char *vers_hide_keywords[]= {"AUTO", "IMPLICIT", "FULL", "NEVER", NullS};
|
static const char *vers_hide_keywords[]= {"AUTO", "IMPLICIT", "FULL", "NEVER", NULL};
|
||||||
static Sys_var_enum Sys_vers_hide(
|
static Sys_var_enum Sys_vers_hide(
|
||||||
"versioning_hide", "Hide system versioning from being displayed in table info. "
|
"versioning_hide", "Hide system versioning from being displayed in table info. "
|
||||||
"AUTO: hide implicit system fields only in non-versioned and AS OF queries; "
|
"AUTO: hide implicit system fields only in non-versioned and AS OF queries; "
|
||||||
"IMPLICIT: hide implicit system fields in all queries; "
|
"IMPLICIT: hide implicit system fields in all queries; "
|
||||||
"FULL: hide any system fields in all queries and hide versioning info in SHOW commands; "
|
"FULL: hide any system fields in all queries and hide versioning info in SHOW commands; "
|
||||||
"NEVER: don't hide system fields",
|
"NEVER: don't hide system fields",
|
||||||
SESSION_VAR(vers_hide), CMD_LINE(OPT_ARG), vers_hide_keywords, DEFAULT(VERS_HIDE_AUTO));
|
SESSION_VAR(vers_hide), CMD_LINE(REQUIRED_ARG),
|
||||||
|
vers_hide_keywords, DEFAULT(VERS_HIDE_AUTO));
|
||||||
|
|
||||||
static Sys_var_mybool Sys_vers_innodb_algorithm_simple(
|
static Sys_var_mybool Sys_vers_innodb_algorithm_simple(
|
||||||
"versioning_innodb_algorithm_simple",
|
"versioning_innodb_algorithm_simple",
|
||||||
@ -411,14 +413,13 @@ static Sys_var_mybool Sys_vers_innodb_algorithm_simple(
|
|||||||
SESSION_VAR(vers_innodb_algorithm_simple), CMD_LINE(OPT_ARG),
|
SESSION_VAR(vers_innodb_algorithm_simple), CMD_LINE(OPT_ARG),
|
||||||
DEFAULT(TRUE));
|
DEFAULT(TRUE));
|
||||||
|
|
||||||
static const char *vers_alter_history_keywords[]= {"KEEP", "SURVIVE", "DROP",
|
static const char *vers_alter_history_keywords[]= {"KEEP", "SURVIVE", "DROP", NULL};
|
||||||
NULL};
|
|
||||||
static Sys_var_enum Sys_vers_alter_history(
|
static Sys_var_enum Sys_vers_alter_history(
|
||||||
"versioning_alter_history", "Versioning ALTER TABLE mode. "
|
"versioning_alter_history", "Versioning ALTER TABLE mode. "
|
||||||
"KEEP: leave historical system rows as is on ALTER TABLE; "
|
"KEEP: leave historical system rows as is on ALTER TABLE; "
|
||||||
"SURVIVE: use DDL survival feature; "
|
"SURVIVE: use DDL survival feature; "
|
||||||
"DROP: delete historical system rows on ALTER TABLE",
|
"DROP: delete historical system rows on ALTER TABLE",
|
||||||
SESSION_VAR(vers_alter_history), CMD_LINE(OPT_ARG),
|
SESSION_VAR(vers_alter_history), CMD_LINE(REQUIRED_ARG),
|
||||||
vers_alter_history_keywords, DEFAULT(VERS_ALTER_HISTORY_KEEP));
|
vers_alter_history_keywords, DEFAULT(VERS_ALTER_HISTORY_KEEP));
|
||||||
|
|
||||||
static Sys_var_ulonglong Sys_binlog_cache_size(
|
static Sys_var_ulonglong Sys_binlog_cache_size(
|
||||||
|
150
sql/sys_vars.ic
150
sql/sys_vars.ic
@ -2604,129 +2604,91 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Sys_var_vers_asof: public sys_var
|
class Sys_var_vers_asof: public Sys_var_enum
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sys_var_vers_asof(const char *name_arg, const char *comment, int flag_args,
|
static const char *asof_keywords[];
|
||||||
ptrdiff_t off, size_t size, CMD_LINE getopt, enum charset_enum is_os_charset_arg,
|
|
||||||
const char *def_val, on_check_function on_check_func=0, on_update_function on_update_func=0) :
|
public:
|
||||||
sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id, getopt.arg_type,
|
Sys_var_vers_asof(const char *name_arg,
|
||||||
SHOW_CHAR, (intptr) def_val, 0, VARIABLE_NOT_IN_BINLOG, on_check_func, on_update_func, 0)
|
const char *comment, int flag_args, ptrdiff_t off, size_t size,
|
||||||
|
CMD_LINE getopt, const char *values[],
|
||||||
|
uint def_val)
|
||||||
|
: Sys_var_enum(name_arg, comment, flag_args, off, size,
|
||||||
|
getopt, values, def_val)
|
||||||
{
|
{
|
||||||
option.var_type|= GET_STR;
|
// setval() accepts string rather enum
|
||||||
if (global_update(def_val))
|
option.var_type= GET_STR;
|
||||||
|
}
|
||||||
|
virtual bool do_check(THD *thd, set_var *var)
|
||||||
|
{
|
||||||
|
if (!Sys_var_enum::do_check(thd, var))
|
||||||
|
return false;
|
||||||
|
MYSQL_TIME ltime;
|
||||||
|
bool res= var->value->get_date(<ime, 0);
|
||||||
|
if (!res)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(false);
|
var->save_result.ulonglong_value= FOR_SYSTEM_TIME_AS_OF;
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool do_check(THD *thd, set_var *var)
|
private:
|
||||||
{ return false; }
|
bool update(set_var *var, st_vers_asof_timestamp &out)
|
||||||
|
{
|
||||||
|
bool res= false;
|
||||||
|
out.type= var->save_result.ulonglong_value;
|
||||||
|
if (out.type == FOR_SYSTEM_TIME_AS_OF)
|
||||||
|
{
|
||||||
|
res= var->value->get_date(&out.ltime, 0);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
bool update(String &in, st_vers_current_time &out)
|
public:
|
||||||
|
virtual bool global_update(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
if (in.length() == 3 && 0 == my_strcasecmp(in.charset(), "ALL", in.ptr()))
|
return update(var, global_var(st_vers_asof_timestamp));
|
||||||
{
|
|
||||||
out.type= FOR_SYSTEM_TIME_ALL;
|
|
||||||
}
|
|
||||||
else if (in.length() == 3 && 0 == my_strcasecmp(in.charset(), "NOW", in.ptr()))
|
|
||||||
{
|
|
||||||
out.type= FOR_SYSTEM_TIME_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MYSQL_TIME_STATUS status;
|
|
||||||
if (str_to_datetime(in.ptr(), in.length(), &out.ltime, flags, &status) ||
|
|
||||||
out.ltime.time_type != MYSQL_TIMESTAMP_DATETIME ||
|
|
||||||
(status.warnings & ~MYSQL_TIME_NOTE_TRUNCATED) != 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
out.type= FOR_SYSTEM_TIME_AS_OF;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
bool update(THD *thd, set_var *var, st_vers_current_time &out)
|
virtual bool session_update(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
Item *item= var->value;
|
return update(var, session_var(thd, st_vers_asof_timestamp));
|
||||||
|
}
|
||||||
|
|
||||||
switch (item->result_type())
|
private:
|
||||||
{
|
uchar *value_ptr(THD *thd, st_vers_asof_timestamp &val)
|
||||||
case TIME_RESULT:
|
|
||||||
{
|
|
||||||
if (item->get_date(&out.ltime, 0))
|
|
||||||
break;
|
|
||||||
out.type= FOR_SYSTEM_TIME_AS_OF;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case STRING_RESULT:
|
|
||||||
{
|
|
||||||
String *str= item->val_str();
|
|
||||||
if (!str || update(*str, out))
|
|
||||||
break;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String *str= item->val_str();
|
|
||||||
const char *cstr= str ? str->c_ptr_safe() : "NULL";
|
|
||||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name.str, cstr);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool global_update(const char *in)
|
|
||||||
{
|
|
||||||
String s(in, &my_charset_utf8_general_ci);
|
|
||||||
return update(s, global_var(st_vers_current_time));
|
|
||||||
}
|
|
||||||
bool option_updated()
|
|
||||||
{
|
|
||||||
return global_update(global_var(st_vers_current_time).str_value);
|
|
||||||
}
|
|
||||||
bool global_update(THD *thd, set_var *var)
|
|
||||||
{
|
|
||||||
return update(thd, var, global_var(st_vers_current_time));
|
|
||||||
}
|
|
||||||
bool session_update(THD *thd, set_var *var)
|
|
||||||
{
|
|
||||||
return update(thd, var, session_var(thd, st_vers_current_time));
|
|
||||||
}
|
|
||||||
uchar *valptr(THD *thd, st_vers_current_time &val)
|
|
||||||
{
|
{
|
||||||
switch (val.type)
|
switch (val.type)
|
||||||
{
|
{
|
||||||
case FOR_SYSTEM_TIME_UNSPECIFIED:
|
case FOR_SYSTEM_TIME_UNSPECIFIED:
|
||||||
return (uchar*) thd->strdup("NOW");
|
|
||||||
case FOR_SYSTEM_TIME_ALL:
|
case FOR_SYSTEM_TIME_ALL:
|
||||||
return (uchar*) thd->strdup("ALL");
|
return (uchar*) thd->strdup(asof_keywords[val.type]);
|
||||||
case FOR_SYSTEM_TIME_AS_OF:
|
case FOR_SYSTEM_TIME_AS_OF:
|
||||||
|
{
|
||||||
|
uchar *buf= (uchar*) thd->alloc(MAX_DATE_STRING_REP_LENGTH);
|
||||||
|
if (buf &&!my_datetime_to_str(&val.ltime, (char*) buf, 6))
|
||||||
{
|
{
|
||||||
uchar *buf= (uchar*) thd->alloc(MAX_DATE_STRING_REP_LENGTH);
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "versioning_asof_timestamp", "NULL (wrong datetime)");
|
||||||
if (buf)
|
return (uchar*) thd->strdup("Error: wrong datetime");
|
||||||
{
|
|
||||||
if (!my_datetime_to_str(&val.ltime, (char*) buf, 6))
|
|
||||||
{
|
|
||||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "vers_current_time", "NULL (wrong datetime)");
|
|
||||||
return (uchar*) thd->strdup("Error: wrong datetime");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "vers_current_time", "NULL (wrong range type)");
|
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "versioning_asof_timestamp", "NULL (wrong range type)");
|
||||||
return (uchar*) thd->strdup("Error: wrong range type");
|
return (uchar*) thd->strdup("Error: wrong range type");
|
||||||
}
|
}
|
||||||
void session_save_default(THD *thd, set_var *var)
|
void session_save_default(THD *thd, set_var *var)
|
||||||
{ DBUG_ASSERT(false); }
|
{ DBUG_ASSERT(false); }
|
||||||
void global_save_default(THD *thd, set_var *var)
|
void global_save_default(THD *thd, set_var *var)
|
||||||
{ DBUG_ASSERT(false); }
|
{ DBUG_ASSERT(false); }
|
||||||
uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
|
|
||||||
{ return valptr(thd, session_var(thd, st_vers_current_time)); }
|
|
||||||
uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
|
|
||||||
{ return valptr(thd, global_var(st_vers_current_time)); }
|
|
||||||
uchar *default_value_ptr(THD *thd)
|
uchar *default_value_ptr(THD *thd)
|
||||||
{ return (uchar *)option.def_value; }
|
{ return (uchar *)option.def_value; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
|
||||||
|
{ return value_ptr(thd, session_var(thd, st_vers_asof_timestamp)); }
|
||||||
|
virtual uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
|
||||||
|
{ return value_ptr(thd, global_var(st_vers_asof_timestamp)); }
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user