1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, unsigned_int_column)

Item_func_hybrid_field_type did not return correct field_type(), cmp_type()
and result_type() in some cases, because cached_result_type and
cached_field_type were set in independent pieces of the code and
did not properly match to each other.
Fix:
- Removing Item_func_hybrid_result_type
- Deriving Item_func_hybrid_field_type directly from Item_func
- Introducing a new class Type_handler which guarantees that
  field_type(), cmp_type() and result_type() are always properly synchronized
  and using the new class in Item_func_hybrid_field_type.
This commit is contained in:
Alexander Barkov
2015-09-30 12:37:34 +04:00
parent 09b87d6293
commit cc9cfecab7
12 changed files with 2084 additions and 157 deletions

View File

@@ -0,0 +1,81 @@
# "mtr --ps" returns different values in "Max length"
--disable_ps_protocol
--enable_metadata
--vertical_results
SELECT
a AS ___________a,
CASE WHEN a IS NOT NULL THEN a END AS case_______a,
CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
COALESCE(a) AS coalesce___a,
COALESCE(a, a) AS coalesce_a_a,
IF(a IS NULL, a, a) AS if_______a_a,
IFNULL(a, a) AS ifnull___a_a,
LEAST(a, a) AS least____a_a,
GREATEST(a, a) AS greatest_a_a,
b AS ___________b,
CASE WHEN a IS NOT NULL THEN b END AS case_______b,
CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
COALESCE(b) AS coalesce___b,
COALESCE(b, b) AS coalesce_b_b,
IF(a IS NULL, b, b) AS if_______b_b,
IFNULL(b, b) AS ifnull___b_b,
LEAST(b, b) AS least____b_b,
GREATEST(b, b) AS greatest_b_b
FROM t1;
SELECT
CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
COALESCE(a, b) AS coalesce_a_b,
COALESCE(b, a) AS coalesce_b_a,
IF(a IS NULL, a, b) AS if_______a_b,
IF(a IS NULL, b, a) AS if_______b_a,
IFNULL(a, b) AS ifnull___a_b,
IFNULL(b, a) AS ifnull___b_a,
LEAST(a, b) AS least____a_b,
LEAST(b, a) AS least____b_a,
GREATEST(a, b) AS greatest_a_b,
GREATEST(b, a) AS greatest_b_a
FROM t1;
--horizontal_results
--disable_metadata
--enable_ps_protocol
CREATE TABLE t2 AS
SELECT
a AS ___________a,
CASE WHEN a IS NOT NULL THEN a END AS case_______a,
CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
COALESCE(a) AS coalesce___a,
COALESCE(a, a) AS coalesce_a_a,
IF(a IS NULL, a, a) AS if_______a_a,
IFNULL(a, a) AS ifnull___a_a,
LEAST(a, a) AS least____a_a,
GREATEST(a, a) AS greatest_a_a,
b AS ___________b,
CASE WHEN a IS NOT NULL THEN b END AS case_______b,
CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
COALESCE(b) AS coalesce___b,
COALESCE(b, b) AS coalesce_b_b,
IF(a IS NULL, b, b) AS if_______b_b,
IFNULL(b, b) AS ifnull___b_b,
LEAST(b, b) AS least____b_b,
GREATEST(b, b) AS greatest_b_b
FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2;
CREATE TABLE t2 AS
SELECT
CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
COALESCE(a, b) AS coalesce_a_b,
COALESCE(b, a) AS coalesce_b_a,
IF(a IS NULL, a, b) AS if_______a_b,
IF(a IS NULL, b, a) AS if_______b_a,
IFNULL(a, b) AS ifnull___a_b,
IFNULL(b, a) AS ifnull___b_a,
LEAST(a, b) AS least____a_b,
LEAST(b, a) AS least____b_a,
GREATEST(a, b) AS greatest_a_b,
GREATEST(b, a) AS greatest_b_a
FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2;