diff --git a/pkg/workload/schemachange/error_screening.go b/pkg/workload/schemachange/error_screening.go index 6292014bee12..4d5ad403700d 100644 --- a/pkg/workload/schemachange/error_screening.go +++ b/pkg/workload/schemachange/error_screening.go @@ -560,14 +560,20 @@ SELECT count(*) > 0 return nil } +func getValidGenerationErrors() errorCodeSet { + return errorCodeSet{ + pgcode.NumericValueOutOfRange: true, + pgcode.FloatingPointException: true, + pgcode.InvalidTextRepresentation: true, + } +} + // isValidGenerationError these codes can be observed when evaluating values // for generated expressions. These are errors are not ignored, but added into // the expected set of errors. func isValidGenerationError(code string) bool { pgCode := pgcode.MakeCode(code) - return pgCode == pgcode.NumericValueOutOfRange || - pgCode == pgcode.FloatingPointException || - pgCode == pgcode.InvalidTextRepresentation + return getValidGenerationErrors().contains(pgCode) } // validateGeneratedExpressionsForInsert goes through generated expressions and diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index f075e199533f..c447fee36163 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -1335,6 +1335,14 @@ func (og *operationGenerator) createTableAs(ctx context.Context, tx pgx.Tx) (*op {code: pgcode.DuplicateColumn, condition: duplicateColumns}, }.add(opStmt.expectedExecErrors) + // Confirm the select itself doesn't run into any column generation errors, + // by executing it independently first until we add validation when adding + // generated columns. See issue: #81698?, which will allow us to remove this + // logic in the future. + if opStmt.expectedExecErrors.empty() { + opStmt.potentialExecErrors.merge(getValidGenerationErrors()) + } + opStmt.sql = fmt.Sprintf(`CREATE TABLE %s AS %s FETCH FIRST %d ROWS ONLY`, destTableName, selectStatement.String(), MaxRowsToConsume) return opStmt, nil