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
WIP
  • Loading branch information
Dmitry committed Apr 26, 2023
commit a7f0a8e2d30f9f67b4fa1f74c217b784ddbcc3c5
6 changes: 3 additions & 3 deletions internal/handlers/pg/pgdb/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func CalculateDBStats(ctx context.Context, tx pgx.Tx, db string) (*DBStats, erro
SUM(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename)))
FROM pg_tables
WHERE schemaname = $1`
args := []any{pgx.Identifier{db}.Sanitize()}
args := []any{db}
row := tx.QueryRow(ctx, sql, args...)

var schemaSize *int32
Expand All @@ -116,10 +116,10 @@ func CalculateDBStats(ctx context.Context, tx pgx.Tx, db string) (*DBStats, erro
COALESCE(SUM(pg_table_size(c.oid)), 0) AS SizeTables,
COALESCE(SUM(pg_indexes_size(c.oid)), 0) AS SizeIndexes
FROM pg_tables AS t
LEFT JOIN pg_class AS c ON c.relname = t.tablename AND c.relnamespace = t.schemaname::regnamespace
LEFT JOIN pg_class AS c ON c.relname = t.tablename AND c.relnamespace = quote_ident(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{pgx.Identifier{db}.Sanitize(), reservedPrefix + "%"}
args = []any{db, reservedPrefix + "%"}

row = tx.QueryRow(ctx, sql, args...)
if err := row.Scan(
Expand Down