From 2595ab7d79a6a9f1a034c0b8e4df7a7c6c0d9bfd Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Thu, 16 Jan 2025 02:08:43 +0800 Subject: [PATCH] Fix database quoting problem in collector 'info_schema.tables' Signed-off-by: Jason Ng --- collector/info_schema_tables.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/collector/info_schema_tables.go b/collector/info_schema_tables.go index bb97a59f..e026436d 100644 --- a/collector/info_schema_tables.go +++ b/collector/info_schema_tables.go @@ -17,7 +17,6 @@ package collector import ( "context" - "fmt" "log/slog" "strings" @@ -40,7 +39,7 @@ const ( ifnull(DATA_FREE, '0') as DATA_FREE, ifnull(CREATE_OPTIONS, 'NONE') as CREATE_OPTIONS FROM information_schema.tables - WHERE TABLE_SCHEMA = '%s' + WHERE TABLE_SCHEMA = ? ` dbListQuery = ` SELECT @@ -121,7 +120,7 @@ func (ScrapeTableSchema) Scrape(ctx context.Context, instance *instance, ch chan } for _, database := range dbList { - tableSchemaRows, err := db.QueryContext(ctx, fmt.Sprintf(tableSchemaQuery, database)) + tableSchemaRows, err := db.QueryContext(ctx, tableSchemaQuery, database) if err != nil { return err }