summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2023-01-09 12:49:37 +0100
committerSergei Golubchik <serg@mariadb.org>2023-01-09 18:06:06 +0100
commit1e6ad0ce13c5d2e4125df8006316d9dfe0f8d649 (patch)
treef38f5d5ed1194f71e0050b1b9f25b161f4e0f30c
parent32f09df2b86ed4d2b9b63b26b5c95f8555bc1db3 (diff)
downloadmariadb-git-1e6ad0ce13c5d2e4125df8006316d9dfe0f8d649.tar.gz
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
-rw-r--r--mysql-test/main/default.result21
-rw-r--r--mysql-test/main/default.test14
-rw-r--r--mysql-test/main/olap.result10
-rw-r--r--sql/sql_select.cc3
4 files changed, 42 insertions, 6 deletions
diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result
index 100a2fe6a6f..ae835940af3 100644
--- a/mysql-test/main/default.result
+++ b/mysql-test/main/default.result
@@ -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
#
diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test
index 3064209a4a2..13f611246c9 100644
--- a/mysql-test/main/default.test
+++ b/mysql-test/main/default.test
@@ -2170,5 +2170,19 @@ 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 #
diff --git a/mysql-test/main/olap.result b/mysql-test/main/olap.result
index cc261c92603..b837aeaf1db 100644
--- a/mysql-test/main/olap.result
+++ b/mysql-test/main/olap.result
@@ -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;
#
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d7b2891c9d4..d5519e9f541 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;
}