Skip to content

Commit a802109

Browse files
Fix database quoting problem in collector 'info_schema.tables' (#908)
Signed-off-by: Jason Ng <[email protected]> Co-authored-by: Cristian Greco <[email protected]>
1 parent 770a3ff commit a802109

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

collector/info_schema_tables.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package collector
1717

1818
import (
1919
"context"
20-
"fmt"
2120
"log/slog"
2221
"strings"
2322

@@ -40,7 +39,7 @@ const (
4039
ifnull(DATA_FREE, '0') as DATA_FREE,
4140
ifnull(CREATE_OPTIONS, 'NONE') as CREATE_OPTIONS
4241
FROM information_schema.tables
43-
WHERE TABLE_SCHEMA = '%s'
42+
WHERE TABLE_SCHEMA = ?
4443
`
4544
dbListQuery = `
4645
SELECT
@@ -121,7 +120,7 @@ func (ScrapeTableSchema) Scrape(ctx context.Context, instance *instance, ch chan
121120
}
122121

123122
for _, database := range dbList {
124-
tableSchemaRows, err := db.QueryContext(ctx, fmt.Sprintf(tableSchemaQuery, database))
123+
tableSchemaRows, err := db.QueryContext(ctx, tableSchemaQuery, database)
125124
if err != nil {
126125
return err
127126
}

0 commit comments

Comments
 (0)