Commit 1e6ad0ce authored by Sergei Golubchik's avatar Sergei Golubchik

don't set default value in temp table if NO_DEFAULT_VALUE_FLAG

when an internal temporary table field is created from a real field,
a new temp field should only copy a default from the source field
when the latter has it
parent 32f09df2
......@@ -3463,5 +3463,26 @@ SELECT 1 FROM t1 GROUP BY DEFAULT(pk);
1
DROP TABLE t1;
#
# MDEV-29890 Update with inner join false row count result
#
create table t1 (a int not null);
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='t1';
column_name column_default has_default is_nullable
a NULL 0 NO
create or replace view v1 as select * from t1;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
column_name column_default has_default is_nullable
a NULL 0 NO
create or replace view v1 as select * from t1 group by a;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
column_name column_default has_default is_nullable
a NULL 0 NO
create or replace view v1 as select * from t1 group by a with rollup;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
column_name column_default has_default is_nullable
a NULL 1 YES
drop view v1;
drop table t1;
#
# End of 10.4 test
#
......@@ -2169,6 +2169,20 @@ INSERT INTO t1 VALUES (),();
SELECT 1 FROM t1 GROUP BY DEFAULT(pk);
DROP TABLE t1;
--echo #
--echo # MDEV-29890 Update with inner join false row count result
--echo #
create table t1 (a int not null);
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='t1';
create or replace view v1 as select * from t1;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
create or replace view v1 as select * from t1 group by a;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
create or replace view v1 as select * from t1 group by a with rollup;
select column_name, column_default, column_default is not null as 'has_default', is_nullable from information_schema.columns where table_schema='test' and table_name='v1';
drop view v1;
drop table t1;
--echo #
--echo # End of 10.4 test
--echo #
......@@ -695,7 +695,7 @@ 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 int(11) YES 0
a int(11) YES NULL
LENGTH(a) int(10) YES NULL
COUNT(*) bigint(21) NO 0
SELECT * FROM v1;
......@@ -858,7 +858,7 @@ 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 int(11) YES 0
a int(11) YES NULL
LENGTH(a) int(10) YES NULL
COUNT(*) bigint(21) NO 0
DROP VIEW v1;
......@@ -868,7 +868,7 @@ 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
a bigint(20) YES NULL
LENGTH(a) int(10) YES NULL
COUNT(*) bigint(21) NO 0
DROP VIEW v1;
......@@ -893,8 +893,8 @@ DROP VIEW v1;
CREATE VIEW v1 AS SELECT a, b FROM t1 GROUP BY a,b WITH ROLLUP;
DESC v1;
Field Type Null Key Default Extra
a int(11) YES 0
b int(20) YES 0
a int(11) YES NULL
b int(20) YES NULL
DROP VIEW v1;
DROP TABLE t1;
#
......
......@@ -18241,7 +18241,8 @@ Field *Item_field::create_tmp_field_ex(TABLE *table,
src->set_field(field);
if (!(result= create_tmp_field_from_item_field(table, NULL, param)))
return NULL;
if (field->eq_def(result))
if (!(field->flags & NO_DEFAULT_VALUE_FLAG) &&
field->eq_def(result))
src->set_default_field(field);
return result;
}
......
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