SHOW INDEX on a sequence fails with SELECT command denied, even for root (v8.5.6+)

Open Beginner friendly
#72,792 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yahonda is already working on this.

Since Nov 6, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
databases, go, sql

Research direction

The issue identifies pkg/executor/show.go and fetchShowIndex as the affected code. Read that function and the privilege checks for SHOW INDEX, then reproduce the reported sequence case on TiDB v8.5.6 or later. Done means SHOW INDEX FROM s returns an empty result for a sequence, while privilege checks for tables with columns continue to work.

Written by the indexing model from the issue text.

Description

Bug Report

1. Minimal reproduce step (Required)

Start a TiDB v8.5.6 or later cluster (e.g. tiup playground v8.5.8) and run as root:

CREATE DATABASE t;
USE t;
CREATE SEQUENCE s;
SHOW INDEX FROM s;
2. What did you expect to see? (Required)

TiDB v8.5.5:

mysql> SHOW INDEX FROM s;
Empty set (0.002 sec)

MariaDB 13.0.2:

MariaDB> SHOW INDEX FROM s;
Empty set (0.000 sec)

An empty result set, as in TiDB v8.5.5 and earlier (v8.1.2, v8.2.0–v8.4.0, v8.5.0, v8.5.4, v8.5.5 were checked). MariaDB 13.0.2 also returns an empty result for SHOW INDEX FROM <sequence> to a user who has privileges on it, and an access-denied error only to a user without privileges.

3. What did you see instead (Required)
mysql> SHOW INDEX FROM s;
ERROR 1142 (42000): SELECT command denied to user 'root'@'%' for table 's'

A non-root user granted SELECT ON t.s gets the same error. SHOW COLUMNS FROM s and SHOW INDEX FROM <view> still return an empty result.

This appears to come from #66535 (backport of #61679), which changed fetchShowIndex in pkg/executor/show.go to pass the privilege check only if the user has a privilege on at least one of tb.VisibleCols(). A sequence has no columns, so the loop never runs, passCheck stays false, and every user, including root, is denied. master still checks table-level privileges and is not affected.

Impact: Rails' schema cache (activerecord-tidb-adapter) runs SHOW KEYS on every data source listed in information_schema.tables, including sequences. On v8.5.6+ this fails with the error above (worked around in pingcap/activerecord-tidb-adapter#75).

4. What is your TiDB version? (Required)
Release Version: v8.5.8
Edition: Community
Git Commit Hash: 8b857efa20363d50a8fa2ea7dd9809a85a61b115
Git Branch: HEAD
UTC Build Time: 2026-08-27 07:18:32
Store: tikv

First affected release: v8.5.6.

Dominant language
Go
Stars
40.7k
Forks
6.3k
Avg merge
2d 20h
Merged PRs (30d)
291

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pingcap/tidb

All issues in pingcap/tidb

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.