Skip to content

Commit

Permalink
executor: fix the wrong ORDINAL_POSTITION in columns view (#43491)
Browse files Browse the repository at this point in the history
close #43379
  • Loading branch information
bb7133 authored May 3, 2023
1 parent 275696a commit 7eff8ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,13 @@ func (e *hugeMemTableRetriever) dataForColumnsInTable(ctx context.Context, sctx
}
}
}
i := 1
i := 0
ForColumnsTag:
for _, col := range tbl.Columns {
if col.Hidden {
continue
}

i++
ft := &(col.FieldType)
if tbl.IsView() {
e.viewMu.RLock()
Expand Down Expand Up @@ -1018,7 +1018,6 @@ ForColumnsTag:
col.GeneratedExprString, // GENERATION_EXPRESSION
)
e.rows = append(e.rows, record)
i++
}
}

Expand Down
4 changes: 4 additions & 0 deletions executor/infoschema_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func TestColumnsTables(t *testing.T) {
tk.MustExec("CREATE TABLE t (`COL3` bit(1) NOT NULL,b year) ;")
tk.MustQuery("select column_type from information_schema.columns where TABLE_SCHEMA = 'test' and TABLE_NAME = 't';").
Check(testkit.Rows("bit(1)", "year(4)"))

// For issue: https://github.com/pingcap/tidb/issues/43379
tk.MustQuery("select ordinal_position from information_schema.columns where table_schema=database() and table_name='t' and column_name='b'").
Check(testkit.Rows("2"))
}

func TestEngines(t *testing.T) {
Expand Down

0 comments on commit 7eff8ce

Please sign in to comment.