Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow database name contain uppercase characters #2504

Merged
merged 15 commits into from
Apr 26, 2023
Prev Previous commit
Next Next commit
sanitize more db names
  • Loading branch information
syasyayas committed Apr 25, 2023
commit c6eb55578e3fd7f84c7e5b61114089414ec19f77
4 changes: 2 additions & 2 deletions internal/handlers/pg/pgdb/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func CalculateDBStats(ctx context.Context, tx pgx.Tx, db string) (*DBStats, erro
LEFT JOIN pg_class AS c ON c.relname = t.tablename AND c.relnamespace = t.schemaname::regnamespace
LEFT JOIN pg_indexes AS i ON i.schemaname = t.schemaname AND i.tablename = t.tablename
WHERE t.schemaname = $1 AND t.tablename NOT LIKE $2`
args = []any{db, reservedPrefix + "%"}
args = []any{pgx.Identifier{db}.Sanitize(), reservedPrefix + "%"}

row = tx.QueryRow(ctx, sql, args...)
if err := row.Scan(
Expand Down Expand Up @@ -175,7 +175,7 @@ func CalculateCollStats(ctx context.Context, tx pgx.Tx, db, collection string) (
SELECT COUNT(indexname)
FROM pg_indexes
WHERE schemaname = $1 AND tablename = $2`
args := []any{db, metadata.table}
args := []any{pgx.Identifier{db}.Sanitize(), metadata.table}
row = tx.QueryRow(ctx, sql, args...)

if err := row.Scan(&res.CountIndexes); err != nil {
Expand Down