Skip to content

Commit 926af1f

Browse files
authored
Merge pull request #2976 from actiontech/2287
fix(driver/mysql): add backticks around schema and table names in GetTableIndexesInfo
2 parents 993c991 + aa4535b commit 926af1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqle/driver/mysql/executor/executor.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
driverV2 "github.com/actiontech/sqle/sqle/driver/v2"
1414
"github.com/actiontech/sqle/sqle/errors"
15+
"github.com/actiontech/sqle/sqle/utils"
1516
"github.com/go-sql-driver/mysql"
1617
"github.com/sirupsen/logrus"
1718
)
@@ -786,7 +787,10 @@ type TableIndexesInfo struct {
786787

787788
// When using keywords as view names, you need to pay attention to wrapping them in quotation marks
788789
func (c *Executor) GetTableIndexesInfo(schema, tableName string) ([]*TableIndexesInfo, error) {
789-
records, err := c.Db.Query(fmt.Sprintf("SHOW INDEX FROM %s.%s", schema, tableName))
790+
records, err := c.Db.Query(fmt.Sprintf("SHOW INDEX FROM %s.%s",
791+
utils.SupplementalQuotationMarks(schema),
792+
utils.SupplementalQuotationMarks(tableName),
793+
))
790794
if err != nil {
791795
return nil, err
792796
}

0 commit comments

Comments
 (0)