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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
eb218f3c
Commit
eb218f3c
authored
Jan 30, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/dlenev/src/mysql-4.0-bg2464
parents
31ad5e49
e3816cb4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
16 deletions
+98
-16
mysql-test/r/type_timestamp.result
mysql-test/r/type_timestamp.result
+45
-2
mysql-test/t/type_timestamp.test
mysql-test/t/type_timestamp.test
+30
-3
sql/field.cc
sql/field.cc
+1
-2
sql/field.h
sql/field.h
+4
-1
sql/sql_parse.cc
sql/sql_parse.cc
+6
-6
sql/sql_show.cc
sql/sql_show.cc
+12
-2
No files found.
mysql-test/r/type_timestamp.result
View file @
eb218f3c
...
...
@@ -122,5 +122,48 @@ t2 t4 t6 t8 t10 t12 t14
0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
drop table t1;
create table t1 (a timestamp default 1);
Invalid default value for 'a'
create table t1 (t1 timestamp default '2003-01-01 00:00:00',
t2 timestamp default '2003-01-01 00:00:00');
set TIMESTAMP=1000000000;
insert into t1 values();
select * from t1;
t1 t2
2001-09-09 04:46:40 2003-01-01 00:00:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1` timestamp(14) NOT NULL,
`t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00'
) TYPE=MyISAM
show columns from t1;
Field Type Null Key Default Extra
t1 timestamp(14) YES NULL
t2 timestamp(14) YES 2003-01-01 00:00:00
show columns from t1 like 't2';
Field Type Null Key Default Extra
t2 timestamp(14) YES 2003-01-01 00:00:00
create table t2 (select * from t1);
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`t1` timestamp(14) NOT NULL,
`t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00'
) TYPE=MyISAM
alter table t1 add column t0 timestamp first;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t0` timestamp(14) NOT NULL,
`t1` timestamp(14) NOT NULL default '2003-01-01 00:00:00',
`t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00'
) TYPE=MyISAM
drop table t1,t2;
create table t1 (ts1 timestamp, ts2 timestamp);
set TIMESTAMP=1000000000;
insert into t1 values ();
insert into t1 values (DEFAULT, DEFAULT);
select * from t1;
ts1 ts2
2001-09-09 04:46:40 0000-00-00 00:00:00
2001-09-09 04:46:40 0000-00-00 00:00:00
drop table t1;
mysql-test/t/type_timestamp.test
View file @
eb218f3c
...
...
@@ -73,8 +73,35 @@ select * from t1;
drop
table
t1
;
#
# Bug #1885
# Bug #1885, bug #2539.
# Not perfect but still sensible attitude towards defaults for TIMESTAMP
# We will ignore default value for first TIMESTAMP column.
#
create
table
t1
(
t1
timestamp
default
'2003-01-01 00:00:00'
,
t2
timestamp
default
'2003-01-01 00:00:00'
);
set
TIMESTAMP
=
1000000000
;
insert
into
t1
values
();
select
*
from
t1
;
show
create
table
t1
;
show
columns
from
t1
;
show
columns
from
t1
like
't2'
;
create
table
t2
(
select
*
from
t1
);
show
create
table
t2
;
# Ugly, but we can't do anything about this in 4.0
alter
table
t1
add
column
t0
timestamp
first
;
show
create
table
t1
;
--
error
1067
create
table
t1
(
a
timestamp
default
1
);
drop
table
t1
,
t2
;
#
# Test for bug 2464, DEFAULT keyword in INSERT statement should return
# default value for column.
#
create
table
t1
(
ts1
timestamp
,
ts2
timestamp
);
set
TIMESTAMP
=
1000000000
;
insert
into
t1
values
();
insert
into
t1
values
(
DEFAULT
,
DEFAULT
);
select
*
from
t1
;
drop
table
t1
;
sql/field.cc
View file @
eb218f3c
...
...
@@ -5124,8 +5124,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
interval
=
0
;
def
=
0
;
if
(
!
old_field
->
is_real_null
()
&&
!
(
flags
&
BLOB_FLAG
)
&&
old_field
->
type
()
!=
FIELD_TYPE_TIMESTAMP
&&
old_field
->
ptr
&&
orig_field
)
old_field
->
ptr
&&
orig_field
)
{
char
buff
[
MAX_FIELD_WIDTH
],
*
pos
;
String
tmp
(
buff
,
sizeof
(
buff
));
...
...
sql/field.h
View file @
eb218f3c
...
...
@@ -564,7 +564,10 @@ public:
void
set_time
();
virtual
void
set_default
()
{
if
(
table
->
timestamp_field
==
this
)
set_time
();
else
Field
::
set_default
();
}
inline
long
get_timestamp
()
{
...
...
sql/sql_parse.cc
View file @
eb218f3c
...
...
@@ -3058,12 +3058,12 @@ bool add_field_to_list(char *field_name, enum_field_types type,
if
(
default_value
)
{
if
(
type
==
FIELD_TYPE_TIMESTAMP
)
{
net_printf
(
&
thd
->
net
,
ER_INVALID_DEFAULT
,
field_name
);
DBUG_RETURN
(
1
);
}
else
if
(
default_value
->
type
()
==
Item
::
NULL_ITEM
)
/*
We allow specifying value for first TIMESTAMP column
altough it is silently ignored. This should be fixed in 4.1
(by proper warning or real support for default values)
*/
if
(
default_value
->
type
()
==
Item
::
NULL_ITEM
)
{
default_value
=
0
;
if
((
type_modifier
&
(
NOT_NULL_FLAG
|
AUTO_INCREMENT_FLAG
))
==
...
...
sql/sql_show.cc
View file @
eb218f3c
...
...
@@ -508,6 +508,12 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
field
->
sql_type
(
type
);
net_store_data
(
packet
,
convert
,
type
.
ptr
(),
type
.
length
());
/*
Altough TIMESTAMP fields can't contain NULL as its value they
will accept NULL if you will try to insert such value and will
convert it to current TIMESTAMP. So YES here means that NULL
is allowed for assignment but can't be returned.
*/
pos
=
(
byte
*
)
((
flags
&
NOT_NULL_FLAG
)
&&
field
->
type
()
!=
FIELD_TYPE_TIMESTAMP
?
""
:
"YES"
);
...
...
@@ -517,7 +523,11 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
(
field
->
flags
&
MULTIPLE_KEY_FLAG
)
?
"MUL"
:
""
);
net_store_data
(
packet
,
convert
,(
char
*
)
pos
);
if
(
field
->
type
()
==
FIELD_TYPE_TIMESTAMP
||
/*
We handle first TIMESTAMP column in special way because its
default value is ignored and current timestamp used instead.
*/
if
(
table
->
timestamp_field
==
field
||
field
->
unireg_check
==
Field
::
NEXT_NUMBER
)
null_default_value
=
1
;
if
(
!
null_default_value
&&
!
field
->
is_null
())
...
...
@@ -888,7 +898,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet
->
append
(
type
.
ptr
(),
type
.
length
());
has_default
=
(
field
->
type
()
!=
FIELD_TYPE_BLOB
&&
field
->
type
()
!=
FIELD_TYPE_TIMESTAMP
&&
table
->
timestamp_field
!=
field
&&
field
->
unireg_check
!=
Field
::
NEXT_NUMBER
);
if
(
flags
&
NOT_NULL_FLAG
)
packet
->
append
(
" NOT NULL"
,
9
);
...
...
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