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
1f784008
Commit
1f784008
authored
Oct 20, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-29833 CREATE ... SELECT system_versioned_table causes invalid defaults
ROW START/END fields shold have no default value
parent
768a10d0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
30 deletions
+25
-30
mysql-test/suite/versioning/r/create.result
mysql-test/suite/versioning/r/create.result
+18
-19
mysql-test/suite/versioning/t/create.test
mysql-test/suite/versioning/t/create.test
+0
-4
sql/handler.cc
sql/handler.cc
+1
-1
sql/sql_insert.cc
sql/sql_insert.cc
+3
-4
sql/sql_lex.cc
sql/sql_lex.cc
+1
-1
sql/sql_table.cc
sql/sql_table.cc
+2
-1
No files found.
mysql-test/suite/versioning/r/create.result
View file @
1f784008
drop table if exists t1;
create table t1 (
x1 int unsigned,
Sys_start SYS_DATATYPE as row start invisible comment 'start',
...
...
@@ -266,8 +265,8 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`en` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`st` timestamp(6) NOT NULL,
`en` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
## For versioned table
insert into t1 values (1);
...
...
@@ -296,8 +295,8 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`en` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`st` timestamp(6) NOT NULL,
`en` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
select * from t3 where y > 2;
y st en
...
...
@@ -385,8 +384,8 @@ show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x25` int(11) DEFAULT NULL,
`row_start` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`row_end` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`row_start` timestamp(6) NOT NULL,
`row_end` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create or replace table t2 with system versioning
as select x25, row_start rs, row_end re from t1;
...
...
@@ -394,8 +393,8 @@ show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x25` int(11) DEFAULT NULL,
`rs` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`re` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`rs` timestamp(6) NOT NULL,
`re` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
create or replace table t1 (
x26 int,
...
...
@@ -409,8 +408,8 @@ show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x26` int(11) DEFAULT NULL,
`st` bigint(20) unsigned NOT NULL
DEFAULT 0
,
`en` bigint(20) unsigned NOT NULL
DEFAULT 0
`st` bigint(20) unsigned NOT NULL,
`en` bigint(20) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
create or replace table t1 (x27 int, id int) with system versioning engine NON_DEFAULT_ENGINE;
create or replace table t2 (b int, id int);
...
...
@@ -421,8 +420,8 @@ Table Create Table
t3 CREATE TABLE `t3` (
`b` int(11) DEFAULT NULL,
`x27` int(11) DEFAULT NULL,
`rs` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`re` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`rs` timestamp(6) NOT NULL,
`re` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
## Errors
create or replace temporary table t (x28 int) with system versioning;
...
...
@@ -458,10 +457,10 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`row_start` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`row_end` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`st` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`en` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
`row_start` timestamp(6) NOT NULL,
`row_end` timestamp(6) NOT NULL,
`st` timestamp(6) NOT NULL,
`en` timestamp(6) NOT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create or replace table t3 (
y int,
...
...
@@ -475,8 +474,8 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`row_start` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`row_end` timestamp(6) NOT NULL
DEFAULT '0000-00-00 00:00:00.000000'
,
`row_start` timestamp(6) NOT NULL,
`row_end` timestamp(6) NOT NULL,
`st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`st`, `en`)
...
...
mysql-test/suite/versioning/t/create.test
View file @
1f784008
--
source
suite
/
versioning
/
engines
.
inc
--
source
suite
/
versioning
/
common
.
inc
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
--
enable_prepare_warnings
--
replace_result
$default_engine
DEFAULT_ENGINE
$sys_datatype_expl
SYS_DATATYPE
NULL
''
...
...
sql/handler.cc
View file @
1f784008
...
...
@@ -8084,7 +8084,7 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f
f
->
field_name
.
str
=
field_name
;
f
->
field_name
.
length
=
strlen
(
field_name
);
f
->
charset
=
system_charset_info
;
f
->
flags
=
flags
|
NOT_NULL_FLAG
;
f
->
flags
=
flags
|
NO
_DEFAULT_VALUE_FLAG
|
NO
T_NULL_FLAG
;
if
(
integer
)
{
DBUG_ASSERT
(
0
);
// Not implemented yet
...
...
sql/sql_insert.cc
View file @
1f784008
...
...
@@ -320,7 +320,8 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
static
bool
has_no_default_value
(
THD
*
thd
,
Field
*
field
,
TABLE_LIST
*
table_list
)
{
if
((
field
->
flags
&
NO_DEFAULT_VALUE_FLAG
)
&&
field
->
real_type
()
!=
MYSQL_TYPE_ENUM
)
if
((
field
->
flags
&
(
NO_DEFAULT_VALUE_FLAG
|
VERS_ROW_START
|
VERS_ROW_END
))
==
NO_DEFAULT_VALUE_FLAG
&&
field
->
real_type
()
!=
MYSQL_TYPE_ENUM
)
{
bool
view
=
false
;
if
(
table_list
)
...
...
@@ -2257,9 +2258,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry, TABLE_LIST *t
for
(
Field
**
field
=
entry
->
field
;
*
field
;
field
++
)
{
if
(
!
bitmap_is_set
(
write_set
,
(
*
field
)
->
field_index
)
&&
!
(
*
field
)
->
vers_sys_field
()
&&
has_no_default_value
(
thd
,
*
field
,
table_list
)
&&
((
*
field
)
->
real_type
()
!=
MYSQL_TYPE_ENUM
))
has_no_default_value
(
thd
,
*
field
,
table_list
))
err
=
1
;
}
return
thd
->
abort_on_warning
?
err
:
0
;
...
...
sql/sql_lex.cc
View file @
1f784008
...
...
@@ -9810,7 +9810,7 @@ bool LEX::last_field_generated_always_as_row_start_or_end(Lex_ident *p,
last_field
->
field_name
.
str
);
return
true
;
}
last_field
->
flags
|=
(
flag
|
NOT_NULL_FLAG
);
last_field
->
flags
|=
(
flag
|
NO
_DEFAULT_VALUE_FLAG
|
NO
T_NULL_FLAG
);
DBUG_ASSERT
(
p
);
*
p
=
last_field
->
field_name
;
return
false
;
...
...
sql/sql_table.cc
View file @
1f784008
...
...
@@ -3793,7 +3793,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
if
(
sql_field
->
invisible
==
INVISIBLE_USER
&&
sql_field
->
flags
&
NOT_NULL_FLAG
&&
sql_field
->
flags
&
NO_DEFAULT_VALUE_FLAG
)
sql_field
->
flags
&
NO_DEFAULT_VALUE_FLAG
&&
!
sql_field
->
vers_sys_field
())
{
my_error
(
ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT
,
MYF
(
0
),
sql_field
->
field_name
.
str
);
...
...
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