diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml
index 2ca423c..ccff611 100644
--- a/doc/src/sgml/mvcc.sgml
+++ b/doc/src/sgml/mvcc.sgml
@@ -865,7 +865,7 @@ ERROR:  could not serialize access due to read/write dependencies among transact
         <para>
          Acquired by <command>VACUUM</command> (without <option>FULL</option>),
          <command>ANALYZE</>, <command>CREATE INDEX CONCURRENTLY</>, and
-         some forms of <command>ALTER TABLE</command>.
+         <command>ALTER TABLE VALIDATE</command>.
         </para>
        </listitem>
       </varlistentry>
@@ -906,8 +906,8 @@ ERROR:  could not serialize access due to read/write dependencies among transact
         </para>
 
         <para>
-         This lock mode is not automatically acquired by any
-         <productname>PostgreSQL</productname> command.
+         Acquired by <command>ALTER TABLE</> for subcommand types that
+         affect write operations and by <command>CREATE TRIGGER</>.
         </para>
        </listitem>
       </varlistentry>
@@ -951,7 +951,7 @@ ERROR:  could not serialize access due to read/write dependencies among transact
         </para>
 
         <para>
-         Acquired by the <command>ALTER TABLE</>, <command>DROP TABLE</>,
+         Acquired by the <command>ALTER TABLE</> for rewriting, <command>DROP TABLE</>,
          <command>TRUNCATE</command>, <command>REINDEX</command>,
          <command>CLUSTER</command>, and <command>VACUUM FULL</command>
          commands.
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 2b02e66..5fd118f 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -84,7 +84,10 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
 
   <para>
    <command>ALTER TABLE</command> changes the definition of an existing table.
-   There are several subforms:
+   There are several subforms described below. Note that the lock level required
+   differs for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is held
+   unless explicitly noted. When multiple subcommands are listed, the lock
+   held will be the strictest one required from any subcommand.
 
   <variablelist>
    <varlistentry>
@@ -153,6 +156,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       or <command>UPDATE</> commands; they do not cause rows already in the
       table to change.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -181,6 +187,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       <productname>PostgreSQL</productname> query planner, refer to
       <xref linkend="planner-stats">.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -213,6 +222,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       of statistics by the <productname>PostgreSQL</productname> query
       planner, refer to <xref linkend="planner-stats">.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -264,6 +276,12 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       the table, until it is validated by using the <literal>VALIDATE
       CONSTRAINT</literal> option.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock
+      on the table being altered. If the constraint is a foreign key then
+      a <literal>SHARE UPDATE EXCLUSIVE</literal> lock is also required on
+      the table referenced by the constraint.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -325,6 +343,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       This form alters the attributes of a constraint that was previously
       created. Currently only foreign key constraints may be altered.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -338,11 +359,17 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       Nothing happens if the constraint is already marked valid.
      </para>
      <para>
-      Validation can be a long process on larger tables and currently requires
-      an <literal>ACCESS EXCLUSIVE</literal> lock.  The value of separating
+      Validation can be a long process on larger tables. The value of separating
       validation from initial creation is that you can defer validation to less
       busy times, or can be used to give additional time to correct pre-existing
-      errors while preventing new errors.
+      errors while preventing new errors. Note also that validation on its own
+      does not prevent normal write commands against the table while it runs.
+     </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock
+      on the table being altered. If the constraint is a foreign key then
+      a <literal>ROW SHARE</literal> lock is also required on
+      the table referenced by the constraint.
      </para>
     </listitem>
    </varlistentry>
@@ -383,6 +410,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       mode, and triggers configured as <literal>ENABLE ALWAYS</literal> will
       fire regardless of the current replication mode.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -408,6 +438,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       <xref linkend="SQL-CLUSTER">
       operations.  It does not actually re-cluster the table.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -420,6 +453,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       index specification from the table.  This affects
       future cluster operations that don't specify an index.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -467,6 +503,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       FULL</>, <xref linkend="SQL-CLUSTER"> or one of the forms
       of <command>ALTER TABLE</> that forces a table rewrite.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock.
+     </para>
 
      <note>
       <para>
@@ -489,6 +528,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       defaults.  As with <literal>SET</>, a table rewrite might be
       needed to update the table entirely.
      </para>
+     <para>
+      This form requires only a <literal>SHARE ROW EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -517,6 +559,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       <literal>FOREIGN KEY</literal> constraints are not considered, but
       this might change in the future.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -529,6 +574,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       Queries against the parent table will no longer include records drawn
       from the target table.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -544,6 +592,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
       that <command>CREATE TABLE OF</> would permit an equivalent table
       definition.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -553,6 +604,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
      <para>
       This form dissociates a typed table from its type.
      </para>
+     <para>
+      This form requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock.
+     </para>
     </listitem>
    </varlistentry>
 
@@ -1075,6 +1129,14 @@ ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES
   </para>
 
   <para>
+   To add a foreign key constraint to a table minimising impact on other work:
+<programlisting>
+ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address) NOT VALID;
+ALTER TABLE distributors VALIDATE CONSTRAINT distfk;
+</programlisting>
+  </para>
+
+  <para>
    To add a (multicolumn) unique constraint to a table:
 <programlisting>
 ALTER TABLE distributors ADD CONSTRAINT dist_id_zipcode_key UNIQUE (dist_id, zipcode);
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index f044280..90f1794 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -27,6 +27,7 @@
 #include "catalog/toasting.h"
 #include "miscadmin.h"
 #include "nodes/makefuncs.h"
+#include "storage/lock.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
@@ -35,7 +36,7 @@
 Oid			binary_upgrade_next_toast_pg_type_oid = InvalidOid;
 
 static bool create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
-				   Datum reloptions);
+				   Datum reloptions, LOCKMODE lockmode);
 static bool needs_toast_table(Relation rel);
 
 
@@ -52,7 +53,7 @@ static bool needs_toast_table(Relation rel);
  * to end with CommandCounterIncrement if it makes any changes.
  */
 void
-AlterTableCreateToastTable(Oid relOid, Datum reloptions)
+AlterTableCreateToastTable(Oid relOid, Datum reloptions, LOCKMODE lockmode)
 {
 	Relation	rel;
 
@@ -63,10 +64,10 @@ AlterTableCreateToastTable(Oid relOid, Datum reloptions)
 	 * concurrent readers of the pg_class tuple won't have visibility issues,
 	 * so let's be safe.
 	 */
-	rel = heap_open(relOid, AccessExclusiveLock);
+	rel = heap_open(relOid, lockmode);
 
 	/* create_toast_table does all the work */
-	(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions);
+	(void) create_toast_table(rel, InvalidOid, InvalidOid, reloptions, lockmode);
 
 	heap_close(rel, NoLock);
 }
@@ -91,7 +92,8 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
 						relName)));
 
 	/* create_toast_table does all the work */
-	if (!create_toast_table(rel, toastOid, toastIndexOid, (Datum) 0))
+	if (!create_toast_table(rel, toastOid, toastIndexOid, (Datum) 0,
+							AccessExclusiveLock))
 		elog(ERROR, "\"%s\" does not require a toast table",
 			 relName);
 
@@ -107,7 +109,8 @@ BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
  * bootstrap they can be nonzero to specify hand-assigned OIDs
  */
 static bool
-create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptions)
+create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
+				   Datum reloptions, LOCKMODE lockmode)
 {
 	Oid			relOid = RelationGetRelid(rel);
 	HeapTuple	reltup;
@@ -161,6 +164,14 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
 		return false;
 
 	/*
+	 * We need to create a toast table. We shouldn't
+	 * have got this far if we're in ALTER TABLE unless
+	 * we are holding AccessExclusiveLock.
+	 */
+	if (lockmode < AccessExclusiveLock)
+		elog(ERROR, "AccessExclusiveLock required to add toast tables.");
+
+	/*
 	 * Create the toast table and its index
 	 */
 	snprintf(toast_relname, sizeof(toast_relname),
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 8b18e4a..bbe87ae 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -714,7 +714,11 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, bool forcetemp,
 		if (isNull)
 			reloptions = (Datum) 0;
 
-		AlterTableCreateToastTable(OIDNewHeap, reloptions);
+		/*
+		 * Adding a toast table means we must have an AccessExclusiveLock,
+		 * which we need to have acquired before we examine the table.
+		 */
+		AlterTableCreateToastTable(OIDNewHeap, reloptions, AccessExclusiveLock);
 
 		ReleaseSysCache(tuple);
 	}
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index 73e6e20..ed38295 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -373,7 +373,7 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
 
 	(void) heap_reloptions(RELKIND_TOASTVALUE, toast_options, true);
 
-	AlterTableCreateToastTable(intoRelationId, toast_options);
+	AlterTableCreateToastTable(intoRelationId, toast_options, AccessExclusiveLock);
 
 	/* Create the "view" part of a materialized view. */
 	if (is_matview)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 1de3170..e4ff88f 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2687,8 +2687,7 @@ AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
  * The caller must lock the relation, with an appropriate lock level
  * for the subcommands requested. Any subcommand that needs to rewrite
  * tuples in the table forces the whole command to be executed with
- * AccessExclusiveLock (actually, that is currently required always, but
- * we hope to relax it at some point).	We pass the lock level down
+ * AccessExclusiveLock.  We pass the lock level down
  * so that we can apply it recursively to inherited tables. Note that the
  * lock level we want as we recurse might well be higher than required for
  * that specific subcommand. So we pass down the overall lock requirement,
@@ -2755,30 +2754,8 @@ LOCKMODE
 AlterTableGetLockLevel(List *cmds)
 {
 	/*
-	 * Late in 9.1 dev cycle a number of issues were uncovered with access to
-	 * catalog relations, leading to the decision to re-enforce all DDL at
-	 * AccessExclusiveLock level by default.
-	 *
-	 * The issues are that there is a pervasive assumption in the code that
-	 * the catalogs will not be read unless an AccessExclusiveLock is held. If
-	 * that rule is relaxed, we must protect against a number of potential
-	 * effects - infrequent, but proven possible with test cases where
-	 * multiple DDL operations occur in a stream against frequently accessed
-	 * tables.
-	 *
-	 * 1. Catalog tables were read using SnapshotNow, which has a race bug that
-	 * allows a scan to return no valid rows even when one is present in the
-	 * case of a commit of a concurrent update of the catalog table.
-	 * SnapshotNow also ignores transactions in progress, so takes the latest
-	 * committed version without waiting for the latest changes.
-	 *
-	 * 2. Relcache needs to be internally consistent, so unless we lock the
-	 * definition during reads we have no way to guarantee that.
-	 *
-	 * 3. Catcache access isn't coordinated at all so refreshes can occur at
-	 * any time.
+	 * This only works if we read catalog tables using MVCC snapshots.
 	 */
-#ifdef REDUCED_ALTER_TABLE_LOCK_LEVELS
 	ListCell   *lcmd;
 	LOCKMODE	lockmode = ShareUpdateExclusiveLock;
 
@@ -2790,28 +2767,55 @@ AlterTableGetLockLevel(List *cmds)
 		switch (cmd->subtype)
 		{
 				/*
-				 * Need AccessExclusiveLock for these subcommands because they
-				 * affect or potentially affect both read and write
-				 * operations.
-				 *
-				 * New subcommand types should be added here by default.
+				 * These subcommands rewrite the heap, so require full locks.
 				 */
 			case AT_AddColumn:	/* may rewrite heap, in some cases and visible
 								 * to SELECT */
-			case AT_DropColumn:	/* change visible to SELECT */
-			case AT_AddColumnToView:	/* CREATE VIEW */
+			case AT_SetTableSpace:		/* must rewrite heap */
 			case AT_AlterColumnType:	/* must rewrite heap */
+			case AT_AddOids:			/* must rewrite heap */
+				cmd_lockmode = AccessExclusiveLock;
+				break;
+
+				/*
+				 * These subcommands may require addition of toast tables.
+				 */
+			case AT_SetStorage:			/* may add toast tables, see ATRewriteCatalogs() */
+				cmd_lockmode = AccessExclusiveLock;
+				break;
+
+				/*
+				 * Removing constraints can affect SELECTs that have been
+				 * optimised assuming the constraint holds true.
+				 */
 			case AT_DropConstraint:		/* as DROP INDEX */
-			case AT_AddOids:	/* must rewrite heap */
-			case AT_DropOids:	/* calls AT_DropColumn */
+			case AT_DropNotNull:		/* may change some SQL plans */
+				cmd_lockmode = AccessExclusiveLock;
+				break;
+
+				/*
+				 * Subcommands that may be visible to concurrent SELECTs
+				 */
+			case AT_DropColumn:			/* change visible to SELECT */
+			case AT_AddColumnToView:	/* CREATE VIEW */
+			case AT_DropOids:			/* calls AT_DropColumn */
 			case AT_EnableAlwaysRule:	/* may change SELECT rules */
 			case AT_EnableReplicaRule:	/* may change SELECT rules */
-			case AT_EnableRule:	/* may change SELECT rules */
+			case AT_EnableRule:			/* may change SELECT rules */
 			case AT_DisableRule:		/* may change SELECT rules */
+				cmd_lockmode = AccessExclusiveLock;
+				break;
+
+				/*
+				 * Changing owner may remove implicit SELECT privileges
+				 */
 			case AT_ChangeOwner:		/* change visible to SELECT */
-			case AT_SetTableSpace:		/* must rewrite heap */
-			case AT_DropNotNull:		/* may change some SQL plans */
-			case AT_SetNotNull:
+				cmd_lockmode = AccessExclusiveLock;
+				break;
+
+				/*
+				 * Changing foreign table options may affect optimisation.
+				 */
 			case AT_GenericOptions:
 			case AT_AlterColumnGenericOptions:
 				cmd_lockmode = AccessExclusiveLock;
@@ -2832,9 +2836,11 @@ AlterTableGetLockLevel(List *cmds)
 			case AT_DisableTrig:
 			case AT_DisableTrigAll:
 			case AT_DisableTrigUser:
+			case AT_AlterConstraint:
 			case AT_AddIndex:	/* from ADD CONSTRAINT */
 			case AT_AddIndexConstraint:
 			case AT_ReplicaIdentity:
+			case AT_SetNotNull:
 				cmd_lockmode = ShareRowExclusiveLock;
 				break;
 
@@ -2879,22 +2885,23 @@ AlterTableGetLockLevel(List *cmds)
 				 * behaviour, while queries started after we commit will see
 				 * new behaviour. No need to prevent reads or writes to the
 				 * subtable while we hook it up though.
+				 * Changing the TupDesc may be a problem, so keep highest lock.
 				 */
 			case AT_AddInherit:
 			case AT_DropInherit:
-				cmd_lockmode = ShareUpdateExclusiveLock;
+				cmd_lockmode = AccessExclusiveLock;
 				break;
 
 				/*
 				 * These subcommands affect implicit row type conversion. They
-				 * have affects similar to CREATE/DROP CAST on queries.  We
+				 * have affects similar to CREATE/DROP CAST on queries.
 				 * don't provide for invalidating parse trees as a result of
-				 * such changes.  Do avoid concurrent pg_class updates,
-				 * though.
+				 * such changes, so we keep these at AccessExclusiveLock.
 				 */
 			case AT_AddOf:
 			case AT_DropOf:
-				cmd_lockmode = ShareUpdateExclusiveLock;
+				cmd_lockmode = AccessExclusiveLock;
+				break;
 
 				/*
 				 * These subcommands affect general strategies for performance
@@ -2914,8 +2921,6 @@ AlterTableGetLockLevel(List *cmds)
 			case AT_ReplaceRelOptions:
 			case AT_SetOptions:
 			case AT_ResetOptions:
-			case AT_SetStorage:
-			case AT_AlterConstraint:
 			case AT_ValidateConstraint:
 				cmd_lockmode = ShareUpdateExclusiveLock;
 				break;
@@ -2932,9 +2937,6 @@ AlterTableGetLockLevel(List *cmds)
 		if (cmd_lockmode > lockmode)
 			lockmode = cmd_lockmode;
 	}
-#else
-	LOCKMODE	lockmode = AccessExclusiveLock;
-#endif
 
 	return lockmode;
 }
@@ -3269,7 +3271,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
 
 		if (tab->relkind == RELKIND_RELATION ||
 			tab->relkind == RELKIND_MATVIEW)
-			AlterTableCreateToastTable(tab->relid, (Datum) 0);
+			AlterTableCreateToastTable(tab->relid, (Datum) 0, lockmode);
 	}
 }
 
@@ -5870,9 +5872,9 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
 	 * deadlock.)
 	 */
 	if (OidIsValid(fkconstraint->old_pktable_oid))
-		pkrel = heap_open(fkconstraint->old_pktable_oid, AccessExclusiveLock);
+		pkrel = heap_open(fkconstraint->old_pktable_oid, ShareUpdateExclusiveLock);
 	else
-		pkrel = heap_openrv(fkconstraint->pktable, AccessExclusiveLock);
+		pkrel = heap_openrv(fkconstraint->pktable, ShareUpdateExclusiveLock);
 
 	/*
 	 * Validity checks (permission checks wait till we have the column
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index fa74bd2..a0ea474 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -156,9 +156,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
 				referenced;
 
 	if (OidIsValid(relOid))
-		rel = heap_open(relOid, AccessExclusiveLock);
+		rel = heap_open(relOid, ShareUpdateExclusiveLock);
 	else
-		rel = heap_openrv(stmt->relation, AccessExclusiveLock);
+		rel = heap_openrv(stmt->relation, ShareUpdateExclusiveLock);
 
 	/*
 	 * Triggers must be on tables or views, and there are additional
@@ -500,8 +500,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
 	 * can skip this for internally generated triggers, since the name
 	 * modification above should be sufficient.
 	 *
-	 * NOTE that this is cool only because we have AccessExclusiveLock on the
-	 * relation, so the trigger set won't be changing underneath us.
+	 * NOTE that this is cool only because we have a sufficient lock on the
+	 * relation to ensure the trigger set won't be changing underneath us.
 	 */
 	if (!isInternal)
 	{
@@ -1077,7 +1077,7 @@ RemoveTriggerById(Oid trigOid)
 	 */
 	relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
 
-	rel = heap_open(relid, AccessExclusiveLock);
+	rel = heap_open(relid, ShareUpdateExclusiveLock);
 
 	if (rel->rd_rel->relkind != RELKIND_RELATION &&
 		rel->rd_rel->relkind != RELKIND_VIEW)
@@ -1243,8 +1243,8 @@ renametrig(RenameStmt *stmt)
 	 * on tgrelid/tgname would complain anyway) and to ensure a trigger does
 	 * exist with oldname.
 	 *
-	 * NOTE that this is cool only because we have AccessExclusiveLock on the
-	 * relation, so the trigger set won't be changing underneath us.
+	 * NOTE that this is cool only because we have a sufficient lock on the
+	 * relation to ensure that the trigger set won't be changing underneath us.
 	 */
 	tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
 
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index d1621ad..b15f5dc 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -927,7 +927,8 @@ ProcessUtilitySlow(Node *parsetree,
 												   toast_options,
 												   true);
 
-							AlterTableCreateToastTable(relOid, toast_options);
+							AlterTableCreateToastTable(relOid, toast_options,
+													   AccessExclusiveLock);
 						}
 						else if (IsA(stmt, CreateForeignTableStmt))
 						{
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 2810b35..086d9f8 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -161,6 +161,14 @@ static bool eoxact_list_overflowed = false;
 			eoxact_list_overflowed = true; \
 	} while (0)
 
+/*
+ * EOXactTupleDescArray stores *TupleDescs that (might) need AtEOXact
+ * cleanup work.  The array expands as needed; there is no hashtable because
+ * we don't need to access individual items except at EOXact.
+ */
+static TupleDesc *EOXactTupleDescArray;
+static int NextEOXactTupleDescNum = 0;
+static int EOXactTupleDescArrayLen = 0;
 
 /*
  *		macros to manipulate the lookup hashtables
@@ -219,11 +227,12 @@ static HTAB *OpClassCache = NULL;
 
 /* non-export function prototypes */
 
-static void RelationDestroyRelation(Relation relation);
+static void RelationDestroyRelation(Relation relation, bool remember_tupdesc);
 static void RelationClearRelation(Relation relation, bool rebuild);
 
 static void RelationReloadIndexInfo(Relation relation);
 static void RelationFlushRelation(Relation relation);
+static void RememberToFreeTupleDescAtEOX(TupleDesc td);
 static void AtEOXact_cleanup(Relation relation, bool isCommit);
 static void AtEOSubXact_cleanup(Relation relation, bool isCommit,
 					SubTransactionId mySubid, SubTransactionId parentSubid);
@@ -1811,7 +1820,7 @@ RelationReloadIndexInfo(Relation relation)
  *	Caller must already have unhooked the entry from the hash table.
  */
 static void
-RelationDestroyRelation(Relation relation)
+RelationDestroyRelation(Relation relation, bool remember_tupdesc)
 {
 	Assert(RelationHasReferenceCountZero(relation));
 
@@ -1831,7 +1840,20 @@ RelationDestroyRelation(Relation relation)
 	/* can't use DecrTupleDescRefCount here */
 	Assert(relation->rd_att->tdrefcount > 0);
 	if (--relation->rd_att->tdrefcount == 0)
-		FreeTupleDesc(relation->rd_att);
+	{
+		/*
+		 * If we Rebuilt a relcache entry during a transaction then its
+		 * possible we did that because the TupDesc changed as the result
+		 * of an ALTER TABLE that ran at less than AccessExclusiveLock.
+		 * It's possible someone copied that TupDesc, in which case the
+		 * copy would point to free'd memory. So if we rebuild an entry
+		 * we keep the TupDesc around until end of transaction, to be safe.
+		 */
+		if (remember_tupdesc)
+			RememberToFreeTupleDescAtEOX(relation->rd_att);
+		else
+			FreeTupleDesc(relation->rd_att);
+	}
 	list_free(relation->rd_indexlist);
 	bms_free(relation->rd_indexattr);
 	FreeTriggerDesc(relation->trigdesc);
@@ -1945,7 +1967,7 @@ RelationClearRelation(Relation relation, bool rebuild)
 		RelationCacheDelete(relation);
 
 		/* And release storage */
-		RelationDestroyRelation(relation);
+		RelationDestroyRelation(relation, false);
 	}
 	else if (!IsTransactionState())
 	{
@@ -2012,7 +2034,7 @@ RelationClearRelation(Relation relation, bool rebuild)
 		{
 			/* Should only get here if relation was deleted */
 			RelationCacheDelete(relation);
-			RelationDestroyRelation(relation);
+			RelationDestroyRelation(relation, false);
 			elog(ERROR, "relation %u deleted while still in use", save_relid);
 		}
 
@@ -2074,7 +2096,7 @@ RelationClearRelation(Relation relation, bool rebuild)
 #undef SWAPFIELD
 
 		/* And now we can throw away the temporary entry */
-		RelationDestroyRelation(newrel);
+		RelationDestroyRelation(newrel, !keep_tupdesc);
 	}
 }
 
@@ -2312,6 +2334,37 @@ RelationCloseSmgrByOid(Oid relationId)
 	RelationCloseSmgr(relation);
 }
 
+void
+RememberToFreeTupleDescAtEOX(TupleDesc td)
+{
+	if (EOXactTupleDescArray == NULL)
+	{
+		MemoryContext	oldcxt;
+		oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+
+		EOXactTupleDescArray = (TupleDesc *) palloc(16 * sizeof(TupleDesc));
+		EOXactTupleDescArrayLen = 16;
+		NextEOXactTupleDescNum = 0;
+		MemoryContextSwitchTo(oldcxt);
+	}
+	else if (NextEOXactTupleDescNum >= EOXactTupleDescArrayLen)
+	{
+		MemoryContext	oldcxt;
+		int32       	newlen = EOXactTupleDescArrayLen * 2;
+
+		oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+
+		Assert(EOXactTupleDescArrayLen > 0);
+
+		EOXactTupleDescArray = (TupleDesc *) repalloc(EOXactTupleDescArray,
+														newlen * sizeof(TupleDesc));
+		EOXactTupleDescArrayLen = newlen;
+		MemoryContextSwitchTo(oldcxt);
+	}
+
+	EOXactTupleDescArray[NextEOXactTupleDescNum++] = td;
+}
+
 /*
  * AtEOXact_RelationCache
  *
@@ -2367,9 +2420,20 @@ AtEOXact_RelationCache(bool isCommit)
 		}
 	}
 
-	/* Now we're out of the transaction and can clear the list */
+	if (EOXactTupleDescArrayLen > 0)
+	{
+		Assert(EOXactTupleDescArray != NULL);
+		for (i = 0; i < NextEOXactTupleDescNum; i++)
+			FreeTupleDesc(EOXactTupleDescArray[i]);
+		pfree(EOXactTupleDescArray);
+		EOXactTupleDescArray = NULL;
+	}
+
+	/* Now we're out of the transaction and can clear the lists */
 	eoxact_list_len = 0;
 	eoxact_list_overflowed = false;
+	NextEOXactTupleDescNum = 0;
+	EOXactTupleDescArrayLen = 0;
 }
 
 /*
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index ca047f0..07b2169 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -14,10 +14,13 @@
 #ifndef TOASTING_H
 #define TOASTING_H
 
+#include "storage/lock.h"
+
 /*
  * toasting.c prototypes
  */
-extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions);
+extern void AlterTableCreateToastTable(Oid relOid, Datum reloptions,
+									   LOCKMODE lockmode);
 extern void BootstrapToastTable(char *relName,
 					Oid toastOid, Oid toastIndexOid);
 
diff --git a/src/test/isolation/expected/alter-table-1.out b/src/test/isolation/expected/alter-table-1.out
new file mode 100644
index 0000000..9daa418
--- /dev/null
+++ b/src/test/isolation/expected/alter-table-1.out
@@ -0,0 +1,3676 @@
+Parsed test spec with 2 sessions
+
+starting permutation: s1 at1 sc1 s2 at2 sc2 rx1 wx rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 at2 rx1 sc2 wx rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 at2 rx1 wx sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 at2 rx1 wx rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 at2 rx1 wx rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 at2 sc2 wx rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 at2 wx sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 at2 wx rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 at2 wx rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 s2 rx1 wx rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 at2 sc2 wx rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 at2 wx sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 at2 wx rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 at2 wx rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 s2 wx rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 sc1 rx1 wx rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 at2 sc2 wx rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 at2 wx sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 at2 wx rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 at2 wx rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 s2 wx rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 sc1 wx rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx sc1 rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx rx1 sc1 s2 at2 sc2 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 at1 rx1 wx rx1 sc1 s2 at2 c2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 at1 rx1 wx rx1 sc1 s2 c2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 at1 rx1 wx rx1 sc1 c2 s2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 at1 rx1 wx rx1 c2 sc1 s2 at2 sc2
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 at1 sc1 s2 at2 sc2 wx rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 at2 wx sc2 rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 at2 wx rx1 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 at2 wx rx1 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx at2 sc2 rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx at2 rx1 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx at2 rx1 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx rx1 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx rx1 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 s2 wx rx1 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 sc1 wx rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx sc1 rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx rx1 sc1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 at1 wx rx1 sc1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 at1 wx rx1 sc1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 at1 wx rx1 sc1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 at1 wx rx1 c2 sc1 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 at2 sc2 rx1 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 at2 rx1 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 at2 rx1 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 rx1 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 rx1 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 s2 rx1 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 rx1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 rx1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 rx1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 sc1 rx1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 rx1 sc1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 rx1 sc1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 rx1 sc1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 rx1 sc1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: s1 rx1 wx at1 rx1 c2 sc1 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 wx rx1 at1 sc1 s2 at2 sc2 c2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx rx1 at1 sc1 s2 at2 c2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx rx1 at1 sc1 s2 c2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx rx1 at1 sc1 c2 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: s1 rx1 wx rx1 at1 c2 sc1 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: s1 rx1 wx rx1 c2 at1 sc1 s2 at2 sc2
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 at2 sc2 wx rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 at2 wx sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 at2 wx rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 at2 wx rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx at2 sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx at2 rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx at2 rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx rx1 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx rx1 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 s2 wx rx1 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 at2 sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 at2 rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 at2 rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 rx1 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 rx1 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx s2 rx1 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx rx1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx rx1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx rx1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 sc1 wx rx1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 at2 sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 at2 rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 at2 rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 rx1 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 rx1 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 s2 rx1 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step s2: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 rx1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 rx1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step c2: COMMIT;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 rx1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s2: BEGIN;
+step c2: COMMIT;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx sc1 rx1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+step sc1: COMMIT;
+step wx: <... completed>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx rx1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 at1 wx rx1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 at1 wx rx1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 at1 wx rx1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 at1 wx rx1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step wx: INSERT INTO b VALUES (0); <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 at2 sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 at2 rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 at2 rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 rx1 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 rx1 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 s2 rx1 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 rx1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 rx1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 rx1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 sc1 rx1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 rx1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 rx1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 rx1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 rx1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 s1 wx at1 rx1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 wx rx1 at1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx rx1 at1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx rx1 at1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx rx1 at1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 s1 wx rx1 at1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 s1 wx rx1 c2 at1 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step s1: BEGIN;
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx s1 at1 sc1 s2 at2 sc2 rx1 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 s2 at2 rx1 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 s2 at2 rx1 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 s2 rx1 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 s2 rx1 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 s2 rx1 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 rx1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 rx1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 rx1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 sc1 rx1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 rx1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 rx1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 rx1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 rx1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+invalid permutation detected
+
+starting permutation: rx1 wx s1 at1 rx1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx s1 rx1 at1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 rx1 at1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 rx1 at1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 rx1 at1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx s1 rx1 at1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx s1 rx1 c2 at1 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step s1: BEGIN;
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx rx1 s1 at1 sc1 s2 at2 sc2 c2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx rx1 s1 at1 sc1 s2 at2 c2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx rx1 s1 at1 sc1 s2 c2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx rx1 s1 at1 sc1 c2 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+invalid permutation detected
+
+starting permutation: rx1 wx rx1 s1 at1 c2 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; <waiting ...>
+step c2: COMMIT;
+step at1: <... completed>
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx rx1 s1 c2 at1 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step s1: BEGIN;
+step c2: COMMIT;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
+
+starting permutation: rx1 wx rx1 c2 s1 at1 sc1 s2 at2 sc2
+step rx1: SELECT * FROM b WHERE a_id = 1 LIMIT 1;
+a_id           
+
+1              
+step wx: INSERT INTO b VALUES (0);
+step rx1: SELECT * FROM b WHERE a_id = 3 LIMIT 3;
+a_id           
+
+3              
+3              
+3              
+step c2: COMMIT;
+step s1: BEGIN;
+step at1: ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID;
+step sc1: COMMIT;
+step s2: BEGIN;
+step at2: ALTER TABLE b VALIDATE CONSTRAINT bfk;
+step sc2: COMMIT;
diff --git a/src/test/isolation/expected/alter-table-2.out b/src/test/isolation/expected/alter-table-2.out
new file mode 100644
index 0000000..9e957bf
--- /dev/null
+++ b/src/test/isolation/expected/alter-table-2.out
@@ -0,0 +1,1681 @@
+Parsed test spec with 2 sessions
+
+starting permutation: s1 at1 c1 rx1 wx1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+442368         
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+811008         
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 c1 wx1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step c1: COMMIT;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+442368         
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+811008         
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx1 c1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx1 rx2 c1 wx2 rx3 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx1 rx2 wx2 c1 rx3 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx1 rx2 wx2 rx3 c1 c2
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 at1 rx1 wx1 rx2 wx2 rx3 c2 c1
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 at1 c1 wx1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+442368         
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+811008         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx1 c1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx1 rx2 c1 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx1 rx2 wx2 c1 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx1 rx2 wx2 rx3 c1 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 at1 wx1 rx2 wx2 rx3 c2 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 wx1 at1 c1 rx2 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 at1 rx2 c1 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 at1 rx2 wx2 c1 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 at1 rx2 wx2 rx3 c1 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 at1 rx2 wx2 rx3 c2 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 at1 c1 wx2 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 at1 wx2 c1 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 at1 wx2 rx3 c1 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 at1 wx2 rx3 c2 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 at1 c1 rx3 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 at1 rx3 c1 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 at1 rx3 c2 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 rx3 at1 c1 c2
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 rx3 at1 c2 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: s1 rx1 wx1 rx2 wx2 rx3 c2 at1 c1
+step s1: BEGIN;
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 s1 at1 c1 wx1 rx2 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+442368         
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+811008         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx1 c1 rx2 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx1 rx2 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx1 rx2 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx1 rx2 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 at1 wx1 rx2 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 s1 wx1 at1 c1 rx2 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 at1 rx2 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 at1 rx2 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 at1 rx2 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 at1 rx2 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 at1 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 at1 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 at1 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 at1 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 at1 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 at1 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 at1 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 rx3 at1 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 rx3 at1 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 s1 wx1 rx2 wx2 rx3 c2 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step s1: BEGIN;
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 s1 at1 c1 rx2 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 at1 rx2 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 at1 rx2 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 at1 rx2 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 at1 rx2 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 at1 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 at1 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 at1 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 at1 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 at1 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 at1 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 at1 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 rx3 at1 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 rx3 at1 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 s1 rx2 wx2 rx3 c2 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 at1 c1 wx2 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+475136         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 at1 wx2 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 at1 wx2 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 at1 wx2 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 at1 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 at1 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 at1 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 rx3 at1 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 rx3 at1 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 s1 wx2 rx3 c2 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step s1: BEGIN;
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 at1 c1 rx3 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 at1 rx3 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 at1 rx3 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 rx3 at1 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 rx3 at1 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 s1 rx3 c2 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step s1: BEGIN;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 rx3 s1 at1 c1 c2
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+step c2: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 rx3 s1 at1 c2 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c2: COMMIT;
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 rx3 s1 c2 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step s1: BEGIN;
+step c2: COMMIT;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
+
+starting permutation: rx1 wx1 rx2 wx2 rx3 c2 s1 at1 c1
+step rx1: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+65536          
+step wx1: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx2: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+98304          
+step wx2: INSERT INTO b SELECT generate_series(1,1000) % 4;
+step rx3: SELECT pg_total_relation_size('b');
+pg_total_relation_size
+
+139264         
+step c2: COMMIT;
+step s1: BEGIN;
+step at1: ALTER TABLE b SET (fillfactor = 10);
+step c1: COMMIT;
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule
index 1e73b4a..6fd2fe1 100644
--- a/src/test/isolation/isolation_schedule
+++ b/src/test/isolation/isolation_schedule
@@ -23,4 +23,6 @@ test: multixact-no-deadlock
 test: multixact-no-forget
 test: propagate-lock-delete
 test: drop-index-concurrently-1
+test: alter-table-1
+test: alter-table-2
 test: timeouts
diff --git a/src/test/isolation/specs/alter-table-1.spec b/src/test/isolation/specs/alter-table-1.spec
new file mode 100644
index 0000000..f01084d
--- /dev/null
+++ b/src/test/isolation/specs/alter-table-1.spec
@@ -0,0 +1,34 @@
+# ALTER TABLE - Add and Validate constraint with concurrent writes
+#
+# ADD FOREIGN KEY allows a minimum of ShareRowExclusiveLock,
+# so we mix writes with it to see what works or waits.
+# VALIDATE allows a minimum of ShareUpdateExclusiveLock
+# so we mix reads with it to see what works or waits
+
+setup
+{
+ CREATE TABLE a (i int PRIMARY KEY);
+ CREATE TABLE b (a_id int);
+ INSERT INTO a VALUES (0), (1), (2), (3);
+ INSERT INTO b SELECT generate_series(1,1000) % 4;
+}
+
+teardown
+{
+ DROP TABLE a, b;
+}
+
+session "s1"
+step "s1"	{ BEGIN; }
+step "at1"	{ ALTER TABLE b ADD CONSTRAINT bfk FOREIGN KEY (a_id) REFERENCES a (i) NOT VALID; }
+step "sc1"	{ COMMIT; }
+step "s2"	{ BEGIN; }
+step "at2"	{ ALTER TABLE b VALIDATE CONSTRAINT bfk; }
+step "sc2"	{ COMMIT; }
+
+session "s2"
+setup		{ BEGIN; }
+step "rx1"	{ SELECT * FROM b WHERE a_id = 1 LIMIT 1; }
+step "wx"	{ INSERT INTO b VALUES (0); }
+step "rx1"	{ SELECT * FROM b WHERE a_id = 3 LIMIT 3; }
+step "c2"	{ COMMIT; }
diff --git a/src/test/isolation/specs/alter-table-2.spec b/src/test/isolation/specs/alter-table-2.spec
new file mode 100644
index 0000000..bd0f3ba
--- /dev/null
+++ b/src/test/isolation/specs/alter-table-2.spec
@@ -0,0 +1,29 @@
+# ALTER TABLE - Change fillfactor
+#
+# As the fillfactor takes effect the table grows much larger
+
+setup
+{
+ CREATE TABLE b (a_id int);
+ ALTER TABLE b SET (fillfactor = 100);
+ INSERT INTO b SELECT generate_series(1,1000) % 4;
+}
+
+teardown
+{
+ DROP TABLE b;
+}
+
+session "s1"
+step "s1"	{ BEGIN; }
+step "at1"	{ ALTER TABLE b SET (fillfactor = 10); }
+step "c1"	{ COMMIT; }
+
+session "s2"
+setup		{ BEGIN; }
+step "rx1"	{ SELECT pg_total_relation_size('b'); }
+step "wx1"	{ INSERT INTO b SELECT generate_series(1,1000) % 4; }
+step "rx2"	{ SELECT pg_total_relation_size('b'); }
+step "wx2"	{ INSERT INTO b SELECT generate_series(1,1000) % 4; }
+step "rx3"	{ SELECT pg_total_relation_size('b'); }
+step "c2"	{ COMMIT; }
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 0f0c638..316d789 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -1840,72 +1840,75 @@ and relnamespace != (select oid from pg_namespace where nspname = 'pg_catalog')
 and c.relname != 'my_locks'
 group by c.relname;
 create table alterlock (f1 int primary key, f2 text);
+insert into alterlock values (1, 'foo');
+create table alterlock2 (f3 int primary key, f1 int);
+insert into alterlock2 values (1, 1);
 begin; alter table alterlock alter column f2 set statistics 150;
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
 (1 row)
 
 rollback;
 begin; alter table alterlock cluster on alterlock_pkey;
 select * from my_locks order by 1;
-    relname     |    max_lockmode     
-----------------+---------------------
- alterlock      | AccessExclusiveLock
- alterlock_pkey | AccessExclusiveLock
+    relname     |       max_lockmode       
+----------------+--------------------------
+ alterlock      | ShareUpdateExclusiveLock
+ alterlock_pkey | ShareUpdateExclusiveLock
 (2 rows)
 
 commit;
 begin; alter table alterlock set without cluster;
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
 (1 row)
 
 commit;
 begin; alter table alterlock set (fillfactor = 100);
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
- pg_toast  | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
+ pg_toast  | ShareUpdateExclusiveLock
 (2 rows)
 
 commit;
 begin; alter table alterlock reset (fillfactor);
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
- pg_toast  | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
+ pg_toast  | ShareUpdateExclusiveLock
 (2 rows)
 
 commit;
 begin; alter table alterlock set (toast.autovacuum_enabled = off);
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
- pg_toast  | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
+ pg_toast  | ShareUpdateExclusiveLock
 (2 rows)
 
 commit;
 begin; alter table alterlock set (autovacuum_enabled = off);
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
- pg_toast  | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
+ pg_toast  | ShareUpdateExclusiveLock
 (2 rows)
 
 commit;
 begin; alter table alterlock alter column f2 set (n_distinct = 1);
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
 (1 row)
 
 rollback;
@@ -1919,13 +1922,67 @@ select * from my_locks order by 1;
 rollback;
 begin; alter table alterlock alter column f2 set default 'x';
 select * from my_locks order by 1;
-  relname  |    max_lockmode     
------------+---------------------
- alterlock | AccessExclusiveLock
+  relname  |     max_lockmode      
+-----------+-----------------------
+ alterlock | ShareRowExclusiveLock
+(1 row)
+
+rollback;
+begin;
+create trigger ttdummy
+	before delete or update on alterlock
+	for each row
+	execute procedure
+	ttdummy (1, 1);
+select * from my_locks order by 1;
+  relname  |       max_lockmode       
+-----------+--------------------------
+ alterlock | ShareUpdateExclusiveLock
 (1 row)
 
 rollback;
+begin;
+select * from my_locks order by 1;
+ relname | max_lockmode 
+---------+--------------
+(0 rows)
+
+alter table alterlock2 add foreign key (f1) references alterlock (f1);
+select * from my_locks order by 1;
+     relname     |       max_lockmode       
+-----------------+--------------------------
+ alterlock       | ShareUpdateExclusiveLock
+ alterlock2      | ShareRowExclusiveLock
+ alterlock2_pkey | AccessShareLock
+ alterlock_pkey  | AccessShareLock
+(4 rows)
+
+rollback;
+begin;
+alter table alterlock2
+add constraint alterlock2nv foreign key (f1) references alterlock (f1) NOT VALID;
+select * from my_locks order by 1;
+  relname   |       max_lockmode       
+------------+--------------------------
+ alterlock  | ShareUpdateExclusiveLock
+ alterlock2 | ShareRowExclusiveLock
+(2 rows)
+
+commit;
+begin;
+alter table alterlock2 validate constraint alterlock2nv;
+select * from my_locks order by 1;
+     relname     |       max_lockmode       
+-----------------+--------------------------
+ alterlock       | RowShareLock
+ alterlock2      | ShareUpdateExclusiveLock
+ alterlock2_pkey | AccessShareLock
+ alterlock_pkey  | AccessShareLock
+(4 rows)
+
+rollback;
 -- cleanup
+drop table alterlock2;
 drop table alterlock;
 drop view my_locks;
 drop type lockmodes;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 87973c1..a2ad863 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1283,6 +1283,9 @@ and c.relname != 'my_locks'
 group by c.relname;
 
 create table alterlock (f1 int primary key, f2 text);
+insert into alterlock values (1, 'foo');
+create table alterlock2 (f3 int primary key, f1 int);
+insert into alterlock2 values (1, 1);
 
 begin; alter table alterlock alter column f2 set statistics 150;
 select * from my_locks order by 1;
@@ -1324,7 +1327,33 @@ begin; alter table alterlock alter column f2 set default 'x';
 select * from my_locks order by 1;
 rollback;
 
+begin;
+create trigger ttdummy
+	before delete or update on alterlock
+	for each row
+	execute procedure
+	ttdummy (1, 1);
+select * from my_locks order by 1;
+rollback;
+
+begin;
+select * from my_locks order by 1;
+alter table alterlock2 add foreign key (f1) references alterlock (f1);
+select * from my_locks order by 1;
+rollback;
+
+begin;
+alter table alterlock2
+add constraint alterlock2nv foreign key (f1) references alterlock (f1) NOT VALID;
+select * from my_locks order by 1;
+commit;
+begin;
+alter table alterlock2 validate constraint alterlock2nv;
+select * from my_locks order by 1;
+rollback;
+
 -- cleanup
+drop table alterlock2;
 drop table alterlock;
 drop view my_locks;
 drop type lockmodes;
