Skip to content

Commit 5423853

Browse files
committed
Avoid retrieval of CHECK constraints and DEFAULT exprs in data-only dump
Those extra queries are not necessary when doing a data-only dump. With this change, this means that the dependencies between CHECK/DEFAULT and the parent table are not tracked anymore for a data-only dump. However, these dependencies are only used for the schema generation and we have never guaranteed that a dump can be reloaded if a CHECK constraint uses a custom function whose behavior changes when loading the data, like when using cross-table references in the CHECK function. Author: Julien Rouhaud Reviewed-by: Daniel Gustafsson, Michael Paquier Discussion: https://postgr.es/m/20200712054850.GA92357@nol
1 parent c8aeaf3 commit 5423853

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8644,9 +8644,10 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
86448644
PQclear(res);
86458645

86468646
/*
8647-
* Get info about column defaults
8647+
* Get info about column defaults. This is skipped for a data-only
8648+
* dump, as it is only needed for table schemas.
86488649
*/
8649-
if (hasdefaults)
8650+
if (!dopt->dataOnly && hasdefaults)
86508651
{
86518652
AttrDefInfo *attrdefs;
86528653
int numDefaults;
@@ -8731,9 +8732,10 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
87318732
}
87328733

87338734
/*
8734-
* Get info about table CHECK constraints
8735+
* Get info about table CHECK constraints. This is skipped for a
8736+
* data-only dump, as it is only needed for table schemas.
87358737
*/
8736-
if (tbinfo->ncheck > 0)
8738+
if (!dopt->dataOnly && tbinfo->ncheck > 0)
87378739
{
87388740
ConstraintInfo *constrs;
87398741
int numConstrs;

0 commit comments

Comments
 (0)