Skip to content

Commit

Permalink
Merge pull request #1793 from taozhi8833998/fix-show-index-mysql
Browse files Browse the repository at this point in the history
fix: show index from table in mysql
  • Loading branch information
taozhi8833998 authored Feb 9, 2024
2 parents 65801c2 + f397135 commit ad72a35
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pegjs/mariadb.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ show_stmt
}
}
}
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i) __ from:from_clause {
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i / "INDEX"i) __ from:from_clause {
return {
tableList: Array.from(tableList),
columnList: columnListTableAlias(columnList),
Expand Down
2 changes: 1 addition & 1 deletion pegjs/mysql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ show_stmt
}
}
}
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i) __ from:from_clause {
/ KW_SHOW __ keyword:('COLUMNS'i / 'INDEXES'i / "INDEX"i) __ from:from_clause {
return {
tableList: Array.from(tableList),
columnList: columnListTableAlias(columnList),
Expand Down
1 change: 1 addition & 0 deletions src/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function showToSQL(showExpr) {
break
case 'COLUMNS':
case 'INDEXES':
case 'INDEX':
str = commonOptionConnector('FROM', tablesToSQL, showExpr.from)
break
case 'GRANTS':
Expand Down
7 changes: 7 additions & 0 deletions test/mysql-mariadb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,13 @@ describe('mysql', () => {
');',
"CREATE TABLE `table` (`name` VARCHAR(255) CHECK (`name` LIKE 'ABC%' AND LENGTH(`name`) >= 5))"
]
},
{
title: 'show index',
sql: [
'show index from user',
'SHOW INDEX FROM `user`'
]
}
]
SQL_LIST.forEach(sqlInfo => {
Expand Down

0 comments on commit ad72a35

Please sign in to comment.