dolthub / dolthub/dolt

`DESCRIBE <table>` should read indexes in order that they were defined

Open
#7,932 0 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
correctness good repro sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

`DESCRIBE` queries over tables that do not have `primary keys` mark the columns that have `NOT NULL` constraint and are part of the first unique key/index as `PRI`. However, dolt treats first index as in first in lexicographic order, while MySQL treats it as first index made.

dolt:
```sql
tmp/main> create table t (i int not null, j int not null, unique key (j), unique key(i));
tmp/main*> describe t;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| i | int | NO | PRI | NULL | |
| j | int | NO | UNI | NULL | |
+-------+------+------+-----+---------+-------+
2 rows in set (0.00 sec)
```

mysql:
```sql
mysql> create table t (i int not null, j int not null, unique key (j), unique key(i));
Query OK, 0 rows affected (0.0315 sec)
mysql> describe t;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| i | int | NO | UNI | NULL | |
| j | int | NO | PRI | NULL | |
+-------+------+------+-----+---------+-------+
2 rows in set (0.0016 sec)
```

Skipped test here: https://github.com/dolthub/go-mysql-server/pull/2467/files#diff-a2fc9c77f73a02bb06e3742498bfffe92aa39331918f0f396f0150fbbce3c2adR3181

related: https://github.com/dolthub/dolt/issues/2289

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.