summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/versioning/r/create.result37
-rw-r--r--mysql-test/suite/versioning/t/create.test4
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/sql_insert.cc7
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_table.cc3
6 files changed, 25 insertions, 30 deletions
diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result
index 5e68d4df2e8..c9d68f15e57 100644
--- a/mysql-test/suite/versioning/r/create.result
+++ b/mysql-test/suite/versioning/r/create.result
@@ -1,4 +1,3 @@
-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`)
diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test
index 6f5153b4ec1..46ed8fad4cb 100644
--- a/mysql-test/suite/versioning/t/create.test
+++ b/mysql-test/suite/versioning/t/create.test
@@ -1,10 +1,6 @@
--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 ''
diff --git a/sql/handler.cc b/sql/handler.cc
index ce52df005da..4a8b58951d3 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -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 | NOT_NULL_FLAG;
if (integer)
{
DBUG_ASSERT(0); // Not implemented yet
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index c850bdbe34f..1e5d64885c1 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -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;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 2c91b4cc9c6..215bd4ab085 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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 | NOT_NULL_FLAG);
DBUG_ASSERT(p);
*p= last_field->field_name;
return false;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 5a35baddf93..ad58dd620d9 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3793,7 +3793,8 @@ without_overlaps_err:
}
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);