pingcap / pingcap/tiflash

TiFlash returns truncated results for UNION of LONGTEXT and DECIMAL columns

Open
#10,534 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/compute contribution type/bug
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
DROP TABLE IF EXISTS tb0;
DROP TABLE IF EXISTS tb4;
CREATE TABLE tb0 (
    id INT AUTO_INCREMENT NOT NULL,
    c0 DECIMAL(20,17)
);

CREATE TABLE tb4 (
    id INT AUTO_INCREMENT NOT NULL,
    c0 LONGTEXT NOT NULL
) PARTITION BY HASH (id) PARTITIONS 2;

INSERT INTO tb4 (c0) VALUES ('v3hquFLhrRBIfJVqKFE5wwA8nEKJotu4f6V8uaCe0');

ALTER TABLE tb4 SET TIFLASH REPLICA 1;
ALTER TABLE tb0 SET TIFLASH REPLICA 1;

(SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 AS col_0, 1 FROM tb4 AS t0)
UNION
(SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 AS col_0, t0.id AS col_1 FROM tb0 AS t0 WHERE false);
2. What did you expect to see? (Required)

tidb result

mysql> (SELECT /*+ read_from_storage(tikv[t0]) */ t0.c0 AS col_0, 1 FROM tb4 AS t0)
    -> UNION
    -> (SELECT /*+ read_from_storage(tikv[t0]) */ t0.c0 AS col_0, t0.id AS col_1 FROM tb0 AS t0 WHERE false);
+-------------------------------------------+---+
| col_0                                     | 1 |
+-------------------------------------------+---+
| v3hquFLhrRBIfJVqKFE5wwA8nEKJotu4f6V8uaCe0 | 1 |
+-------------------------------------------+---+
1 row in set (0.004 sec)

without union

mysql> (SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 AS col_0, 1 FROM tb4 AS t0);
+-------------------------------------------+---+
| col_0                                     | 1 |
+-------------------------------------------+---+
| v3hquFLhrRBIfJVqKFE5wwA8nEKJotu4f6V8uaCe0 | 1 |
+-------------------------------------------+---+
1 row in set (0.008 sec)
3. What did you see instead (Required)
mysql> (SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 AS col_0, 1 FROM tb4 AS t0)
    -> UNION
    -> (SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 AS col_0, t0.id AS col_1 FROM tb0 AS t0 WHERE false);
+------------------+---+
| col_0            | 1 |
+------------------+---+
| v3hquFLhrRBIfJVq | 1 |
+------------------+---+
1 row in set (0.020 sec)

mysql>
4. What is your TiFlash version? (Required)
mysql> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-250-ga6d415f24a
Edition: Community
Git Commit Hash: a6d415f24a7d182ebca3d189c457d9044537028f
Git Branch: HEAD
UTC Build Time: 2025-08-03 10:01:12
GoVersion: go1.23.11
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named; start by running the provided TiFlash SQL reproduction and compare the UNION result with the non-UNION result. Done means the UNION query returns the complete LONGTEXT value rather than the truncated string, with regression coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.