-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
When doing a schema dump on tables with EXCLUDE USING gist constraints, the constraint is incorrectly converted to a regular CREATE INDEX statement, losing the exclusion semantics.
Repro SQL code
CREATE SCHEMA test;
CREATE TABLE test.test_table (
id int PRIMARY KEY,
org_id uuid NOT NULL,
start_time timestamptz NOT NULL,
end_time timestamptz NOT NULL,
CONSTRAINT excl_no_overlap EXCLUDE USING gist (
org_id WITH =,
tstzrange(start_time, end_time, '[)') WITH &&
)
);Dump schema
pgschema dump --schema test
Expected output
CREATE TABLE IF NOT EXISTS test_table (
id integer NOT NULL,
org_id uuid NOT NULL,
start_time timestamptz NOT NULL,
end_time timestamptz NOT NULL,
CONSTRAINT test_table_pkey PRIMARY KEY (id),
CONSTRAINT excl_no_overlap EXCLUDE USING gist (org_id WITH =, tstzrange(start_time, end_time, '[)'::text) WITH &&)
);Actual output
CREATE TABLE IF NOT EXISTS test_table (
id integer NOT NULL,
org_id uuid NOT NULL,
start_time timestamptz NOT NULL,
end_time timestamptz NOT NULL,
CONSTRAINT test_table_pkey PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS excl_no_overlap ON test_table USING gist (org_id, tstzrange(start_time, end_time, '[)'::text));The EXCLUDE constraint is converted to a regular gist INDEX, which:
- Loses the
WITH =andWITH &&operators that define the exclusion behavior - Moves the constraint outside the table definition
Environment
- PostgreSQL 18.1
- pgschema v1.6.2
Reactions are currently unavailable