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
73f655d5
Commit
73f655d5
authored
Oct 25, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: VIEW without VERS_COMMIT_TS + CTE fix [fixes #295]
parent
9aae0be8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
54 deletions
+59
-54
mysql-test/suite/versioning/t/view.opt
mysql-test/suite/versioning/t/view.opt
+0
-1
sql/item.h
sql/item.h
+27
-6
sql/sql_select.cc
sql/sql_select.cc
+6
-47
sql/sql_type.cc
sql/sql_type.cc
+14
-0
sql/sql_type.h
sql/sql_type.h
+12
-0
No files found.
mysql-test/suite/versioning/t/view.opt
View file @
73f655d5
--versioning-hide=implicit
--plugin-load=versioning
sql/item.h
View file @
73f655d5
...
...
@@ -4587,6 +4587,12 @@ class Item_ref :public Item_ident
return
0
;
return
cleanup_processor
(
arg
);
}
virtual
bool
vers_trx_id
()
const
{
DBUG_ASSERT
(
ref
);
DBUG_ASSERT
(
*
ref
);
return
(
*
ref
)
->
vers_trx_id
();
}
};
...
...
@@ -6047,8 +6053,10 @@ class Item_type_holder: public Item,
if
(
item
->
real_type
()
==
Item
::
FIELD_ITEM
)
{
Item_field
*
item_field
=
(
Item_field
*
)
item
->
real_item
();
flags
|=
(
item_field
->
field
->
flags
&
m_
flags
|=
(
item_field
->
field
->
flags
&
(
VERS_SYS_START_FLAG
|
VERS_SYS_END_FLAG
));
// TODO: additional field flag?
m_vers_trx_id
=
item_field
->
field
->
vers_trx_id
();
}
}
public:
...
...
@@ -6056,7 +6064,8 @@ class Item_type_holder: public Item,
:
Item
(
thd
,
item
),
Type_handler_hybrid_field_type
(
item
->
real_type_handler
()),
enum_set_typelib
(
0
),
flags
(
0
)
m_flags
(
0
),
m_vers_trx_id
(
false
)
{
DBUG_ASSERT
(
item
->
fixed
);
maybe_null
=
item
->
maybe_null
;
...
...
@@ -6071,7 +6080,8 @@ class Item_type_holder: public Item,
Type_handler_hybrid_field_type
(
handler
),
Type_geometry_attributes
(
handler
,
attr
),
enum_set_typelib
(
attr
->
get_typelib
()),
flags
(
0
)
m_flags
(
0
),
m_vers_trx_id
(
false
)
{
name
=
item
->
name
;
Type_std_attributes
::
set
(
*
attr
);
...
...
@@ -6081,11 +6091,15 @@ class Item_type_holder: public Item,
const
Type_handler
*
type_handler
()
const
{
const
Type_handler
*
handler
=
Type_handler_hybrid_field_type
::
type_handler
();
const
Type_handler
*
handler
=
m_vers_trx_id
?
&
type_handler_vers_trx_id
:
Type_handler_hybrid_field_type
::
type_handler
();
return
handler
->
type_handler_for_item_field
();
}
const
Type_handler
*
real_type_handler
()
const
{
if
(
m_vers_trx_id
)
return
&
type_handler_vers_trx_id
;
return
Type_handler_hybrid_field_type
::
type_handler
();
}
...
...
@@ -6111,10 +6125,17 @@ class Item_type_holder: public Item,
}
Item
*
get_copy
(
THD
*
thd
,
MEM_ROOT
*
mem_root
)
{
return
0
;
}
uint
flags
;
private:
uint
m_flags
;
bool
m_vers_trx_id
;
public:
uint32
field_flags
()
const
{
return
flags
;
return
m_flags
;
}
virtual
bool
vers_trx_id
()
const
{
return
m_vers_trx_id
;
}
};
...
...
sql/sql_select.cc
View file @
73f655d5
...
...
@@ -861,54 +861,13 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
if
(
vers_conditions
)
{
vers_conditions
.
resolve_units
(
timestamps_only
);
if
(
timestamps_only
)
{
if
(
vers_conditions
.
unit_start
==
UNIT_TRX_ID
||
vers_conditions
.
unit_end
==
UNIT_TRX_ID
)
if
(
timestamps_only
&&
(
vers_conditions
.
unit_start
==
UNIT_TRX_ID
||
vers_conditions
.
unit_end
==
UNIT_TRX_ID
))
{
my_error
(
ER_VERS_ENGINE_UNSUPPORTED
,
MYF
(
0
),
table
->
table_name
);
DBUG_RETURN
(
-
1
);
}
}
else
if
(
thd
->
variables
.
vers_innodb_algorithm_simple
)
{
DBUG_ASSERT
(
table
->
table
->
s
&&
table
->
table
->
s
->
db_plugin
);
handlerton
*
hton
=
plugin_hton
(
table
->
table
->
s
->
db_plugin
);
DBUG_ASSERT
(
hton
);
bool
convert_start
=
false
;
bool
convert_end
=
false
;
switch
(
vers_conditions
.
type
)
{
case
FOR_SYSTEM_TIME_AS_OF
:
if
(
vers_conditions
.
unit_start
==
UNIT_TIMESTAMP
)
convert_start
=
convert_end
=
true
;
break
;
case
FOR_SYSTEM_TIME_BEFORE
:
if
(
vers_conditions
.
unit_start
==
UNIT_TIMESTAMP
)
convert_end
=
true
;
break
;
case
FOR_SYSTEM_TIME_FROM_TO
:
case
FOR_SYSTEM_TIME_BETWEEN
:
if
(
vers_conditions
.
unit_start
==
UNIT_TIMESTAMP
)
convert_end
=
true
;
if
(
vers_conditions
.
unit_end
==
UNIT_TIMESTAMP
)
convert_start
=
true
;
default:
break
;
}
if
(
convert_start
)
row_start
=
newx
Item_func_vtq_ts
(
thd
,
hton
,
row_start
,
VTQ_COMMIT_TS
);
if
(
convert_end
)
row_end
=
newx
Item_func_vtq_ts
(
thd
,
hton
,
row_end
,
VTQ_COMMIT_TS
);
}
}
Item
*
cond1
=
0
,
*
cond2
=
0
,
*
curr
=
0
;
// Temporary tables of can be created from INNODB tables and thus will
...
...
@@ -17481,9 +17440,9 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
if
(
type
==
Item
::
TYPE_HOLDER
)
{
Item_type_holder
*
ith
=
(
Item_type_holder
*
)
item
;
if
(
ith
->
f
lags
&
VERS_SYS_START_FLAG
)
if
(
ith
->
f
ield_flags
()
&
VERS_SYS_START_FLAG
)
sys_trx_start
=
new_field
;
else
if
(
ith
->
f
lags
&
VERS_SYS_END_FLAG
)
else
if
(
ith
->
f
ield_flags
()
&
VERS_SYS_END_FLAG
)
sys_trx_end
=
new_field
;
}
if
(
type
==
Item
::
SUM_FUNC_ITEM
)
...
...
sql/sql_type.cc
View file @
73f655d5
...
...
@@ -32,6 +32,7 @@ Type_handler_long type_handler_long;
Type_handler_int24
type_handler_int24
;
Type_handler_longlong
type_handler_longlong
;
Type_handler_longlong
type_handler_ulonglong
;
// Only used for CAST() for now
Type_handler_vers_trx_id
type_handler_vers_trx_id
;
Type_handler_float
type_handler_float
;
Type_handler_double
type_handler_double
;
Type_handler_bit
type_handler_bit
;
...
...
@@ -2065,6 +2066,19 @@ Field *Type_handler_longlong::make_table_field(const LEX_CSTRING *name,
}
Field
*
Type_handler_vers_trx_id
::
make_table_field
(
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE
*
table
)
const
{
return
new
(
table
->
in_use
->
mem_root
)
Field_vers_trx_id
(
addr
.
ptr
,
attr
.
max_char_length
(),
addr
.
null_ptr
,
addr
.
null_bit
,
Field
::
NONE
,
name
,
0
/*zerofill*/
,
attr
.
unsigned_flag
);
}
Field
*
Type_handler_float
::
make_table_field
(
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
...
...
sql/sql_type.h
View file @
73f655d5
...
...
@@ -1875,6 +1875,17 @@ class Type_handler_longlong: public Type_handler_general_purpose_int
};
class
Type_handler_vers_trx_id
:
public
Type_handler_longlong
{
public:
virtual
~
Type_handler_vers_trx_id
()
{}
Field
*
make_table_field
(
const
LEX_CSTRING
*
name
,
const
Record_addr
&
addr
,
const
Type_all_attributes
&
attr
,
TABLE
*
table
)
const
;
};
class
Type_handler_int24
:
public
Type_handler_general_purpose_int
{
static
const
Name
m_name_mediumint
;
...
...
@@ -2905,6 +2916,7 @@ extern MYSQL_PLUGIN_IMPORT Type_handler_int24 type_handler_int24;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_long
type_handler_long
;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_longlong
type_handler_longlong
;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_longlong
type_handler_ulonglong
;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_vers_trx_id
type_handler_vers_trx_id
;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_newdecimal
type_handler_newdecimal
;
extern
MYSQL_PLUGIN_IMPORT
Type_handler_olddecimal
type_handler_olddecimal
;
...
...
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