From 49b5ecd886600692ac868ff63f32f7959c711996 Mon Sep 17 00:00:00 2001 From: Chengxiong Ruan Date: Thu, 23 Feb 2023 12:15:52 -0500 Subject: [PATCH] sql: skip mixed version test if setup stmt is unimplemented in old version This patch add additional error checking so that we can skip a test if the any of the setup statement is unimplemented. This is useful to skip a mixed version schema changer test when implementing new features which are version gated. Epic: None Release note: None --- pkg/sql/schemachanger/sctest/BUILD.bazel | 1 + pkg/sql/schemachanger/sctest/cumulative.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/sql/schemachanger/sctest/BUILD.bazel b/pkg/sql/schemachanger/sctest/BUILD.bazel index 5089225864d9..516b07981bcd 100644 --- a/pkg/sql/schemachanger/sctest/BUILD.bazel +++ b/pkg/sql/schemachanger/sctest/BUILD.bazel @@ -23,6 +23,7 @@ go_library( "//pkg/sql", "//pkg/sql/catalog", "//pkg/sql/parser", + "//pkg/sql/pgwire/pgcode", "//pkg/sql/schemachanger/corpus", "//pkg/sql/schemachanger/scbuild", "//pkg/sql/schemachanger/scdecomp", diff --git a/pkg/sql/schemachanger/sctest/cumulative.go b/pkg/sql/schemachanger/sctest/cumulative.go index d53f02f3356d..5c0b715eb629 100644 --- a/pkg/sql/schemachanger/sctest/cumulative.go +++ b/pkg/sql/schemachanger/sctest/cumulative.go @@ -32,6 +32,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/parser" + "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/corpus" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scbuild" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scexec" @@ -1391,7 +1392,17 @@ func executeSchemaChangeTxn( // declarative schema changer testing knobs don't get used. tdb.Exec(t, "SET use_declarative_schema_changer = 'off'") for _, stmt := range setup { - tdb.Exec(t, stmt.SQL) + _, err := db.Exec(stmt.SQL) + if err != nil { + // nolint:errcmp + switch errT := err.(type) { + case *pq.Error: + if string(errT.Code) == pgcode.FeatureNotSupported.String() { + skip.IgnoreLint(t, "skipping due to unimplemented feature in old cluster version.") + } + } + return err + } } waitForSchemaChangesToFinish(t, tdb) if before != nil {