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
0581c018
Commit
0581c018
authored
Nov 07, 2016
by
Kosov Eugene
Committed by
Aleksey Midenkov
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL: NULL instead of optimized fields in versioned queries
parent
19641ce8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
1 deletion
+115
-1
mysql-test/suite/versioning/r/optimized_fields.result
mysql-test/suite/versioning/r/optimized_fields.result
+68
-0
mysql-test/suite/versioning/t/optimized_fields.test
mysql-test/suite/versioning/t/optimized_fields.test
+22
-0
sql/field.cc
sql/field.cc
+1
-1
sql/field.h
sql/field.h
+4
-0
sql/item.cc
sql/item.cc
+17
-0
sql/share/errmsg-utf8.txt
sql/share/errmsg-utf8.txt
+3
-0
No files found.
mysql-test/suite/versioning/r/optimized_fields.result
0 → 100644
View file @
0581c018
create table t(
a int,
b int without system versioning
) with system versioning;
insert into t values(1, 2);
insert into t values(3, 4);
select * from t;
a b
1 2
3 4
select a from t for system_time as of timestamp now(6);
a
1
3
select a, b, b+0 from t for system_time as of timestamp now(6);
a b b+0
1 NULL NULL
3 NULL NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6);
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select count(*) from t group by b for system_time as of timestamp now(6);
count(*)
2
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6) order by b asc;
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select * from t for system_time as of timestamp now(6) order by b desc;
a b
1 NULL
3 NULL
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select * from t group by a having a=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select * from t group by b having b=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select a from t where b=2 for system_time as of timestamp now(6);
a
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select a from t where b=NULL for system_time as of timestamp now(6);
a
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
count(*) b
Warnings:
Warning 4050 Attempt to read unversioned field 'b' in historical query
select a, b from t;
a b
1 2
3 4
drop table t;
mysql-test/suite/versioning/t/optimized_fields.test
0 → 100644
View file @
0581c018
create
table
t
(
a
int
,
b
int
without
system
versioning
)
with
system
versioning
;
insert
into
t
values
(
1
,
2
);
insert
into
t
values
(
3
,
4
);
select
*
from
t
;
select
a
from
t
for
system_time
as
of
timestamp
now
(
6
);
select
a
,
b
,
b
+
0
from
t
for
system_time
as
of
timestamp
now
(
6
);
select
*
from
t
for
system_time
as
of
timestamp
now
(
6
);
select
count
(
*
)
from
t
group
by
b
for
system_time
as
of
timestamp
now
(
6
);
select
*
from
t
for
system_time
as
of
timestamp
now
(
6
)
order
by
b
asc
;
select
*
from
t
for
system_time
as
of
timestamp
now
(
6
)
order
by
b
desc
;
select
*
from
t
group
by
a
having
a
=
2
for
system_time
as
of
timestamp
now
(
6
);
select
*
from
t
group
by
b
having
b
=
2
for
system_time
as
of
timestamp
now
(
6
);
select
a
from
t
where
b
=
2
for
system_time
as
of
timestamp
now
(
6
);
select
a
from
t
where
b
=
NULL
for
system_time
as
of
timestamp
now
(
6
);
select
count
(
*
),
b
from
t
group
by
b
having
b
=
NULL
for
system_time
as
of
timestamp
now
(
6
);
select
a
,
b
from
t
;
drop
table
t
;
sql/field.cc
View file @
0581c018
...
...
@@ -1631,7 +1631,7 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
:
ptr
(
ptr_arg
),
null_ptr
(
null_ptr_arg
),
table
(
0
),
orig_table
(
0
),
table_name
(
0
),
field_name
(
field_name_arg
),
option_list
(
0
),
option_struct
(
0
),
key_start
(
0
),
part_of_key
(
0
),
part_of_key_not_clustered
(
0
),
part_of_sortkey
(
0
),
part_of_key_not_clustered
(
0
),
force_null
(
false
),
part_of_sortkey
(
0
),
unireg_check
(
unireg_check_arg
),
field_length
(
length_arg
),
null_bit
(
null_bit_arg
),
is_created_from_null_item
(
FALSE
),
read_stats
(
NULL
),
collected_stats
(
0
),
vcol_info
(
0
),
check_constraint
(
0
),
...
...
sql/field.h
View file @
0581c018
...
...
@@ -707,6 +707,8 @@ class Field: public Value_source
/* Field is part of the following keys */
key_map
key_start
,
part_of_key
,
part_of_key_not_clustered
;
bool
force_null
;
/*
Bitmap of indexes that have records ordered by col1, ... this_field, ...
...
...
@@ -1089,6 +1091,8 @@ class Field: public Value_source
virtual
uint
size_of
()
const
=
0
;
// For new field
inline
bool
is_null
(
my_ptrdiff_t
row_offset
=
0
)
const
{
if
(
force_null
)
return
true
;
/*
The table may have been marked as containing only NULL values
for all fields if it is a NULL-complemented row of an OUTER JOIN
...
...
sql/item.cc
View file @
0581c018
...
...
@@ -2759,6 +2759,21 @@ void Item_field::set_field(Field *field_par)
fixed
=
1
;
if
(
field
->
table
->
s
->
tmp_table
==
SYSTEM_TMP_TABLE
)
any_privileges
=
0
;
if
(
field
->
is_versioning_disabled
()
&&
context
&&
context
->
select_lex
&&
context
->
select_lex
->
vers_conditions
.
type
!=
FOR_SYSTEM_TIME_UNSPECIFIED
&&
!
field
->
force_null
)
{
DBUG_ASSERT
(
context
->
select_lex
->
parent_lex
&&
context
->
select_lex
->
parent_lex
->
thd
);
field
->
force_null
=
true
;
THD
*
thd
=
context
->
select_lex
->
parent_lex
->
thd
;
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_NON_VERSIONED_FIELD_IN_VERSIONED_QUERY
,
ER_THD
(
thd
,
ER_NON_VERSIONED_FIELD_IN_VERSIONED_QUERY
),
field_name
);
}
}
...
...
@@ -5907,6 +5922,8 @@ void Item_field::cleanup()
it will be linked correctly next time by name of field and table alias.
I.e. we can drop 'field'.
*/
if
(
field
)
field
->
force_null
=
false
;
field
=
0
;
item_equal
=
NULL
;
null_value
=
FALSE
;
...
...
sql/share/errmsg-utf8.txt
View file @
0581c018
...
...
@@ -7543,3 +7543,6 @@ ER_VERS_TRX_ID_UNSUPPORTED
ER_VERS_RANGE_UNITS_MISMATCH
eng "Range units mismatch"
ER_NON_VERSIONED_FIELD_IN_VERSIONED_QUERY
eng "Attempt to read unversioned field '%s' in historical query"
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