Skip to content

Commit

Permalink
[PG15] Restore missing space for ADD CONSTRAINT UNIQUE USING
Browse files Browse the repository at this point in the history
Summary:
Bad [[ yugabyte@7e541a1 | 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
  • Loading branch information
foucher committed Oct 23, 2023
1 parent 0732f80 commit f5398e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/postgres/src/bin/pg_dump/pg_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f5398e9

Please sign in to comment.