pingcap / pingcap/tidb

Whether executing SELECT with INET_ATON() after the INSERT results in inconsistent behaviors in transaction

Open
#64,347 2 comments 0 reactions 0 assignees View on GitHub
contribution first-time-contributor type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
/* init */ DROP TABLE IF EXISTS t;
/* init */ CREATE TABLE t (c1 DOUBLE NOT NULL, c2 BIT);;
/* init */ INSERT INTO t(c1, c2) VALUES (5.02, b'0');

-- not in transaction
/* s */ INSERT INTO t(c1,c2) VALUES (-1.54,b'1');
/* s */ SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t; -- [1]

-- in transaction
/* t1 */ BEGIN;
/* t1 */ SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t; -- [2]

-- in transaction after an INSERT
/* t1 */ BEGIN;
/* t1 */ INSERT INTO t(c1,c2) VALUES (-1.54,b'1');
/* t1 */ SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t; -- [3]
```

### 2. What did you expect to see? (Required)
The results of the SELECT statements [1], [2] and [3] are the same.

### 3. What did you see instead (Required)
The SELECT statements [1], [2] have retrieved the results, while the SELECT statement [3] gets an error.

[1] SELECT not in a transaction:
```sql
mysql> INSERT INTO t(c1,c2) VALUES (-1.54,b'1');
Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t;
+-------+------------+
| c1 | c2 |
+-------+------------+
| -1.54 | 0x01 |
| 5.02 | 0x00 |
+-------+------------+
2 rows in set (0.00 sec)
```

[2] SELECT in a transaction:
```sql
mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t;
+------+------------+
| c1 | c2 |
+------+------------+
| 5.02 | 0x00 |
+------+------------+
1 row in set (0.01 sec)
```

[3] SELECT in a transaction after an INSERT
```sql
mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t(c1,c2) VALUES (-1.54,b'1');
Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM t WHERE (INET_ATON('test')) UNION SELECT c1, c2 FROM t;
ERROR 1411 (HY000): Incorrect string value: 'test' for function inet_aton
```

### 4. What is your TiDB version? (Required)

```sql
Release Version: v8.5.3
Edition: Community
Git Commit Hash: dc2548aac79a712265e831cff2a3a896bc0a5a38
Git Branch: HEAD
UTC Build Time: 2025-07-31 13:54:43
GoVersion: go1.23.8
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.