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
0d83bdf2
Commit
0d83bdf2
authored
Oct 04, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/dlenev/src/mysql-4.1-ryan
parents
e1077781
a4d5804e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
18 deletions
+47
-18
mysql-test/r/type_timestamp.result
mysql-test/r/type_timestamp.result
+17
-2
mysql-test/t/type_timestamp.test
mysql-test/t/type_timestamp.test
+13
-2
sql/sql_parse.cc
sql/sql_parse.cc
+17
-14
No files found.
mysql-test/r/type_timestamp.result
View file @
0d83bdf2
...
@@ -369,7 +369,7 @@ create table t1 (a timestamp null, b timestamp null);
...
@@ -369,7 +369,7 @@ create table t1 (a timestamp null, b timestamp null);
show create table t1;
show create table t1;
Table Create Table
Table Create Table
t1 CREATE TABLE `t1` (
t1 CREATE TABLE `t1` (
`a` timestamp NULL default
CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
,
`a` timestamp NULL default
NULL
,
`b` timestamp NULL default NULL
`b` timestamp NULL default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (NULL, NULL);
insert into t1 values (NULL, NULL);
...
@@ -378,7 +378,22 @@ insert into t1 values ();
...
@@ -378,7 +378,22 @@ insert into t1 values ();
select * from t1;
select * from t1;
a b
a b
NULL NULL
NULL NULL
2001-09-09 04:46:57 NULL
NULL NULL
drop table t1;
create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`b` timestamp NULL default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (NULL, NULL);
SET TIMESTAMP=1000000018;
insert into t1 values ();
select * from t1;
a b
NULL NULL
2001-09-09 04:46:58 NULL
drop table t1;
drop table t1;
create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00');
create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00');
show create table t1;
show create table t1;
...
...
mysql-test/t/type_timestamp.test
View file @
0d83bdf2
...
@@ -236,9 +236,10 @@ drop table t1;
...
@@ -236,9 +236,10 @@ drop table t1;
#
#
# Test for TIMESTAMP columns which are able to store NULLs
# Test for TIMESTAMP columns which are able to store NULLs
# (Auto-set property should work for them and NULL values
# should be OK as default values)
#
#
# Unlike for default TIMESTAMP fields we don't interpret first field
# in this table as TIMESTAMP with DEFAULT NOW() ON UPDATE NOW() properties.
create
table
t1
(
a
timestamp
null
,
b
timestamp
null
);
create
table
t1
(
a
timestamp
null
,
b
timestamp
null
);
show
create
table
t1
;
show
create
table
t1
;
insert
into
t1
values
(
NULL
,
NULL
);
insert
into
t1
values
(
NULL
,
NULL
);
...
@@ -247,6 +248,16 @@ insert into t1 values ();
...
@@ -247,6 +248,16 @@ insert into t1 values ();
select
*
from
t1
;
select
*
from
t1
;
drop
table
t1
;
drop
table
t1
;
# But explicit auto-set properties still should be OK.
create
table
t1
(
a
timestamp
null
default
current_timestamp
on
update
current_timestamp
,
b
timestamp
null
);
show
create
table
t1
;
insert
into
t1
values
(
NULL
,
NULL
);
SET
TIMESTAMP
=
1000000018
;
insert
into
t1
values
();
select
*
from
t1
;
drop
table
t1
;
# It is also OK to specify NULL as default explicitly for such fields.
create
table
t1
(
a
timestamp
null
default
null
,
b
timestamp
null
default
'2003-01-01 00:00:00'
);
create
table
t1
(
a
timestamp
null
default
null
,
b
timestamp
null
default
'2003-01-01 00:00:00'
);
show
create
table
t1
;
show
create
table
t1
;
insert
into
t1
values
(
NULL
,
NULL
);
insert
into
t1
values
(
NULL
,
NULL
);
...
...
sql/sql_parse.cc
View file @
0d83bdf2
...
@@ -4142,12 +4142,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
...
@@ -4142,12 +4142,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
}
}
else
if
(
default_value
->
type
()
==
Item
::
NULL_ITEM
)
else
if
(
default_value
->
type
()
==
Item
::
NULL_ITEM
)
{
{
/*
default_value
=
0
;
TIMESTAMP type should be able to distingush non-specified default
value and default value NULL later.
*/
if
(
type
!=
FIELD_TYPE_TIMESTAMP
)
default_value
=
0
;
if
((
type_modifier
&
(
NOT_NULL_FLAG
|
AUTO_INCREMENT_FLAG
))
==
if
((
type_modifier
&
(
NOT_NULL_FLAG
|
AUTO_INCREMENT_FLAG
))
==
NOT_NULL_FLAG
)
NOT_NULL_FLAG
)
{
{
...
@@ -4357,19 +4352,27 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
...
@@ -4357,19 +4352,27 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
else
else
new_field
->
unireg_check
=
(
on_update_value
?
Field
::
TIMESTAMP_UN_FIELD
:
new_field
->
unireg_check
=
(
on_update_value
?
Field
::
TIMESTAMP_UN_FIELD
:
Field
::
NONE
);
Field
::
NONE
);
if
(
default_value
->
type
()
==
Item
::
NULL_ITEM
)
new_field
->
def
=
0
;
}
}
else
else
{
{
/*
/*
We are setting TIMESTAMP_OLD_FIELD here only temporary, we will
If we have default TIMESTAMP NOT NULL column without explicit DEFAULT
replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
or ON UPDATE values then for the sake of compatiblity we should treat
this column as having DEFAULT NOW() ON UPDATE NOW() (when we don't
have another TIMESTAMP column with auto-set option before this one)
or DEFAULT 0 (in other cases).
So here we are setting TIMESTAMP_OLD_FIELD only temporary, and will
replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
information about all TIMESTAMP fields in table will be availiable.
information about all TIMESTAMP fields in table will be availiable.
If we have TIMESTAMP NULL column without explicit DEFAULT value
we treat it as having DEFAULT NULL attribute.
*/
*/
new_field
->
unireg_check
=
on_update_value
?
Field
::
TIMESTAMP_UN_FIELD
:
new_field
->
unireg_check
=
on_update_value
?
Field
::
TIMESTAMP_OLD_FIELD
;
Field
::
TIMESTAMP_UN_FIELD
:
(
new_field
->
flags
&
NOT_NULL_FLAG
?
Field
::
TIMESTAMP_OLD_FIELD
:
Field
::
NONE
);
}
}
break
;
break
;
case
FIELD_TYPE_DATE
:
// Old date type
case
FIELD_TYPE_DATE
:
// Old date type
...
...
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