Skip to content

Commit aa4535b

Browse files
committed
fix(driver/mysql): add quotation marks for schema and table names in GetTableIndexesInfo
- Update the GetTableIndexesInfo function to add quotation marks around schema and table names - This change helps prevent potential errors when dealing with keywords or special characters in schema/table names
1 parent 42f6e52 commit aa4535b

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)