Skip to content

dump omits non-default column collations #593

Description

@milalintabach

Summary

pgschema dump omits a column's explicitly configured non-default collation.
This changes the semantics of a schema recreated from the dump, including the
collation inherited by indexes on that column.

Reproduction

CREATE SCHEMA collation_repro;

CREATE TABLE collation_repro.recipient_search (
    id bigint PRIMARY KEY,
    search_text text COLLATE "C" NOT NULL
);

CREATE INDEX recipient_search_prefix_idx
    ON collation_repro.recipient_search (search_text text_pattern_ops);
pgschema dump --schema collation_repro --no-comments

Actual output

CREATE TABLE IF NOT EXISTS recipient_search (
    id bigint,
    search_text text NOT NULL,
    CONSTRAINT recipient_search_pkey PRIMARY KEY (id)
);

CREATE INDEX IF NOT EXISTS recipient_search_prefix_idx
    ON recipient_search (search_text text_pattern_ops);

Expected output

The table declaration should preserve the explicit collation:

CREATE TABLE IF NOT EXISTS recipient_search (
    id bigint,
    search_text text COLLATE "C" NOT NULL,
    CONSTRAINT recipient_search_pkey PRIMARY KEY (id)
);

The index can continue to inherit the column collation once the column
declaration is preserved.

Impact

Applying the generated dump on a database whose default collation is not C
recreates the column and its index with a different collation. That can change
ordering and prefix-search behavior, so the generated schema is not a faithful
round trip.

Environment

  • pgschema 1.13.0 (current latest release)
  • PostgreSQL 18.4
  • macOS arm64 pgschema release binary

I also searched the existing open and closed issues for a collation report and
did not find one covering this behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions