Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORDINAL_POSITION from information_schema.columns is incorrect when filtering #43379

Closed
kolbe opened this issue Apr 24, 2023 · 1 comment · Fixed by #43491
Closed

ORDINAL_POSITION from information_schema.columns is incorrect when filtering #43379

kolbe opened this issue Apr 24, 2023 · 1 comment · Fixed by #43491
Assignees
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@kolbe
Copy link
Contributor

kolbe commented Apr 24, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t1 (a int, b int, c int);
select column_name, ordinal_position from information_schema.columns where table_schema=database() and table_name='t1' and column_name='c';

2. What did you expect to see? (Required)

select ordinal_position from information_schema.columns where /* ... */ column_name='c' should show 3 because this is the 3rd column in the table. However, filtering using a WHERE clause seems to reset the ordinal_position counter so that it refers to the position in the resultset?

3. What did you see instead (Required)

MySQL [test]> create table t1 (a int, b int, c int);
seQuery OK, 0 rows affected (0.54 sec)

MySQL [test]> select column_name, ordinal_position from information_schema.columns where table_schema=database() and table_name='t1';
+-------------+------------------+
| column_name | ordinal_position |
+-------------+------------------+
| a | 1 |
| b | 2 |
| c | 3 |
+-------------+------------------+
3 rows in set (0.00 sec)

MySQL [test]> select column_name, ordinal_position from information_schema.columns where table_schema=database() and table_name='t1' and column_name='c';
+-------------+------------------+
| column_name | ordinal_position |
+-------------+------------------+
| c | 1 |
+-------------+------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

MySQL [test]> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v7.0.0
Edition: Community
Git Commit Hash: 8783269d3d97f3fd1858c083170eacaf7b732bcd
Git Branch: HEAD
UTC Build Time: 2023-04-12 18:44:47
GoVersion: go1.20
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
@kolbe kolbe added the type/bug The issue is confirmed as a bug. label Apr 24, 2023
@bb7133
Copy link
Member

bb7133 commented Apr 27, 2023

This bug was introduced by #37419, I will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants