Em seg., 15 de jun. de 2026 às 04:52, Akshay Joshi <
[email protected]> escreveu:

> I don't think per-contype flags are the right shape, though. The existing
> toggles group by catalog (indexes, constraints, rules, ...); splitting
> constraints into PK/FK/CHECK/UNIQUE/EXCLUDE/NOT NULL adds six flags on a
> second axis, and the function already carries nine. Only FKs have the
> cross-table dependency-ordering problem; the rest only reference the same
> table, so splitting them unlocks nothing new.
>

Ok, I understand your point. Initially, I saw the usefulness of this
function for cloning a schema, something very common in a multi-tenant
model. But creating the foreign keys along with the create table makes that
unfeasible.

Options are variadic, so you could split your emit_local_constraints into
+emit_local_foreign_keys_constraints(TableDdlContext * ctx)
+ if (!(ctx->include_constraints || ctx->include_foreign_keys)) then
+   return

+emit_local_primary_keys_constraints(TableDdlContext * ctx)
+ if (!(ctx->include_constraints || ctx->include_primary_keys)) then
+   return

pg_get_table_ddl('x','includes_constraints','true') -- would print all
constraints
pg_get_table_ddl('x','include_primary_keys','true') -- would print only
primary key constraints

regards
Marcos

Reply via email to