@@ -1996,36 +1996,32 @@ CopyFrom(CopyState cstate)
19961996 hi_options |= HEAP_INSERT_SKIP_FSM ;
19971997 if (!XLogIsNeeded ())
19981998 hi_options |= HEAP_INSERT_SKIP_WAL ;
1999+ }
19992000
2000- /*
2001- * Optimize if new relfilenode was created in this subxact or
2002- * one of its committed children and we won't see those rows later
2003- * as part of an earlier scan or command. This ensures that if this
2004- * subtransaction aborts then the frozen rows won't be visible
2005- * after xact cleanup. Note that the stronger test of exactly
2006- * which subtransaction created it is crucial for correctness
2007- * of this optimisation.
2008- */
2009- if (cstate -> freeze )
2010- {
2011- if (!ThereAreNoPriorRegisteredSnapshots () || !ThereAreNoReadyPortals ())
2012- ereport (ERROR ,
2013- (ERRCODE_INVALID_TRANSACTION_STATE ,
2014- errmsg ("cannot perform FREEZE because of prior transaction activity" )));
2001+ /*
2002+ * Optimize if new relfilenode was created in this subxact or
2003+ * one of its committed children and we won't see those rows later
2004+ * as part of an earlier scan or command. This ensures that if this
2005+ * subtransaction aborts then the frozen rows won't be visible
2006+ * after xact cleanup. Note that the stronger test of exactly
2007+ * which subtransaction created it is crucial for correctness
2008+ * of this optimisation.
2009+ */
2010+ if (cstate -> freeze )
2011+ {
2012+ if (!ThereAreNoPriorRegisteredSnapshots () || !ThereAreNoReadyPortals ())
2013+ ereport (ERROR ,
2014+ (ERRCODE_INVALID_TRANSACTION_STATE ,
2015+ errmsg ("cannot perform FREEZE because of prior transaction activity" )));
20152016
2016- if (cstate -> rel -> rd_createSubid == GetCurrentSubTransactionId () ||
2017- cstate -> rel -> rd_newRelfilenodeSubid == GetCurrentSubTransactionId ())
2018- hi_options |= HEAP_INSERT_FROZEN ;
2019- else
2020- ereport (ERROR ,
2021- (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE ,
2022- errmsg ("cannot perform FREEZE because of transaction activity after table creation or truncation" )));
2023- }
2017+ if (cstate -> rel -> rd_createSubid != GetCurrentSubTransactionId () &&
2018+ cstate -> rel -> rd_newRelfilenodeSubid != GetCurrentSubTransactionId ())
2019+ ereport (ERROR ,
2020+ (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE ,
2021+ errmsg ("cannot perform FREEZE because the table was not created or truncated in the current subtransaction" )));
2022+
2023+ hi_options |= HEAP_INSERT_FROZEN ;
20242024 }
2025- else if (cstate -> freeze )
2026- ereport (ERROR ,
2027- (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE ,
2028- errmsg ("cannot perform FREEZE because the table was not created or truncated in the current transaction" )));
20292025
20302026 /*
20312027 * We need a ResultRelInfo so we can use the regular executor's
0 commit comments