Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
Description
I run this script:
CREATE OR REPLACE TABLE t1 (a int(11) NOT NULL); |
INSERT INTO t1 VALUES (1),(2); |
CREATE OR REPLACE VIEW v1 AS SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP; |
DESCRIBE v1;
|
+-----------+------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+-----------+------------+------+-----+---------+-------+
|
| a | bigint(11) | YES | | NULL | |
|
| LENGTH(a) | bigint(10) | YES | | NULL | |
|
| COUNT(*) | bigint(21) | NO | | 0 | |
|
+-----------+------------+------+-----+---------+-------+
|
Notice, it reports the data type of v1.a as BIGINT for some reasons. The expected data type is INT.
Now I change the data type from int to bigint:
CREATE OR REPLACE TABLE t1 (a bigint(11) NOT NULL); |
INSERT INTO t1 VALUES (1),(2); |
CREATE OR REPLACE VIEW v1 AS SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP; |
DESCRIBE v1;
|
+-----------+------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+-----------+------------+------+-----+---------+-------+
|
| a | bigint(20) | YES | | 0 | |
|
| LENGTH(a) | bigint(10) | YES | | NULL | |
|
| COUNT(*) | bigint(21) | NO | | 0 | |
|
+-----------+------------+------+-----+---------+-------+
|
Notice, field "a" has different default:
- NULL for int
- 0 for BIGINT.
Looks suspicious.
The difference happens because int does not pass this condition, while bigint does:
if (orig_type != Item::DEFAULT_VALUE_ITEM && field->field->eq_def(result)) |
*default_field= field->field;
|
See sql_select.cc, create_tmp_field().
Attachments
Issue Links
- relates to
-
MDEV-9410 VIEW over a ROLLUP query reports too large columns
- Closed