@@ -456,12 +456,12 @@ func (w *schemaChangeWorker) runInTxn(
456456) error {
457457 w .logger .startLog (w .id )
458458 w .logger .writeLog ("BEGIN" )
459- opsNum := 1 + w .opGen .randIntn (w .maxOpsPerWorker )
460- if useDeclarativeSchemaChanger && opsNum > w .workload .declarativeSchemaMaxStmtsPerTxn {
461- opsNum = w .workload .declarativeSchemaMaxStmtsPerTxn
459+ numOps := 1 + w .opGen .randIntn (w .maxOpsPerWorker )
460+ if useDeclarativeSchemaChanger && numOps > w .workload .declarativeSchemaMaxStmtsPerTxn {
461+ numOps = w .workload .declarativeSchemaMaxStmtsPerTxn
462462 }
463463
464- for i := 0 ; i < opsNum ; i ++ {
464+ for i := 0 ; i < numOps ; i ++ {
465465 // Terminating this loop early if there are expected commit errors prevents unexpected commit behavior from being
466466 // hidden by subsequent operations. Consider the case where there are expected commit errors.
467467 // It is possible that committing the transaction now will fail the workload because the error does not occur
@@ -474,8 +474,7 @@ func (w *schemaChangeWorker) runInTxn(
474474 break
475475 }
476476
477- // Only allow DML for single-statement transactions.
478- op , err := w .opGen .randOp (ctx , tx , useDeclarativeSchemaChanger , opsNum == 1 )
477+ op , err := w .opGen .randOp (ctx , tx , useDeclarativeSchemaChanger , numOps )
479478 if pgErr := new (pgconn.PgError ); errors .As (err , & pgErr ) &&
480479 pgcode .MakeCode (pgErr .Code ) == pgcode .SerializationFailure {
481480 return errors .Mark (err , errRunInTxnRbkSentinel )
0 commit comments