Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wbwxR-002yGN-1a for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 08:58:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbwxQ-00AiFw-0B for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jun 2026 08:58:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wbwxP-00AiFn-2L for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 08:58:11 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbwxM-00000001tUM-3Kc0 for pgsql-hackers@lists.postgresql.org; Tue, 23 Jun 2026 08:58:10 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-697b8540279so2481177a12.0 for ; Tue, 23 Jun 2026 01:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782205087; cv=none; d=google.com; s=arc-20240605; b=PHVx9eAEgLnyFkviEILmX330VtvquRN0RhG8Srm5QpE9VbVvOukx0vd8LEB8jMdjqI aCQb8hEehikIqlXer8Xo4sdDBZIs5CtTzaF08Gzs3a0xKIzL99pxTqVQrCO7+KP/gohV vD7U88AV+sdkXoi3WCvzpwz2FbYRwqQp2VlnpbH0ZNM5R4vYD6f8Dv8qk2YjzwFTGO3d YoeEHG5HLQqveob3wB0LkOYJosyrtnURaILPl1Dqk7oOgdgl/7qECuc0kQ40sZDNUfdk DQQnN0VUtW8K7JVzynjGabjblUvGKyqIfbUssXIoq20S2/E2DiBKWCLzs1+EGvCPRe4F K2Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=kPGnrQeOGMu+FrmrFArAq7mAYStkvUcNsM3FolyQR7s=; fh=MHMmcvdim3eqe6u1vueiwnBjjWedonQdQxgVMFLw9A8=; b=HoBALUkGuXlytvcfH5OwkEk5TdvdAmbX9LnFddCFVVZjzEcLC95KfPL+u79EzyKSL7 8kooArC4ZJm0HkRxkIq59AtNbhYWUkwwo2NjN3VeJNyStgfh8G49lNszodKj7cvJMBL7 UFi7ClySlc+AuLoIDCJz7UwTetmzmn8wgcdU244QGjOS56LdRlCKL/Q6/JYgpU8Ewrfy 7JuEoEykfpGkL5UpM+nhfXnzSHafYdg1c2049czbWP0jRnG8SzrxYtXpPaXnsGdqRYBF 2sbxKfVCHC7uRCsEA6GZUjmhCXaKDri+CBJ0p/IykMU6hU1J1tM44kCtc9Ycz8gYA4N4 KLsQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1782205087; x=1782809887; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=kPGnrQeOGMu+FrmrFArAq7mAYStkvUcNsM3FolyQR7s=; b=GTz8Qt5+s8CFT+3MMXvZy5OjFaUQiS3WlVL6Kevk8DmwTTGUCfm1OSMTgAqAjlw8N2 o9bSaZvznMbne4BqpPfeCBxdzMKWxYbMGioAnsFHFP3Vd7gailKRhQEksOIrSlDslTaF Ts4X2WVahfz9CyRSo/wi0HQHpvNX/3eBjjpaIDrmGj8sX02PnhbQzymmVYlpUswIGkTV CjynnSkUBj/Ol03pdf/YD2FHq5SGtBzw1fEmuSvi88kqfWJ01+1nRUPNwkD9AAJbdnZL 2SmxSIOllz23y1gqZZszyIXTn8/3EOmehuh0vSMd8aFUhJ3cIGptD3Yq932SofrWIAxz 8uow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782205087; x=1782809887; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kPGnrQeOGMu+FrmrFArAq7mAYStkvUcNsM3FolyQR7s=; b=bTO42ZlxWF79nE6AWdoYtnA++JwaO21q45Xl98kO7jFAVICvqrRq+n6FyY9Skw07H/ 0U9uE89MaStvHCR78qlF24GKEVB0jWIuN1pifmVOzTVvYJ0maGKfXi0SQNsnems+cxnw 5kE4zQnfIP0UdVw8ruKnxegBvv9SNXWUxbDLjY4vgeuMRsvzpbwh/KxLFDP6CvK03hGq DXhIbmi1I7LF6FUR2I6b17rrcJIZgbuEbPEQzTYD0IzICOb+AB5At17tBl1smWbOSuLY yS3I64+hTnbwZ8RaaQIG8MuadTdTLirqpMs/P5j5FImAKVtf2ibIJERXMLVfV3HdVGan jM1g== X-Forwarded-Encrypted: i=1; AFNElJ82qeq3UlPv4NrjQIKAhvrczDXC+7942pvcZSR0hGZ/kv9swuQRCVHbIOp3sKT8QtYJ+dzqhAQEMKggQDTM@lists.postgresql.org X-Gm-Message-State: AOJu0YzUz8oFoma+NkNtLZY6Gh3lYig3wyy7euM62nAAwv2+dCW+j2+l /avmUJbRyp7AyYFb1dZ/o3aPyWsN1XAOa2qU1kT11PZQuDGYungZf75MJhk1Dj2Lm88RptnPSdO ppzZ2ptSqa6mTuWyHRcnm5z0LszlqkugyU6DEcuYR X-Gm-Gg: AfdE7cnq1gx0xmhkzf3f44FwfXIfrXyP+SSw4kJjugSMaXmardXN2dgIviYgoa5RU4x agkV93clZcX64hZsXRDy+1i2PQNbhL8G/ByMFcVMo9mS8jaQ0koVpYWR4j8+nesvotdBdeWoaCw dbeJaAFVFaKp4ZiJ6yj19tsPHZSJk2NujKaJq8UL3y+Xni9Jg4iF8RLLWL79Ds/RIXnU9+2xHx+ wH6f08CwX+FucPsDLzf14gf0BNQJBbPZkvQ+/KOrp6xE88aK75l7fgxlrh8YwJAb2M+nAQ8Jw== X-Received: by 2002:a17:907:d501:b0:bfe:ed06:565f with SMTP id a640c23a62f3a-c10807aa9f8mr84664066b.52.1782205086910; Tue, 23 Jun 2026 01:58:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Akshay Joshi Date: Tue, 23 Jun 2026 14:27:54 +0530 X-Gm-Features: AVVi8CeNyoii0SJBkJcE4boru5a6G1FjH5AF7JRKnZWgwpfCEnm8dgeX0Pp9FYQ Message-ID: Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements To: Marcos Pegoraro Cc: Zsolt Parragi , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000001f5f9f0654e7f5f5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001f5f9f0654e7f5f5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 22, 2026 at 8:25=E2=80=AFPM Marcos Pegoraro = wrote: > Em seg., 22 de jun. de 2026 =C3=A0s 03:27, Akshay Joshi < > akshay.joshi@enterprisedb.com> escreveu: > >> The documentation paragraph for `includes_foreign_keys` now directs user= s >> to `only_foreign_keys` as the intended second pass. Regression coverage >> adds three cases: the FK-only emission for your cons example, the zero-r= ow >> result for a table without FKs, and the error path. >> >>> > I still think this model of only having options for foreign keys is > incomplete, maybe wrong. > Imagine then cloning a schema from a publication server to be executed on > a subscription server. So I don't want any other constraints besides the > primary key, for example. The way you implemented it is not possible. > > Furthermore having only_foreign_keys and includes_foreign_keys seems > confuse. > OK. I'd like to change the model, not just the flag names. Drop the entire *includes_** family and *only_foreign_keys*, replace them with two mutually-exclusive variadic keys: - include =3D> 'kind1,kind2,...' =E2=80=94 emit only these kinds - exclude =3D> 'kind1,kind2,...' =E2=80=94 emit everything except these Setting both is an error. Setting neither emits everything (today's default behavior, which is preserved). *Vocabulary*: indexes, primary_key, unique, check, foreign_keys, exclusion, rules, statistics, triggers, policies, rls, replica_identity, partitions. Unknown kind =E2=86=92 parse-time error, which also catches typos that the boolean version silently accepted. If everyone approves the model above, I'll try implementing it. regards > Marcos > > --0000000000001f5f9f0654e7f5f5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Jun 22,= 2026 at 8:25=E2=80=AFPM Marcos Pegoraro <marcos@f10.com.br> wrote:
Em seg., 22 de jun. de 2026 =C3=A0s 03:27= , Akshay Joshi <akshay.joshi@enterprisedb.com> escreveu:
The= documentation paragraph for `includes_foreign_keys` now directs users to `= only_foreign_keys` as the intended second pass. Regression coverage adds th= ree cases: the FK-only emission for your cons example, the zero-row result = for a table without FKs, and the error path.=C2=A0
<= /div>

Imagine then cloning= a schema from a publication server to be executed on a subscription server= . So I=C2=A0don't want any other co= nstraints besides the primary key, for example.=C2=A0The way you implemented it is not possible.

Furthermore=C2=A0having only_foreign_= keys and includes_foreign_keys seems confuse.=C2=A0

=C2=A0 =C2=A0OK.=C2=A0I'd like to change the model, not just the flag names. Drop the entir= e includes_* family and only_foreign_keys, replace them with = two mutually-exclusive variadic keys:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C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2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 Vocabulary: indexes, pr= imary_key, unique, check, foreign_keys, exclusion, rules, statistics, trigg= ers, policies, rls, replica_identity, partitions. Unknown kind =E2=86=92 pa= rse-time error, which also =C2=A0 =C2=A0 =C2=A0
=C2=A0 catches typos tha= t the boolean version silently accepted.

=C2=A0 If everyone approves= the model above, I'll try implementing it.=C2=A0

r= egards
Marcos

--0000000000001f5f9f0654e7f5f5--