Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b8bfc06b
Commit
b8bfc06b
authored
Feb 27, 2017
by
kevg
Committed by
Aleksey Midenkov
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL, Tests: temporal_current_timestamp for setting default AS OF timestamp [closes #117]
parent
fc7da4dd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
0 deletions
+98
-0
mysql-test/suite/versioning/r/variables.result
mysql-test/suite/versioning/r/variables.result
+38
-0
mysql-test/suite/versioning/t/variables.test
mysql-test/suite/versioning/t/variables.test
+28
-0
sql/mysqld.cc
sql/mysqld.cc
+3
-0
sql/mysqld.h
sql/mysqld.h
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+23
-0
sql/sys_vars.cc
sql/sys_vars.cc
+5
-0
No files found.
mysql-test/suite/versioning/r/variables.result
0 → 100644
View file @
b8bfc06b
create table t (a int) with system versioning;
insert into t values (1);
update t set a=2;
select * from t;
a
2
show variables where Variable_name like "temporal_current_timestamp%";
Variable_name Value
temporal_current_timestamp now
set global temporal_current_timestamp = '2031-1-1 0:0:0';
select * from t;
a
2
set global temporal_current_timestamp = '2011-1-1 0:0:0';
select * from t;
a
set global temporal_current_timestamp = 'all';
select * from t;
a
2
1
show variables where Variable_name like "temporal_current_timestamp%";
Variable_name Value
temporal_current_timestamp all
create view vt as select * from t;
select * from t;
a
2
1
drop view vt;
select * from (select * from t) as tt;
a
2
1
set session temporal_current_timestamp = 'now';
ERROR HY000: Variable 'temporal_current_timestamp' is a GLOBAL variable and should be set with SET GLOBAL
drop table t;
set global temporal_current_timestamp = 'now';
mysql-test/suite/versioning/t/variables.test
0 → 100644
View file @
b8bfc06b
create
table
t
(
a
int
)
with
system
versioning
;
insert
into
t
values
(
1
);
update
t
set
a
=
2
;
select
*
from
t
;
show
variables
where
Variable_name
like
"temporal_current_timestamp%"
;
set
global
temporal_current_timestamp
=
'2031-1-1 0:0:0'
;
select
*
from
t
;
set
global
temporal_current_timestamp
=
'2011-1-1 0:0:0'
;
select
*
from
t
;
set
global
temporal_current_timestamp
=
'all'
;
select
*
from
t
;
show
variables
where
Variable_name
like
"temporal_current_timestamp%"
;
create
view
vt
as
select
*
from
t
;
select
*
from
t
;
drop
view
vt
;
select
*
from
(
select
*
from
t
)
as
tt
;
--
error
ER_GLOBAL_VARIABLE
set
session
temporal_current_timestamp
=
'now'
;
drop
table
t
;
set
global
temporal_current_timestamp
=
'now'
;
sql/mysqld.cc
View file @
b8bfc06b
...
...
@@ -781,6 +781,9 @@ char *relay_log_info_file, *report_user, *report_password, *report_host;
char
*
opt_relay_logname
=
0
,
*
opt_relaylog_index_name
=
0
;
char
*
opt_logname
,
*
opt_slow_logname
,
*
opt_bin_logname
;
/* System Versioning */
char
*
temporal_current_timestamp
;
/* Static variables */
static
volatile
sig_atomic_t
kill_in_progress
;
...
...
sql/mysqld.h
View file @
b8bfc06b
...
...
@@ -175,6 +175,7 @@ extern char *opt_backup_history_logname, *opt_backup_progress_logname,
*
opt_backup_settings_name
;
extern
const
char
*
log_output_str
;
extern
const
char
*
log_backup_output_str
;
extern
char
*
temporal_current_timestamp
;
extern
char
*
mysql_home_ptr
,
*
pidfile_name_ptr
;
extern
MYSQL_PLUGIN_IMPORT
char
glob_hostname
[
FN_REFLEN
];
extern
char
mysql_home
[
FN_REFLEN
];
...
...
sql/sql_select.cc
View file @
b8bfc06b
...
...
@@ -62,6 +62,7 @@
#include <my_bit.h>
#include <hash.h>
#include <ft_global.h>
#include "sys_vars_shared.h"
/*
A key part number that means we're using a fulltext scan.
...
...
@@ -775,6 +776,28 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
DBUG_RETURN
(
-
1
);
}
if
(
vers_conditions
.
type
==
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
const
char
var
[]
=
"temporal_current_timestamp"
;
sys_var
*
sv
=
intern_find_sys_var
(
var
,
sizeof
(
var
)
-
1
);
DBUG_ASSERT
(
sv
);
const
char
*
data
=
*
(
char
**
)
sv
->
option
.
value
;
DBUG_ASSERT
(
data
);
if
(
0
==
strcmp
(
data
,
"all"
))
{
vers_conditions
.
init
(
FOR_SYSTEM_TIME_ALL
,
UNIT_TIMESTAMP
);
}
else
if
(
0
!=
strcmp
(
data
,
"now"
))
{
Item
*
ts
=
create_temporal_literal
(
thd
,
data
,
strlen
(
data
),
system_charset_info
,
MYSQL_TYPE_DATETIME
,
true
);
if
(
!
ts
)
DBUG_RETURN
(
-
1
);
vers_conditions
.
init
(
FOR_SYSTEM_TIME_AS_OF
,
UNIT_TIMESTAMP
,
ts
);
}
}
if
(
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
)
{
switch
(
slex
->
lock_type
)
...
...
sql/sys_vars.cc
View file @
b8bfc06b
...
...
@@ -382,6 +382,11 @@ static Sys_var_charptr Sys_basedir(
READ_ONLY
GLOBAL_VAR
(
mysql_home_ptr
),
CMD_LINE
(
REQUIRED_ARG
,
'b'
),
IN_FS_CHARSET
,
DEFAULT
(
0
));
static
Sys_var_charptr
sys_temporal_current_timestamp
(
"temporal_current_timestamp"
,
"Default AS OF value for versioned tables"
,
GLOBAL_VAR
(
temporal_current_timestamp
),
CMD_LINE
(
REQUIRED_ARG
,
'b'
),
IN_FS_CHARSET
,
DEFAULT
(
"now"
));
static
Sys_var_ulonglong
Sys_binlog_cache_size
(
"binlog_cache_size"
,
"The size of the transactional cache for "
"updates to transactional engines for the binary log. "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment