pingcap / pingcap/tidb

INET6_ATON behaves inconsistently between vectorized and scalar execution modes (Error vs NULL)

Open
#65,816 2 comments 0 reactions 0 assignees View on GitHub
contribution severity/moderate sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

There is a inconsistency in how INET6_ATON() handles invalid input formats depending on the tidb_enable_vectorized_expression session variable.

Vectorized Mode (ON): The function returns NULL (implied by the empty result set) but fails to produce the standard Incorrect string value warning.

Scalar Mode (OFF): The function throws a hard ERROR 1411, causing the query to crash immediately.

Both behaviors deviate from the standard MySQL 8.0 behavior, which robustly handles the invalid input by returning NULL (Empty Set) accompanied by a specific Warning.

### 1. Minimal reproduce step (Required)

```
CREATE DATABASE test;
USE test;
CREATE TABLE t0(c0 INT);
INSERT INTO t0(c0) VALUES (1);
SET SESSION tidb_enable_vectorized_expression = ON;
SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
EXPLAIN ANALYZE SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
SHOW WARNINGS;
SET SESSION tidb_enable_vectorized_expression = off;
SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
EXPLAIN ANALYZE SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
```

### 2. What did you expect to see? (Required)
Behavior should be consistent with MySQL:
```
(MySQL 8.0.42-0ubuntu0.20.04.1)
mysql> SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
Empty set, 1 warning (0.00 sec)

mysql> EXPLAIN ANALYZE SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
+------------------------------------------------------------------------------------------------+
| EXPLAIN |
+------------------------------------------------------------------------------------------------+
| -> Zero rows (Impossible WHERE) (cost=0..0 rows=0) (actual time=57e-6..57e-6 rows=0 loops=1)
|
+------------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------+
| Warning | 1411 | Incorrect string value: '1' for function inet6_aton |
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)
```

### 3. What did you see instead (Required)
```
mysql> SET SESSION tidb_enable_vectorized_expression = ON;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
Empty set (0.00 sec)

mysql> EXPLAIN ANALYZE SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
+-------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+-------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
| Selection_7 | 8000.00 | 0 | root | | time:483.6µs, loops:1, RU:0.49 | inet6_aton("1") | 380 Bytes | N/A |
| └─TableReader_6 | 10000.00 | 1 | root | | time:476.2µs, loops:2, cop_task: {num: 1, max: 452.8µs, proc_keys: 1, tot_proc: 48.5µs, tot_wait: 51µs, copr_cache_hit_ratio: 0.00, build_task_duration: 8.32µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:1, total_time:440.9µs}} | data:TableFullScan_5 | 256 Bytes | N/A |
| └─TableFullScan_5 | 10000.00 | 1 | cop[tikv] | table:t0 | tikv_task:{time:0s, loops:1}, scan_detail: {total_process_keys: 1, total_process_keys_size: 37, total_keys: 2, get_snapshot_time: 18.1µs, rocksdb: {key_skipped_count: 1, block: {cache_hit_count: 2}}}, time_detail: {total_process_time: 48.5µs, total_wait_time: 51µs, tikv_wall_time: 184.6µs} | keep order:false, stats:pseudo | N/A | N/A |
+-------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
3 rows in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+----------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------------------------------------------------------------------------+
| Warning | 1105 | Scalar function 'inet6_aton'(signature: Inet6Aton, return type: var_string(16)) is not supported to push down to tikv now. |
+---------+------+----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SET SESSION tidb_enable_vectorized_expression = off;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
ERROR 1411 (HY000): Incorrect string value: '1' for function inet_aton6
mysql> EXPLAIN ANALYZE SELECT t0.c0 FROM t0 WHERE INET6_ATON(1);
ERROR 1411 (HY000): Incorrect string value: '1' for function inet_aton6
mysql>
```
mysql>
### 4. What is your TiDB version? (Required)
```
mysql> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.4
Edition: Community
Git Commit Hash: e4e814fdc0afe9c3a6e5e96f129d83df802ab820
Git Branch: HEAD
UTC Build Time: 2025-11-26 15:53:39
GoVersion: go1.23.12
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.04 sec)
```

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.