diff --git a/src/postgres_deparse.c b/src/postgres_deparse.c index 8687a9d3..c24533cc 100644 --- a/src/postgres_deparse.c +++ b/src/postgres_deparse.c @@ -4593,7 +4593,7 @@ static void deparseConstraint(StringInfo str, Constraint *constraint) if (constraint->conname != NULL) { appendStringInfoString(str, "CONSTRAINT "); - appendStringInfoString(str, constraint->conname); + appendStringInfoString(str, quote_identifier(constraint->conname)); appendStringInfoChar(str, ' '); } diff --git a/test/deparse_tests.c b/test/deparse_tests.c index 3c203615..106f2349 100644 --- a/test/deparse_tests.c +++ b/test/deparse_tests.c @@ -392,6 +392,7 @@ const char* tests[] = { "CREATE INDEX \"foo.index\" ON foo USING btree (bar)", "CREATE TABLE distributors (did int, name varchar(40), UNIQUE (name) WITH (fillfactor=70)) WITH (fillfactor=70)", "SHOW ALL", + "ALTER TABLE ONLY public.\"Test 123\" ADD CONSTRAINT \"Test 123_pkey\" PRIMARY KEY (c1)", }; size_t testsLength = __LINE__ - 4;