Skip to content

Conversation

@dverite
Copy link
Collaborator

@dverite dverite commented Dec 16, 2025

When table names contain special characters that require identifiers to be quoted, the code was not quoting properly.

In particular:

  • calling Sprintf("%s.%s") with unquoted table and schema names is not safe to build SQL statements. pgx.Identifier.Sanitize() is used instead.

  • Casting to regclass to convert OID to names is too complicated because it can produce quoted or unquoted names depending on the context. Use pg_class and pg_namespace instead.

  • Casting to regclass to convert names to OID depends on the search_path, and also requires pre-quoting, which makes it difficult to use properly with user-supplied arguments. Use pg_class and pg_namespace instead.

When table names contain special characters that require identifiers
to be quoted, the code was not quoting properly.

In particular:

- calling Sprintf("%s.%s") with unquoted table and schema names is not safe to
build SQL statements. pgx.Identifier.Sanitize() is used instead.

- Casting to regclass to convert OID to names is too complicated because
it can produce quoted or unquoted names depending on the context.
Use pg_class and pg_namespace instead.

- Casting to regclass to convert names to OID depends on the search_path,
and also requires pre-quoting, which makes it difficult to use
properly with user-supplied arguments. Use pg_class and pg_namespace
instead.

Signed-off-by: Daniel Vérité <dverite@gmail.com>
@github-actions
Copy link

Code Coverage

Package Line Rate Health
github.com/qonto/postgresql-partition-manager/cmd 50%
github.com/qonto/postgresql-partition-manager/cmd/run 70%
github.com/qonto/postgresql-partition-manager/cmd/validate 65%
github.com/qonto/postgresql-partition-manager/internal/infra/config 71%
github.com/qonto/postgresql-partition-manager/internal/infra/logger 100%
github.com/qonto/postgresql-partition-manager/internal/infra/partition 78%
github.com/qonto/postgresql-partition-manager/internal/infra/postgresql 91%
github.com/qonto/postgresql-partition-manager/internal/infra/retry 100%
github.com/qonto/postgresql-partition-manager/internal/infra/uuid7 91%
github.com/qonto/postgresql-partition-manager 100%
github.com/qonto/postgresql-partition-manager/pkg/ppm 70%
github.com/qonto/postgresql-partition-manager/pkg/ppm/mocks 36%
Summary 70% (1056 / 1507)

@dverite
Copy link
Collaborator Author

dverite commented Dec 18, 2025

#storage

Copy link
Contributor

@qfritz qfritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dverite dverite merged commit 13b6c18 into main Dec 18, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants