Commit 8bd5d724 authored by unknown's avatar unknown

Fix for bug #22377: iNCONSISTENCY WITH null

Backport. See #20910: NOT NULL column reported as NULL in SHOW FIELDS or INFORMATION_SCHEMA


mysql-test/r/type_ranges.result:
  Fix for bug #22377: iNCONSISTENCY WITH null
    - results adjusted.
mysql-test/r/type_timestamp.result:
  Fix for bug #22377: iNCONSISTENCY WITH null
    - results adjusted.
sql/sql_show.cc:
  Fix for bug #22377: iNCONSISTENCY WITH null
    - as NULL values cannot be stored in 'timestamp not null' fields,
      don't make an exception for them.
parent 5113f600
...@@ -54,7 +54,7 @@ ushort smallint(5) unsigned zerofill NULL MUL 00000 # ...@@ -54,7 +54,7 @@ ushort smallint(5) unsigned zerofill NULL MUL 00000 #
umedium mediumint(8) unsigned NULL MUL 0 # umedium mediumint(8) unsigned NULL MUL 0 #
ulong int(11) unsigned NULL MUL 0 # ulong int(11) unsigned NULL MUL 0 #
ulonglong bigint(13) unsigned NULL MUL 0 # ulonglong bigint(13) unsigned NULL MUL 0 #
time_stamp timestamp NULL YES CURRENT_TIMESTAMP # time_stamp timestamp NULL CURRENT_TIMESTAMP #
date_field date NULL YES NULL # date_field date NULL YES NULL #
time_field time NULL YES NULL # time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
...@@ -222,7 +222,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 # ...@@ -222,7 +222,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 #
umedium mediumint(8) unsigned NULL MUL 0 # umedium mediumint(8) unsigned NULL MUL 0 #
ulong int(11) unsigned NULL MUL 0 # ulong int(11) unsigned NULL MUL 0 #
ulonglong bigint(13) unsigned NULL MUL 0 # ulonglong bigint(13) unsigned NULL MUL 0 #
time_stamp timestamp NULL YES CURRENT_TIMESTAMP # time_stamp timestamp NULL CURRENT_TIMESTAMP #
date_field varchar(10) latin1_swedish_ci YES NULL # date_field varchar(10) latin1_swedish_ci YES NULL #
time_field time NULL YES NULL # time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
...@@ -248,7 +248,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 # ...@@ -248,7 +248,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 #
umedium mediumint(8) unsigned NULL 0 # umedium mediumint(8) unsigned NULL 0 #
ulong int(11) unsigned NULL 0 # ulong int(11) unsigned NULL 0 #
ulonglong bigint(13) unsigned NULL 0 # ulonglong bigint(13) unsigned NULL 0 #
time_stamp timestamp NULL YES 0000-00-00 00:00:00 # time_stamp timestamp NULL 0000-00-00 00:00:00 #
date_field varchar(10) latin1_swedish_ci YES NULL # date_field varchar(10) latin1_swedish_ci YES NULL #
time_field time NULL YES NULL # time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
......
...@@ -188,9 +188,9 @@ t1 CREATE TABLE `t1` ( ...@@ -188,9 +188,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES 2003-01-01 00:00:00 t1 timestamp 2003-01-01 00:00:00
t2 datetime YES NULL t2 datetime YES NULL
t3 timestamp YES 0000-00-00 00:00:00 t3 timestamp 0000-00-00 00:00:00
drop table t1; drop table t1;
create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp); create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000002; SET TIMESTAMP=1000000002;
...@@ -212,9 +212,9 @@ t1 CREATE TABLE `t1` ( ...@@ -212,9 +212,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES CURRENT_TIMESTAMP t1 timestamp CURRENT_TIMESTAMP
t2 datetime YES NULL t2 datetime YES NULL
t3 timestamp YES 0000-00-00 00:00:00 t3 timestamp 0000-00-00 00:00:00
drop table t1; drop table t1;
create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime); create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime);
SET TIMESTAMP=1000000004; SET TIMESTAMP=1000000004;
...@@ -238,7 +238,7 @@ t1 CREATE TABLE `t1` ( ...@@ -238,7 +238,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES 2003-01-01 00:00:00 t1 timestamp 2003-01-01 00:00:00
t2 datetime YES NULL t2 datetime YES NULL
drop table t1; drop table t1;
create table t1 (t1 timestamp default now() on update now(), t2 datetime); create table t1 (t1 timestamp default now() on update now(), t2 datetime);
...@@ -263,7 +263,7 @@ t1 CREATE TABLE `t1` ( ...@@ -263,7 +263,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES CURRENT_TIMESTAMP t1 timestamp CURRENT_TIMESTAMP
t2 datetime YES NULL t2 datetime YES NULL
drop table t1; drop table t1;
create table t1 (t1 timestamp, t2 datetime, t3 timestamp); create table t1 (t1 timestamp, t2 datetime, t3 timestamp);
...@@ -289,9 +289,9 @@ t1 CREATE TABLE `t1` ( ...@@ -289,9 +289,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES CURRENT_TIMESTAMP t1 timestamp CURRENT_TIMESTAMP
t2 datetime YES NULL t2 datetime YES NULL
t3 timestamp YES 0000-00-00 00:00:00 t3 timestamp 0000-00-00 00:00:00
drop table t1; drop table t1;
create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime); create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime);
SET TIMESTAMP=1000000009; SET TIMESTAMP=1000000009;
...@@ -315,7 +315,7 @@ t1 CREATE TABLE `t1` ( ...@@ -315,7 +315,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
t1 timestamp YES CURRENT_TIMESTAMP t1 timestamp CURRENT_TIMESTAMP
t2 datetime YES NULL t2 datetime YES NULL
delete from t1; delete from t1;
insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00');
......
...@@ -714,16 +714,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, ...@@ -714,16 +714,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
if (verbose) if (verbose)
protocol->store(field->has_charset() ? field->charset()->name : "NULL", protocol->store(field->has_charset() ? field->charset()->name : "NULL",
system_charset_info); system_charset_info);
/* pos= (byte*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
Even if TIMESTAMP field can't contain NULL as its value it
will accept NULL if you will try to insert such value and will
convert NULL value to current TIMESTAMP. So YES here means
that NULL is allowed for assignment (but may be won't be
returned).
*/
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
field->type() != FIELD_TYPE_TIMESTAMP ?
"" : "YES");
protocol->store((const char*) pos, system_charset_info); protocol->store((const char*) pos, system_charset_info);
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment