From f5398e9cfe75bd4d7859ecfc5fb8c0025c7baeb8 Mon Sep 17 00:00:00 2001 From: Trevor Foucher Date: Thu, 19 Oct 2023 12:23:25 -0700 Subject: [PATCH] [PG15] Restore missing space for ADD CONSTRAINT UNIQUE USING Summary: Bad [[ https://github.com/yugabyte/yugabyte-db/commit/7e541a1191bcc17ed75bb4c9865edc89c55782d0 | merge ]]. The master branch [[ https://github.com/yugabyte/yugabyte-db/blob/1a28aadaae5c5fdb11e24256fcc68ec00ca04051/src/postgres/src/bin/pg_dump/pg_dump.c#L17141 | contains this space]]. When this space isn't generated, `ysql_dump` generates output that says `UNIQUEUSING`, which is not valid SQL, instead of `UNIQUE USING`. Here is what the broken behavior looks like in context. ``` ALTER TABLE ONLY public.p1 ADD CONSTRAINT c1 UNIQUEUSING INDEX c1; ``` Test Plan: In `ysqlsh`: ``` CREATE TABLE p1 (k INT PRIMARY KEY, v TEXT); CREATE UNIQUE INDEX c1 ON p1 (v ASC) SPLIT AT VALUES (('foo'), ('qux')); ALTER TABLE p1 ADD UNIQUE USING INDEX c1; ``` Then: ``` build/latest/postgres/bin/ysql_dump --include-yb-metadata ``` Reviewers: jason Reviewed By: jason Subscribers: smishra, yql Differential Revision: https://phorge.dev.yugabyte.com/D29536 --- src/postgres/src/bin/pg_dump/pg_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postgres/src/bin/pg_dump/pg_dump.c b/src/postgres/src/bin/pg_dump/pg_dump.c index 0a38b9edbacb..2c8a8b09d0dd 100644 --- a/src/postgres/src/bin/pg_dump/pg_dump.c +++ b/src/postgres/src/bin/pg_dump/pg_dump.c @@ -16917,7 +16917,7 @@ dumpConstraint(Archive *fout, const ConstraintInfo *coninfo) } else { - appendPQExpBuffer(q, "%s", + appendPQExpBuffer(q, "%s ", coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE"); /* * If a table has an unique constraint with index definition,