Hi,
Currently, getTableAttrs() always retrieves info about columns defaults and
check constraints, while this will never be used if --data-only option if used.
This seems like a waste of resources, so here's a patch to skip those parts
when the DDL won't be generated.
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e758b5c50a..e4ea604dfe 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -8590,7 +8590,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int
numTables)
/*
* Get info about column defaults
*/
- if (hasdefaults)
+ if (!dopt->dataOnly && hasdefaults)
{
AttrDefInfo *attrdefs;
int numDefaults;
@@ -8677,7 +8677,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int
numTables)
/*
* Get info about table CHECK constraints
*/
- if (tbinfo->ncheck > 0)
+ if (!dopt->dataOnly && tbinfo->ncheck > 0)
{
ConstraintInfo *constrs;
int numConstrs;