Commit 1e442594 authored by unknown's avatar unknown
Browse files

Fixed bug #19714.

DESCRIBE returned the type BIGINT for a column of a view if the column
was specified by an expression over values of the type INT.
    
E.g. for the view defined as follows:
  CREATE VIEW v1 SELECT COALESCE(f1,f2) FROM t1
DESCRIBE returned type BIGINT for the only column of the view if f1,f2 are
columns of the INT type.
At the same time DESCRIBE returned type INT for the only column of the table
defined by the statement:
  CREATE TABLE t2 SELECT COALESCE(f1,f2) FROM t1.
    
This inconsistency was removed by the patch.

Now the code chooses between INT/BIGINT depending on the
precision of the aggregated column type.
 
Thus both DESCRIBE commands above returns type INT for v1 and t2.
 


mysql-test/r/analyse.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/bigint.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/create.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/olap.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_2myisam.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_3innodb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_4heap.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_5merge.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_6bdb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_7ndb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/sp.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/subselect.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/type_ranges.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/view.result:
  Added a test case for bug #19714.
mysql-test/t/view.test:
  Added a test case for bug #19714.
parent 80eae1a3
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -39,10 +39,10 @@ t2 CREATE TABLE `t2` (
  `Field_name` varbinary(255) NOT NULL default '',
  `Min_value` varbinary(255) default NULL,
  `Max_value` varbinary(255) default NULL,
  `Min_length` bigint(11) NOT NULL default '0',
  `Max_length` bigint(11) NOT NULL default '0',
  `Empties_or_zeros` bigint(11) NOT NULL default '0',
  `Nulls` bigint(11) NOT NULL default '0',
  `Min_length` int(11) NOT NULL default '0',
  `Max_length` int(11) NOT NULL default '0',
  `Empties_or_zeros` int(11) NOT NULL default '0',
  `Nulls` int(11) NOT NULL default '0',
  `Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
  `Std` varbinary(255) default NULL,
  `Optimal_fieldtype` varbinary(64) NOT NULL default ''
@@ -58,10 +58,10 @@ t2 CREATE TABLE `t2` (
  `Field_name` varbinary(255) NOT NULL default '',
  `Min_value` varbinary(255) default NULL,
  `Max_value` varbinary(255) default NULL,
  `Min_length` bigint(11) NOT NULL default '0',
  `Max_length` bigint(11) NOT NULL default '0',
  `Empties_or_zeros` bigint(11) NOT NULL default '0',
  `Nulls` bigint(11) NOT NULL default '0',
  `Min_length` int(11) NOT NULL default '0',
  `Max_length` int(11) NOT NULL default '0',
  `Empties_or_zeros` int(11) NOT NULL default '0',
  `Nulls` int(11) NOT NULL default '0',
  `Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
  `Std` varbinary(255) default NULL,
  `Optimal_fieldtype` varbinary(64) NOT NULL default ''
@@ -81,10 +81,10 @@ t2 CREATE TABLE `t2` (
  `Field_name` varbinary(255) NOT NULL default '',
  `Min_value` varbinary(255) default NULL,
  `Max_value` varbinary(255) default NULL,
  `Min_length` bigint(11) NOT NULL default '0',
  `Max_length` bigint(11) NOT NULL default '0',
  `Empties_or_zeros` bigint(11) NOT NULL default '0',
  `Nulls` bigint(11) NOT NULL default '0',
  `Min_length` int(11) NOT NULL default '0',
  `Max_length` int(11) NOT NULL default '0',
  `Empties_or_zeros` int(11) NOT NULL default '0',
  `Nulls` int(11) NOT NULL default '0',
  `Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
  `Std` varbinary(255) default NULL,
  `Optimal_fieldtype` varbinary(64) NOT NULL default ''
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ create table t1 select 1 as 'a';
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` bigint(1) NOT NULL default '0'
  `a` int(1) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 select 9223372036854775809 as 'a';
+2 −2
Original line number Diff line number Diff line
@@ -668,7 +668,7 @@ Table Create Table
t1	CREATE TABLE `t1` (
  `b` int(11) NOT NULL,
  `a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
  `c` bigint(1) NOT NULL default '0',
  `c` int(1) NOT NULL default '0',
  PRIMARY KEY  (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
@@ -681,7 +681,7 @@ Table Create Table
t1	CREATE TABLE `t1` (
  `b` int(11) default NULL,
  `a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
  `c` bigint(1) NOT NULL default '0',
  `c` int(1) NOT NULL default '0',
  PRIMARY KEY  (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+2 −2
Original line number Diff line number Diff line
@@ -620,8 +620,8 @@ CREATE VIEW v1 AS
SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
DESC v1;
Field	Type	Null	Key	Default	Extra
a	bigint(11)	YES		NULL	
LENGTH(a)	bigint(10)	YES		NULL	
a	int(11)	YES		0	
LENGTH(a)	int(10)	YES		NULL	
COUNT(*)	bigint(21)	NO		0	
SELECT * FROM v1;
a	LENGTH(a)	COUNT(*)
+2 −2
Original line number Diff line number Diff line
@@ -1775,7 +1775,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table	Create Table
t5	CREATE TABLE `t5` (
  `const01` bigint(1) NOT NULL default '0',
  `const01` int(1) NOT NULL default '0',
  `param01` bigint(20) default NULL,
  `const02` decimal(2,1) NOT NULL default '0.0',
  `param02` decimal(65,30) default NULL,
@@ -1805,7 +1805,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
def	test	t5	t5	const01	const01	3	1	1	N	32769	0	63
def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
Loading