Skip to content

The size of column state in tidb_trx is not defined #53026

@pcqz

Description

@pcqz

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(id int);
begin;
insert into t values(1);
select state from information_schema.tidb_trx as trx  union select state from information_schema.tidb_trx as trx;

2. What did you expect to see? (Required)

mysql>  select state from information_schema.tidb_trx as trx  union select state from information_schema.tidb_trx as trx;
+-------+
| state |
+-------+
| Idle  |
+-------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select state from information_schema.tidb_trx as trx  union select state from information_schema.tidb_trx as trx;
+-------+
| state |
+-------+
|       |
+-------+
1 row in set, 2 warnings (0.00 sec)

mysql> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1406 | Data Too Long, field len 0, data len 4 |
| Warning | 1406 | Data Too Long, field len 0, data len 4 |
+---------+------+----------------------------------------+
2 rows in set (0.00 sec)

Because the size of column state in tidb_trx is not defined https://github.com/pingcap/tidb/blob/v6.5.8/infoschema/tables.go#L1466, the cast function uses varchar(0) leading to data too long warning.

mysql> desc select state from information_schema.tidb_trx as trx  union select state from information_schema.tidb_trx as trx;
+-----------------------------+----------+------+----------------+----------------------------------------------------------------------------------+
| id                          | estRows  | task | access object  | operator info                                                                    |
+-----------------------------+----------+------+----------------+----------------------------------------------------------------------------------+
| HashAgg_9                   | 20000.00 | root |                | group by:Column#27, funcs:firstrow(Column#27)->Column#27                         |
| └─Union_10                  | 20000.00 | root |                |                                                                                  |
|   ├─Projection_11           | 10000.00 | root |                | cast(Column#5, varchar(0) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin)->Column#27  |
|   │ └─MemTableScan_12       | 10000.00 | root | table:TIDB_TRX |                                                                                  |
|   └─Projection_13           | 10000.00 | root |                | cast(Column#18, varchar(0) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin)->Column#27 |
|     └─MemTableScan_14       | 10000.00 | root | table:TIDB_TRX |                                                                                  |
+-----------------------------+----------+------+----------------+----------------------------------------------------------------------------------+
6 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

v6.5.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.report/customerCustomers have encountered this bug.severity/majorsig/transactionSIG:Transactiontype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions