diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index bc20a025ce..c30eb95ce4 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -8740,7 +8740,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
 	appendPQExpBufferStr(q,
 						 "LEFT JOIN pg_catalog.pg_constraint copk ON "
 						 "(copk.conrelid = src.tbloid\n"
-						 "   AND copk.contype = 'p' AND "
+						 "   AND copk.contype = 'p' AND copk.condeferrable = false AND "
 						 "copk.conkey @> array[a.attnum])\n"
 						 "WHERE a.attnum > 0::pg_catalog.int2\n"
 						 "ORDER BY a.attrelid, a.attnum");
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 3912dbf481..43913e3476 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -3605,12 +3605,12 @@ my %tests = (
 	'CREATE TABLE test_table_generated' => {
 		create_order => 3,
 		create_sql => 'CREATE TABLE dump_test.test_table_generated (
-						   col1 int primary key,
+						   col1 int primary key deferrable,
 						   col2 int generated always as (col1 * 2) stored
 					   );',
 		regexp => qr/^
 			\QCREATE TABLE dump_test.test_table_generated (\E\n
-			\s+\Qcol1 integer CONSTRAINT \E[a-z0-9_]*\Q NOT NULL NO INHERIT,\E\n
+			\s+\Qcol1 integer,\E\n
 			\s+\Qcol2 integer GENERATED ALWAYS AS ((col1 * 2)) STORED\E\n
 			\);
 			/xms,
