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
0e010389
Commit
0e010389
authored
Mar 10, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: forced, hidden versioning [closes #32]
parent
cbb67428
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
118 additions
and
10 deletions
+118
-10
include/mysql_com.h
include/mysql_com.h
+2
-2
plugin/versioning/CMakeLists.txt
plugin/versioning/CMakeLists.txt
+17
-0
plugin/versioning/versioning.cc
plugin/versioning/versioning.cc
+69
-0
sql/handler.cc
sql/handler.cc
+9
-1
sql/handler.h
sql/handler.h
+2
-1
sql/mysqld.cc
sql/mysqld.cc
+2
-0
sql/mysqld.h
sql/mysqld.h
+2
-0
sql/sql_parse.cc
sql/sql_parse.cc
+1
-4
sql/sql_show.cc
sql/sql_show.cc
+6
-2
sql/sys_vars.cc
sql/sys_vars.cc
+8
-0
No files found.
include/mysql_com.h
View file @
0e010389
...
...
@@ -185,10 +185,10 @@ enum enum_indicator_type
#define FIELD_IS_DROPPED (1U << 26)
/* Intern: Field is being dropped */
#define VERS_SYS_START_FLAG (1 << 27)
/* autogenerated column declared with
`generated always a
t
row start`
`generated always a
s
row start`
(see II.a SQL Standard) */
#define VERS_SYS_END_FLAG (1 << 28)
/* autogenerated column declared with
`generated always a
t
row end`
`generated always a
s
row end`
(see II.a SQL Standard).*/
#define VERS_OPTIMIZED_UPDATE_FLAG (1 << 29)
/* column that doesn't support
system versioning when table
...
...
plugin/versioning/CMakeLists.txt
0 → 100644
View file @
0e010389
# Copyright (c) 2016, MariaDB corporation. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
MYSQL_ADD_PLUGIN
(
versioning versioning.cc
MODULE_ONLY MODULE_OUTPUT_NAME
"versioning"
COMPONENT Test
)
plugin/versioning/versioning.cc
0 → 100644
View file @
0e010389
/* Copyright (c) 2016, MariaDB corporation. All rights
reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <mysql_version.h>
#include <mysqld.h>
#include "sql_plugin.h" // st_plugin_int
/*
Disable __attribute__() on non-gcc compilers.
*/
#if !defined(__attribute__) && !defined(__GNUC__)
#define __attribute__(A)
#endif
static
int
forced_versioning_init
(
void
*
p
__attribute__
((
unused
)))
{
DBUG_ENTER
(
"forced_versioning_init"
);
vers_force
=
true
;
vers_hide
=
true
;
DBUG_RETURN
(
0
);
}
static
int
forced_versioning_deinit
(
void
*
p
__attribute__
((
unused
)))
{
DBUG_ENTER
(
"forced_versioning_deinit"
);
vers_force
=
false
;
vers_hide
=
false
;
DBUG_RETURN
(
0
);
}
struct
st_mysql_daemon
forced_versioning_plugin
=
{
MYSQL_DAEMON_INTERFACE_VERSION
};
/*
Plugin library descriptor
*/
maria_declare_plugin
(
forced_versioning
)
{
MYSQL_DAEMON_PLUGIN
,
&
forced_versioning_plugin
,
"forced_versioning"
,
"Natsys Lab"
,
"Enable System Vesioning for all newly created tables"
,
PLUGIN_LICENSE_GPL
,
forced_versioning_init
,
/* Plugin Init */
forced_versioning_deinit
,
/* Plugin Deinit */
0x0100
/* 1.0 */
,
NULL
,
/* status variables */
NULL
,
/* system variables */
"1.0"
,
/* string version */
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
/* maturity */
}
maria_declare_plugin_end
;
sql/handler.cc
View file @
0e010389
...
...
@@ -6669,9 +6669,17 @@ bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info,
bool
Vers_parse_info
::
check_and_fix_implicit
(
THD
*
thd
,
Alter_info
*
alter_info
,
bool
integer_fields
,
HA_CREATE_INFO
*
create_info
,
const
char
*
table_name
)
{
bool
integer_fields
=
create_info
->
db_type
->
flags
&
HTON_SUPPORTS_SYS_VERSIONING
;
if
(
vers_force
)
{
declared_with_system_versioning
=
true
;
create_info
->
options
|=
HA_VERSIONED_TABLE
;
}
if
(
!
need_to_check
())
return
false
;
...
...
sql/handler.h
View file @
0e010389
...
...
@@ -1720,7 +1720,8 @@ struct Vers_parse_info
public:
bool
check_and_fix_implicit
(
THD
*
thd
,
Alter_info
*
alter_info
,
bool
integer_fields
,
const
char
*
table_name
);
HA_CREATE_INFO
*
create_info
,
const
char
*
table_name
);
bool
check_and_fix_alter
(
THD
*
thd
,
Alter_info
*
alter_info
,
HA_CREATE_INFO
*
create_info
,
TABLE_SHARE
*
share
);
bool
fix_create_like
(
THD
*
thd
,
Alter_info
*
alter_info
,
...
...
sql/mysqld.cc
View file @
0e010389
...
...
@@ -783,6 +783,8 @@ char *opt_logname, *opt_slow_logname, *opt_bin_logname;
/* System Versioning */
char
*
temporal_current_timestamp
;
my_bool
vers_force
=
false
;
my_bool
vers_hide
=
false
;
/* Static variables */
...
...
sql/mysqld.h
View file @
0e010389
...
...
@@ -176,6 +176,8 @@ extern char *opt_backup_history_logname, *opt_backup_progress_logname,
extern
const
char
*
log_output_str
;
extern
const
char
*
log_backup_output_str
;
extern
char
*
temporal_current_timestamp
;
extern
my_bool
vers_force
;
extern
my_bool
vers_hide
;
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_parse.cc
View file @
0e010389
...
...
@@ -3876,12 +3876,9 @@ mysql_execute_command(THD *thd)
if
(
!
(
create_info
.
used_fields
&
HA_CREATE_USED_ENGINE
))
create_info
.
use_default_db_type
(
thd
);
DBUG_ASSERT
(
create_info
.
db_type
);
if
(
!
create_info
.
like
()
&&
create_info
.
vers_info
.
check_and_fix_implicit
(
thd
,
&
alter_info
,
create_info
.
db_type
->
flags
&
HTON_SUPPORTS_SYS_VERSIONING
,
create_table
->
table_name
))
thd
,
&
alter_info
,
&
create_info
,
create_table
->
table_name
))
{
goto
end_with_restore_list
;
}
...
...
sql/sql_show.cc
View file @
0e010389
...
...
@@ -2064,6 +2064,10 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
{
uint
flags
=
field
->
flags
;
if
(
vers_hide
&&
(
flags
&
(
VERS_SYS_START_FLAG
|
VERS_SYS_END_FLAG
)))
continue
;
if
(
ptr
!=
table
->
field
)
packet
->
append
(
STRING_WITH_LEN
(
",
\n
"
));
...
...
@@ -2229,7 +2233,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
hton
->
index_options
);
}
if
(
table
->
versioned
())
if
(
table
->
versioned
()
&&
!
vers_hide
)
{
const
Field
*
fs
=
table
->
vers_start_field
();
const
Field
*
fe
=
table
->
vers_end_field
();
...
...
@@ -2278,7 +2282,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
add_table_options
(
thd
,
table
,
create_info_arg
,
table_list
->
schema_table
!=
0
,
0
,
packet
);
if
(
table
->
versioned
())
if
(
table
->
versioned
()
&&
!
vers_hide
)
{
packet
->
append
(
STRING_WITH_LEN
(
" WITH SYSTEM VERSIONING"
));
}
...
...
sql/sys_vars.cc
View file @
0e010389
...
...
@@ -387,6 +387,14 @@ static Sys_var_charptr sys_temporal_current_timestamp(
GLOBAL_VAR
(
temporal_current_timestamp
),
CMD_LINE
(
REQUIRED_ARG
,
'b'
),
IN_FS_CHARSET
,
DEFAULT
(
"now"
));
static
Sys_var_mybool
Sys_vers_force
(
"vers_force"
,
"Force system versioning for all created tables"
,
GLOBAL_VAR
(
vers_force
),
CMD_LINE
(
OPT_ARG
),
DEFAULT
(
FALSE
));
static
Sys_var_mybool
Sys_vers_hide
(
"vers_hide"
,
"Hide system versioning from being displayed in table info"
,
GLOBAL_VAR
(
vers_hide
),
CMD_LINE
(
OPT_ARG
),
DEFAULT
(
FALSE
));
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