Skip to content

Commit f397135

Browse files
committed
fix: show index from table in mysql
1 parent 40d16a4 commit f397135

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

pegjs/mariadb.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ show_stmt
15511551
}
15521552
}
15531553
}
1554-
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i) __ from:from_clause {
1554+
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i / "INDEX"i) __ from:from_clause {
15551555
return {
15561556
tableList: Array.from(tableList),
15571557
columnList: columnListTableAlias(columnList),

pegjs/mysql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ show_stmt
18401840
}
18411841
}
18421842
}
1843-
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i) __ from:from_clause {
1843+
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i / "INDEX"i) __ from:from_clause {
18441844
return {
18451845
tableList: Array.from(tableList),
18461846
columnList: columnListTableAlias(columnList),

src/show.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function showToSQL(showExpr) {
4343
break
4444
case 'COLUMNS':
4545
case 'INDEXES':
46+
case 'INDEX':
4647
str = commonOptionConnector('FROM', tablesToSQL, showExpr.from)
4748
break
4849
case 'GRANTS':

test/mysql-mariadb.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,13 @@ describe('mysql', () => {
935935
');',
936936
"CREATE TABLE `table` (`name` VARCHAR(255) CHECK (`name` LIKE 'ABC%' AND LENGTH(`name`) >= 5))"
937937
]
938+
},
939+
{
940+
title: 'show index',
941+
sql: [
942+
'show index from user',
943+
'SHOW INDEX FROM `user`'
944+
]
938945
}
939946
]
940947
SQL_LIST.forEach(sqlInfo => {

0 commit comments

Comments
 (0)