Commit 8a4a21e2 authored by unknown's avatar unknown

Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0

into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-build
parents 21f2b3cd bf3d46a8
...@@ -54,7 +54,7 @@ SHOW FULL COLUMNS FROM t1; ...@@ -54,7 +54,7 @@ SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
GROUP_ID int(10) unsigned NULL NO PRI 0 # GROUP_ID int(10) unsigned NULL NO PRI 0 #
LANG_ID smallint(5) unsigned NULL NO PRI 0 # LANG_ID smallint(5) unsigned NULL NO PRI 0 #
NAME char(80) latin1_swedish_ci NO MUL # NAME char(80) latin1_swedish_ci NO MUL NULL #
DROP TABLE t1; DROP TABLE t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values(9),(3),(12),(10); insert into t1 values(9),(3),(12),(10);
......
...@@ -430,7 +430,7 @@ d date YES NULL ...@@ -430,7 +430,7 @@ d date YES NULL
e varchar(1) NO e varchar(1) NO
f datetime YES NULL f datetime YES NULL
g time YES NULL g time YES NULL
h longblob NO h longblob NO NULL
dd time YES NULL dd time YES NULL
select * from t2; select * from t2;
a b c d e f g h dd a b c d e f g h dd
......
...@@ -488,7 +488,7 @@ t1 CREATE TABLE `t1` ( ...@@ -488,7 +488,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW FIELDS FROM t1; SHOW FIELDS FROM t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
latin1_f char(32) NO latin1_f char(32) NO NULL
ALTER TABLE t1 CHANGE latin1_f ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
......
...@@ -54,7 +54,7 @@ Table Create Table ...@@ -54,7 +54,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' ' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
Field Type Null Key Default Extra Field Type Null Key Default Extra
char(32) NO char(32) NO NULL
SET CHARACTER SET cp1251; SET CHARACTER SET cp1251;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
...@@ -66,7 +66,7 @@ Table Create Table ...@@ -66,7 +66,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' ' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
Field Type Null Key Default Extra Field Type Null Key Default Extra
char(32) NO char(32) NO NULL
SET CHARACTER SET utf8; SET CHARACTER SET utf8;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
...@@ -78,7 +78,7 @@ Table Create Table ...@@ -78,7 +78,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы'
SHOW FIELDS FROM таблица; SHOW FIELDS FROM таблица;
Field Type Null Key Default Extra Field Type Null Key Default Extra
поле char(32) NO поле char(32) NO NULL
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
DROP TABLE ; DROP TABLE ;
SET CHARACTER SET default; SET CHARACTER SET default;
......
...@@ -115,7 +115,7 @@ Warning 1364 Field 'd' doesn't have a default value ...@@ -115,7 +115,7 @@ Warning 1364 Field 'd' doesn't have a default value
desc bug20691; desc bug20691;
Field Type Null Key Default Extra Field Type Null Key Default Extra
i int(11) YES NULL i int(11) YES NULL
d datetime NO d datetime NO NULL
dn datetime NO 0000-00-00 00:00:00 dn datetime NO 0000-00-00 00:00:00
insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT); insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
Warnings: Warnings:
......
...@@ -9,35 +9,35 @@ CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMET ...@@ -9,35 +9,35 @@ CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMET
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
SHOW FIELDS FROM gis_point; SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g point YES NULL g point YES NULL
SHOW FIELDS FROM gis_line; SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g linestring YES NULL g linestring YES NULL
SHOW FIELDS FROM gis_polygon; SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g polygon YES NULL g polygon YES NULL
SHOW FIELDS FROM gis_multi_point; SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g multipoint YES NULL g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line; SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g multilinestring YES NULL g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon; SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g multipolygon YES NULL g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection; SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g geometrycollection YES NULL g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry; SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra Field Type Null Key Default Extra
fid int(11) NO PRI fid int(11) NO PRI NULL
g geometry YES NULL g geometry YES NULL
INSERT INTO gis_point VALUES INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')), (101, PointFromText('POINT(10 10)')),
...@@ -430,7 +430,7 @@ mln multilinestring YES NULL ...@@ -430,7 +430,7 @@ mln multilinestring YES NULL
mpg multipolygon YES NULL mpg multipolygon YES NULL
gc geometrycollection YES NULL gc geometrycollection YES NULL
gm geometry YES NULL gm geometry YES NULL
fid int(11) NO fid int(11) NO NULL
DROP TABLE t1; DROP TABLE t1;
SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)')))); SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)')))) AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))
......
...@@ -989,7 +989,7 @@ b NULL ...@@ -989,7 +989,7 @@ b NULL
use test; use test;
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO a int(11) NO NULL
b int(11) YES NULL b int(11) YES NULL
drop table t1; drop table t1;
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
...@@ -1354,4 +1354,35 @@ where event_object_table='t1'; ...@@ -1354,4 +1354,35 @@ where event_object_table='t1';
trigger_name trigger_name
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
drop database mysqltest; drop database mysqltest;
create table t1 (
f1 varchar(50),
f2 varchar(50) not null,
f3 varchar(50) default '',
f4 varchar(50) default NULL,
f5 bigint not null,
f6 bigint not null default 10,
f7 datetime not null,
f8 datetime default '2006-01-01'
);
select column_default from information_schema.columns where table_name= 't1';
column_default
NULL
NULL
NULL
NULL
10
NULL
2006-01-01 00:00:00
show columns from t1;
Field Type Null Key Default Extra
f1 varchar(50) YES NULL
f2 varchar(50) NO NULL
f3 varchar(50) YES
f4 varchar(50) YES NULL
f5 bigint(20) NO NULL
f6 bigint(20) NO 10
f7 datetime NO NULL
f8 datetime YES 2006-01-01 00:00:00
drop table t1;
End of 5.0 tests. End of 5.0 tests.
...@@ -1114,4 +1114,101 @@ c b ...@@ -1114,4 +1114,101 @@ c b
3 1 3 1
3 2 3 2
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
a b
2 2
3 2
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
a b
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b ASC, a ASC;
a b
1 1
2 2
3 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b DESC, a DESC;
a b
3 2
2 2
1 1
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b ASC, a DESC;
a b
1 1
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b DESC, a ASC;
a b
2 2
3 2
1 1
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
...@@ -336,8 +336,8 @@ UNIQUE i1idx (i1), ...@@ -336,8 +336,8 @@ UNIQUE i1idx (i1),
UNIQUE i2idx (i2)); UNIQUE i2idx (i2));
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
i1 int(11) NO PRI i1 int(11) NO PRI NULL
i2 int(11) NO UNI i2 int(11) NO UNI NULL
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -392,27 +392,27 @@ drop table t1; ...@@ -392,27 +392,27 @@ drop table t1;
create table t1 (a int not null primary key, b varchar(20) not null unique); create table t1 (a int not null primary key, b varchar(20) not null unique);
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
b varchar(20) NO UNI b varchar(20) NO UNI NULL
drop table t1; drop table t1;
create table t1 (a int not null primary key, b int not null unique); create table t1 (a int not null primary key, b int not null unique);
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
b int(11) NO UNI b int(11) NO UNI NULL
drop table t1; drop table t1;
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10))); create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
b varchar(20) NO UNI b varchar(20) NO UNI NULL
drop table t1; drop table t1;
create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10))); create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10)));
desc t1; desc t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
b varchar(20) NO MUL b varchar(20) NO MUL NULL
c varchar(20) NO c varchar(20) NO NULL
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a INTEGER auto_increment PRIMARY KEY, a INTEGER auto_increment PRIMARY KEY,
......
...@@ -91,7 +91,7 @@ i j k ...@@ -91,7 +91,7 @@ i j k
NULL 1 NULL NULL 1 NULL
Field Type Null Key Default Extra Field Type Null Key Default Extra
i int(11) YES NULL i int(11) YES NULL
j int(11) NO j int(11) NO NULL
k int(11) YES NULL k int(11) YES NULL
+------+---+------+ +------+---+------+
| i | j | k | | i | j | k |
...@@ -102,7 +102,7 @@ k int(11) YES NULL ...@@ -102,7 +102,7 @@ k int(11) YES NULL
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+ +-------+---------+------+-----+---------+-------+
| i | int(11) | YES | | NULL | | | i | int(11) | YES | | NULL | |
| j | int(11) | NO | | | | | j | int(11) | NO | | NULL | |
| k | int(11) | YES | | NULL | | | k | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+ +-------+---------+------+-----+---------+-------+
i s1 i s1
......
...@@ -269,7 +269,7 @@ prepare stmt4 from ' show columns from t2 where field in (select ?) '; ...@@ -269,7 +269,7 @@ prepare stmt4 from ' show columns from t2 where field in (select ?) ';
SET @arg00="a"; SET @arg00="a";
execute stmt4 using @arg00; execute stmt4 using @arg00;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
SET @arg00="b"; SET @arg00="b";
execute stmt4 using @arg00; execute stmt4 using @arg00;
Field Type Null Key Default Extra Field Type Null Key Default Extra
...@@ -280,7 +280,7 @@ Field Type Null Key Default Extra ...@@ -280,7 +280,7 @@ Field Type Null Key Default Extra
prepare stmt4 from ' show columns from t2 from test like ''a%'' '; prepare stmt4 from ' show columns from t2 from test like ''a%'' ';
execute stmt4; execute stmt4;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
create index t2_idx on t2(b); create index t2_idx on t2(b);
prepare stmt4 from ' show index from t2 from test '; prepare stmt4 from ' show index from t2 from test ';
execute stmt4; execute stmt4;
...@@ -409,7 +409,7 @@ drop database mysqltest ; ...@@ -409,7 +409,7 @@ drop database mysqltest ;
prepare stmt3 from ' describe t2 '; prepare stmt3 from ' describe t2 ';
execute stmt3; execute stmt3;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO PRI a int(11) NO PRI NULL
b char(10) YES MUL NULL b char(10) YES MUL NULL
drop table t2 ; drop table t2 ;
execute stmt3; execute stmt3;
......
...@@ -4062,4 +4062,38 @@ SHOW WARNINGS; ...@@ -4062,4 +4062,38 @@ SHOW WARNINGS;
Level Code Message Level Code Message
Note 1003 select '0' AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by '0','0','0','0','0' Note 1003 select '0' AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by '0','0','0','0','0'
DROP TABLE t1; DROP TABLE t1;
SELECT 1 AS ` `;
1
Warnings:
Warning 1474 Name ' ' has become ''
SELECT 1 AS ` `;
1
Warnings:
Warning 1474 Name ' ' has become ''
SELECT 1 AS ` x`;
x
1
Warnings:
Warning 1466 Leading spaces are removed from name ' x'
CREATE VIEW v1 AS SELECT 1 AS ` `;
Warnings:
Warning 1474 Name ' ' has become ''
SELECT `` FROM v1;
1
CREATE VIEW v2 AS SELECT 1 AS ` `;
Warnings:
Warning 1474 Name ' ' has become ''
SELECT `` FROM v2;
1
CREATE VIEW v3 AS SELECT 1 AS ` x`;
Warnings:
Warning 1466 Leading spaces are removed from name ' x'
SELECT `x` FROM v3;
x
1
DROP VIEW v1, v2, v3;
End of 5.0 tests End of 5.0 tests
...@@ -228,7 +228,7 @@ show full columns from t1; ...@@ -228,7 +228,7 @@ show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
test_set set('val1','val2','val3') latin1_swedish_ci NO select,insert,update,references test_set set('val1','val2','val3') latin1_swedish_ci NO select,insert,update,references
name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default
c int(11) NULL NO select,insert,update,references int column c int(11) NULL NO NULL select,insert,update,references int column
c-b int(11) NULL YES NULL select,insert,update,references name with a minus c-b int(11) NULL YES NULL select,insert,update,references name with a minus
space 2 int(11) NULL YES NULL select,insert,update,references name with a space space 2 int(11) NULL YES NULL select,insert,update,references name with a space
drop table t1; drop table t1;
...@@ -901,7 +901,7 @@ def COLUMNS COLUMN_KEY Key 253 9 3 N 1 0 33 ...@@ -901,7 +901,7 @@ def COLUMNS COLUMN_KEY Key 253 9 3 N 1 0 33
def COLUMNS COLUMN_DEFAULT Default 252 589815 0 Y 16 0 33 def COLUMNS COLUMN_DEFAULT Default 252 589815 0 Y 16 0 33
def COLUMNS EXTRA Extra 253 60 0 N 1 0 33 def COLUMNS EXTRA Extra 253 60 0 N 1 0 33
Field Type Null Key Default Extra Field Type Null Key Default Extra
c int(11) NO PRI c int(11) NO PRI NULL
---------------------------------------------------------------- ----------------------------------------------------------------
SHOW TRIGGERS LIKE 't1'; SHOW TRIGGERS LIKE 't1';
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
......
...@@ -2468,7 +2468,7 @@ Database (foo) ...@@ -2468,7 +2468,7 @@ Database (foo)
Level Code Message Level Code Message
Field Type Null Key Default Extra Field Type Null Key Default Extra
id char(16) NO id char(16) NO
data int(11) NO data int(11) NO NULL
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Database Table In_use Name_locked Database Table In_use Name_locked
Privilege Context Comment Privilege Context Comment
...@@ -2520,7 +2520,7 @@ Database (foo) ...@@ -2520,7 +2520,7 @@ Database (foo)
Level Code Message Level Code Message
Field Type Null Key Default Extra Field Type Null Key Default Extra
id char(16) NO id char(16) NO
data int(11) NO data int(11) NO NULL
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Database Table In_use Name_locked Database Table In_use Name_locked
Privilege Context Comment Privilege Context Comment
......
...@@ -657,4 +657,19 @@ b ...@@ -657,4 +657,19 @@ b
# #
# #
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, b bit(2));
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
COUNT(DISTINCT b)
2
2
DROP TABLE t1;
create table t2 (a int, b bit(2), c char(10));
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
(3, 2, 'two'), (3, 1, 'one');
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
COUNT(DISTINCT b,c)
2
2
DROP TABLE t2;
End of 5.0 tests End of 5.0 tests
...@@ -1675,7 +1675,7 @@ t1 CREATE TABLE `t1` ( ...@@ -1675,7 +1675,7 @@ t1 CREATE TABLE `t1` (
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES 1 a int(11) YES 1
b enum('value','_value','') NO b enum('value','_value','') NO NULL
drop table t1; drop table t1;
CREATE TABLE t1 (c enum('a', 'A') BINARY); CREATE TABLE t1 (c enum('a', 'A') BINARY);
INSERT INTO t1 VALUES ('a'),('A'); INSERT INTO t1 VALUES ('a'),('A');
......
...@@ -63,9 +63,9 @@ time_field time NULL YES NULL # ...@@ -63,9 +63,9 @@ time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
blob_col blob NULL YES NULL # blob_col blob NULL YES NULL #
tinyblob_col tinyblob NULL YES NULL # tinyblob_col tinyblob NULL YES NULL #
mediumblob_col mediumblob NULL NO # mediumblob_col mediumblob NULL NO NULL #
longblob_col longblob NULL NO # longblob_col longblob NULL NO NULL #
options enum('one','two','tree') latin1_swedish_ci NO MUL # options enum('one','two','tree') latin1_swedish_ci NO MUL NULL #
flags set('one','two','tree') latin1_swedish_ci NO # flags set('one','two','tree') latin1_swedish_ci NO #
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
...@@ -214,7 +214,7 @@ Field Type Collation Null Key Default Extra Privileges Comment ...@@ -214,7 +214,7 @@ Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL NO MUL NULL auto_increment # auto int(5) unsigned NULL NO MUL NULL auto_increment #
string char(10) latin1_swedish_ci YES newdefault # string char(10) latin1_swedish_ci YES newdefault #
tiny tinyint(4) NULL NO MUL 0 # tiny tinyint(4) NULL NO MUL 0 #
short smallint(6) NULL NO MUL # short smallint(6) NULL NO MUL NULL #
medium mediumint(8) NULL NO MUL 0 # medium mediumint(8) NULL NO MUL 0 #
long_int int(11) NULL NO 0 # long_int int(11) NULL NO 0 #
longlong bigint(13) NULL NO MUL 0 # longlong bigint(13) NULL NO MUL 0 #
...@@ -231,8 +231,8 @@ time_field time NULL YES NULL # ...@@ -231,8 +231,8 @@ time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
new_blob_col varchar(20) latin1_swedish_ci YES NULL # new_blob_col varchar(20) latin1_swedish_ci YES NULL #
tinyblob_col tinyblob NULL YES NULL # tinyblob_col tinyblob NULL YES NULL #
mediumblob_col mediumblob NULL NO # mediumblob_col mediumblob NULL NO NULL #
options enum('one','two','tree') latin1_swedish_ci NO MUL # options enum('one','two','tree') latin1_swedish_ci NO MUL NULL #
flags set('one','two','tree') latin1_swedish_ci NO # flags set('one','two','tree') latin1_swedish_ci NO #
new_field char(10) latin1_swedish_ci NO new # new_field char(10) latin1_swedish_ci NO new #
show full columns from t2; show full columns from t2;
...@@ -240,7 +240,7 @@ Field Type Collation Null Key Default Extra Privileges Comment ...@@ -240,7 +240,7 @@ Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL NO 0 # auto int(5) unsigned NULL NO 0 #
string char(10) latin1_swedish_ci YES newdefault # string char(10) latin1_swedish_ci YES newdefault #
tiny tinyint(4) NULL NO 0 # tiny tinyint(4) NULL NO 0 #
short smallint(6) NULL NO # short smallint(6) NULL NO NULL #
medium mediumint(8) NULL NO 0 # medium mediumint(8) NULL NO 0 #
long_int int(11) NULL NO 0 # long_int int(11) NULL NO 0 #
longlong bigint(13) NULL NO 0 # longlong bigint(13) NULL NO 0 #
...@@ -257,8 +257,8 @@ time_field time NULL YES NULL # ...@@ -257,8 +257,8 @@ time_field time NULL YES NULL #
date_time datetime NULL YES NULL # date_time datetime NULL YES NULL #
new_blob_col varchar(20) latin1_swedish_ci YES NULL # new_blob_col varchar(20) latin1_swedish_ci YES NULL #
tinyblob_col tinyblob NULL YES NULL # tinyblob_col tinyblob NULL YES NULL #
mediumblob_col mediumblob NULL NO # mediumblob_col mediumblob NULL NO NULL #
options enum('one','two','tree') latin1_swedish_ci NO # options enum('one','two','tree') latin1_swedish_ci NO NULL #
flags set('one','two','tree') latin1_swedish_ci NO # flags set('one','two','tree') latin1_swedish_ci NO #
new_field char(10) latin1_swedish_ci NO new # new_field char(10) latin1_swedish_ci NO new #
select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
...@@ -276,8 +276,8 @@ t1 int(1) NULL NO 0 # ...@@ -276,8 +276,8 @@ t1 int(1) NULL NO 0 #
t2 varchar(1) latin1_swedish_ci NO # t2 varchar(1) latin1_swedish_ci NO #
t3 varchar(256) latin1_swedish_ci NO # t3 varchar(256) latin1_swedish_ci NO #
t4 varbinary(256) NULL NO # t4 varbinary(256) NULL NO #
t5 longtext latin1_swedish_ci NO # t5 longtext latin1_swedish_ci NO NULL #
t6 longblob NULL NO # t6 longblob NULL NO NULL #
t7 char(0) latin1_swedish_ci NO # t7 char(0) latin1_swedish_ci NO #
t8 binary(0) NULL NO # t8 binary(0) NULL NO #
select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2; select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2;
......
...@@ -1071,4 +1071,21 @@ connection default; ...@@ -1071,4 +1071,21 @@ connection default;
drop user mysqltest_1@localhost; drop user mysqltest_1@localhost;
drop database mysqltest; drop database mysqltest;
#
# Bug#27747 database metadata doesn't return sufficient column default info
#
create table t1 (
f1 varchar(50),
f2 varchar(50) not null,
f3 varchar(50) default '',
f4 varchar(50) default NULL,
f5 bigint not null,
f6 bigint not null default 10,
f7 datetime not null,
f8 datetime default '2006-01-01'
);
select column_default from information_schema.columns where table_name= 't1';
show columns from t1;
drop table t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
...@@ -937,4 +937,27 @@ SELECT c,b FROM t1 GROUP BY c,b; ...@@ -937,4 +937,27 @@ SELECT c,b FROM t1 GROUP BY c,b;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #31001: ORDER BY DESC in InnoDB not working
#
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
#The two queries below should produce different results, but they don't.
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
SELECT * FROM t1 ORDER BY b ASC, a ASC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
SELECT * FROM t1 ORDER BY b DESC, a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
SELECT * FROM t1 ORDER BY b ASC, a DESC;
query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
SELECT * FROM t1 ORDER BY b DESC, a ASC;
DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -3460,4 +3460,28 @@ SHOW WARNINGS; ...@@ -3460,4 +3460,28 @@ SHOW WARNINGS;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #27695: Misleading warning when declaring all space column names and
# truncation of one-space column names to zero length names.
#
--disable_ps_protocol
SELECT 1 AS ` `;
SELECT 1 AS ` `;
SELECT 1 AS ` x`;
CREATE VIEW v1 AS SELECT 1 AS ` `;
SELECT `` FROM v1;
CREATE VIEW v2 AS SELECT 1 AS ` `;
SELECT `` FROM v2;
CREATE VIEW v3 AS SELECT 1 AS ` x`;
SELECT `x` FROM v3;
DROP VIEW v1, v2, v3;
--enable_ps_protocol
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -304,4 +304,18 @@ SELECT b FROM t1 GROUP BY b; ...@@ -304,4 +304,18 @@ SELECT b FROM t1 GROUP BY b;
--disable_metadata --disable_metadata
DROP TABLE t1; DROP TABLE t1;
#
# BUG#30324 Wrong query result for COUNT(DISTINCT(bit_column))
#
CREATE TABLE t1 (a int, b bit(2));
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
DROP TABLE t1;
create table t2 (a int, b bit(2), c char(10));
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
(3, 2, 'two'), (3, 1, 'one');
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
DROP TABLE t2;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -700,10 +700,16 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) ...@@ -700,10 +700,16 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
str++; str++;
} }
if (orig_len != length && !is_autogenerated_name) if (orig_len != length && !is_autogenerated_name)
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, {
ER_REMOVED_SPACES, ER(ER_REMOVED_SPACES), if (length == 0)
str + length - orig_len); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NAME_BECOMES_EMPTY, ER(ER_NAME_BECOMES_EMPTY),
str + length - orig_len);
else
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_REMOVED_SPACES, ER(ER_REMOVED_SPACES),
str + length - orig_len);
}
} }
if (!my_charset_same(cs, system_charset_info)) if (!my_charset_same(cs, system_charset_info))
{ {
......
...@@ -2464,6 +2464,23 @@ bool Item_sum_count_distinct::setup(THD *thd) ...@@ -2464,6 +2464,23 @@ bool Item_sum_count_distinct::setup(THD *thd)
count_field_types(select_lex, tmp_table_param, list, 0); count_field_types(select_lex, tmp_table_param, list, 0);
tmp_table_param->force_copy_fields= force_copy_fields; tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0); DBUG_ASSERT(table == 0);
/*
Make create_tmp_table() convert BIT columns to BIGINT.
This is needed because BIT fields store parts of their data in table's
null bits, and we don't have methods to compare two table records, which
is needed by Unique which is used when HEAP table is used.
*/
{
List_iterator_fast<Item> li(list);
Item *item;
while ((item= li++))
{
if (item->type() == Item::FIELD_ITEM &&
((Item_field*)item)->field->type() == FIELD_TYPE_BIT)
item->marker=4;
}
}
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1, if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0, 0,
(select_lex->options | thd->options), (select_lex->options | thd->options),
......
...@@ -5637,3 +5637,5 @@ ER_ADMIN_WRONG_MRG_TABLE ...@@ -5637,3 +5637,5 @@ ER_ADMIN_WRONG_MRG_TABLE
eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"
ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
eng "Too high level of nesting for select" eng "Too high level of nesting for select"
ER_NAME_BECOMES_EMPTY
eng "Name '%-.64s' has become ''"
...@@ -12063,6 +12063,12 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, ...@@ -12063,6 +12063,12 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
for (; const_key_parts & 1 ; const_key_parts>>= 1) for (; const_key_parts & 1 ; const_key_parts>>= 1)
key_part++; key_part++;
/*
The primary and secondary key parts were all const (i.e. there's
one row). The sorting doesn't matter.
*/
if (key_part == key_part_end && reverse == 0)
DBUG_RETURN(1);
} }
else else
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -12480,7 +12486,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, ...@@ -12480,7 +12486,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
} }
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (tab->ref.key_parts < used_key_parts) if (tab->ref.key_parts <= used_key_parts)
{ {
/* /*
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
......
...@@ -791,13 +791,70 @@ static void append_directory(THD *thd, String *packet, const char *dir_type, ...@@ -791,13 +791,70 @@ static void append_directory(THD *thd, String *packet, const char *dir_type,
#define LIST_PROCESS_HOST_LEN 64 #define LIST_PROCESS_HOST_LEN 64
static bool get_field_default_value(THD *thd, TABLE *table,
Field *field, String *def_value,
bool quoted)
{
bool has_default;
bool has_now_default;
/*
We are using CURRENT_TIMESTAMP instead of NOW because it is
more standard
*/
has_now_default= table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD;
has_default= (field->type() != FIELD_TYPE_BLOB &&
!(field->flags & NO_DEFAULT_VALUE_FLAG) &&
field->unireg_check != Field::NEXT_NUMBER &&
!((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
&& has_now_default));
def_value->length(0);
if (has_default)
{
if (has_now_default)
def_value->append(STRING_WITH_LEN("CURRENT_TIMESTAMP"));
else if (!field->is_null())
{ // Not null by default
char tmp[MAX_FIELD_WIDTH];
String type(tmp, sizeof(tmp), field->charset());
field->val_str(&type);
if (type.length())
{
String def_val;
uint dummy_errors;
/* convert to system_charset_info == utf8 */
def_val.copy(type.ptr(), type.length(), field->charset(),
system_charset_info, &dummy_errors);
if (quoted)
append_unescaped(def_value, def_val.ptr(), def_val.length());
else
def_value->append(def_val.ptr(), def_val.length());
}
else if (quoted)
def_value->append(STRING_WITH_LEN("''"));
}
else if (field->maybe_null() && quoted)
def_value->append(STRING_WITH_LEN("NULL")); // Null as default
else
return 0;
}
return has_default;
}
static int static int
store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
{ {
List<Item> field_list; List<Item> field_list;
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128]; char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
const char *alias; const char *alias;
String type(tmp, sizeof(tmp), system_charset_info); String type(tmp, sizeof(tmp), system_charset_info);
String def_value(def_value_buf, sizeof(def_value_buf), system_charset_info);
Field **ptr,*field; Field **ptr,*field;
uint primary_key; uint primary_key;
KEY *key_info; KEY *key_info;
...@@ -833,8 +890,6 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) ...@@ -833,8 +890,6 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
for (ptr=table->field ; (field= *ptr); ptr++) for (ptr=table->field ; (field= *ptr); ptr++)
{ {
bool has_default;
bool has_now_default;
uint flags = field->flags; uint flags = field->flags;
if (ptr != table->field) if (ptr != table->field)
...@@ -882,44 +937,10 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) ...@@ -882,44 +937,10 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
packet->append(STRING_WITH_LEN(" NULL")); packet->append(STRING_WITH_LEN(" NULL"));
} }
/* if (get_field_default_value(thd, table, field, &def_value, 1))
Again we are using CURRENT_TIMESTAMP instead of NOW because it is
more standard
*/
has_now_default= table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD;
has_default= (field->type() != FIELD_TYPE_BLOB &&
!(field->flags & NO_DEFAULT_VALUE_FLAG) &&
field->unireg_check != Field::NEXT_NUMBER &&
!((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
&& has_now_default));
if (has_default)
{ {
packet->append(STRING_WITH_LEN(" default ")); packet->append(STRING_WITH_LEN(" default "));
if (has_now_default) packet->append(def_value.ptr(), def_value.length(), system_charset_info);
packet->append(STRING_WITH_LEN("CURRENT_TIMESTAMP"));
else if (!field->is_null())
{ // Not null by default
type.set(tmp, sizeof(tmp), field->charset());
field->val_str(&type);
if (type.length())
{
String def_val;
uint dummy_errors;
/* convert to system_charset_info == utf8 */
def_val.copy(type.ptr(), type.length(), field->charset(),
system_charset_info, &dummy_errors);
append_unescaped(packet, def_val.ptr(), def_val.length());
}
else
packet->append(STRING_WITH_LEN("''"));
}
else if (field->maybe_null())
packet->append(STRING_WITH_LEN("NULL")); // Null as default
else
packet->append(tmp);
} }
if (!limited_mysql_mode && table->timestamp_field == field && if (!limited_mysql_mode && table->timestamp_field == field &&
...@@ -2664,7 +2685,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, ...@@ -2664,7 +2685,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
bool is_blob; bool is_blob;
uint flags=field->flags; uint flags=field->flags;
char tmp[MAX_FIELD_WIDTH]; char tmp[MAX_FIELD_WIDTH];
char tmp1[MAX_FIELD_WIDTH];
String type(tmp,sizeof(tmp), system_charset_info); String type(tmp,sizeof(tmp), system_charset_info);
char *end; char *end;
int decimals, field_length; int decimals, field_length;
...@@ -2710,33 +2730,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, ...@@ -2710,33 +2730,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
table->field[7]->store(type.ptr(), table->field[7]->store(type.ptr(),
(tmp_buff ? tmp_buff - type.ptr() : (tmp_buff ? tmp_buff - type.ptr() :
type.length()), cs); type.length()), cs);
if (show_table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD) if (get_field_default_value(thd, show_table, field, &type, 0))
{
table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs);
table->field[5]->set_notnull();
}
else if (field->unireg_check != Field::NEXT_NUMBER &&
!field->is_null() &&
!(field->flags & NO_DEFAULT_VALUE_FLAG))
{
String def(tmp1,sizeof(tmp1), cs);
type.set(tmp, sizeof(tmp), field->charset());
field->val_str(&type);
uint dummy_errors;
def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
table->field[5]->store(def.ptr(), def.length(), def.charset());
table->field[5]->set_notnull();
}
else if (field->unireg_check == Field::NEXT_NUMBER ||
lex->orig_sql_command != SQLCOM_SHOW_FIELDS ||
field->maybe_null())
table->field[5]->set_null(); // Null as default
else
{ {
table->field[5]->store("",0, cs); table->field[5]->store(type.ptr(), type.length(), cs);
table->field[5]->set_notnull(); table->field[5]->set_notnull();
} }
pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES"); pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES");
table->field[6]->store((const char*) pos, table->field[6]->store((const char*) pos,
strlen((const char*) pos), cs); strlen((const char*) pos), cs);
......
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