pingcap / pingcap/tidb

DDL: add vector index column cause error vector has 0 dimensions, does not fit VECTOR(x)

Open
#62,071 1 comment 0 reactions 1 assignee Claimed by @breezewish View on GitHub
affects-8.5 affects-9.0 severity/moderate sig/vector 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)

```
TiDB root@localhost:test> CREATE TABLE foo2 (
-> id INT PRIMARY KEY
-> );
->
Query OK, 0 rows affected
Time: 0.067s
TiDB root@localhost:test> insert into foo2 (id) values (1);
Query OK, 1 row affected
Time: 0.008s
TiDB root@localhost:test> insert into foo2 (id) values (2);
Query OK, 1 row affected
Time: 0.004s
TiDB root@localhost:test> insert into foo2 (id) values (3);
Query OK, 1 row affected
Time: 0.005s
TiDB root@localhost:test> alter table foo2 add column e1 VECTOR(3) NOT NULL;
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
Query OK, 0 rows affected
Time: 0.164s
TiDB root@localhost:test> insert into foo2 (id, e1) values (4, '[1,2,3]');
Query OK, 1 row affected
Time: 0.005s
TiDB root@localhost:test> select * from foo2;
(1105, 'vector has 0 dimensions, does not fit VECTOR(3)')
```

### 2. What did you expect to see? (Required)
Return the result with default vector filled.

### 3. What did you see instead (Required)
```
(1105, 'vector has 0 dimensions, does not fit VECTOR(3)')
```
BTW. In TiDB version v7.5, it will return empty result.

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

```
TiDB root@localhost:test> select tidb_version();
+-----------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------+
| Release Version: v8.5.2 |
| Edition: Community |
| Git Commit Hash: f43a13324440f92209e2a9f04c0bbe9cf763978d |
| Git Branch: HEAD |
| UTC Build Time: 2025-05-29 03:30:55 |
| GoVersion: go1.23.8 |
| Race Enabled: false |
| Check Table Before Drop: false |
| Store: tikv |
+-----------------------------------------------------------+

1 row in set
Time: 0.005s
```

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.