diff --git a/pkg/sql/colexecerror/error.go b/pkg/sql/colexecerror/error.go index 28a3c4957575..1f5b060c14f2 100644 --- a/pkg/sql/colexecerror/error.go +++ b/pkg/sql/colexecerror/error.go @@ -92,12 +92,18 @@ func CatchVectorizedRuntimeError(operation func()) (retErr error) { return retErr } +// We use the approach of allow-listing the packages the panics from which are +// safe to catch (which is the case when the code doesn't update shared state +// and doesn't manipulate locks). +// +// Multiple actual packages can have the same prefix as a single constant string +// defined below, but all of such packages are allowed to be caught from. const ( colPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/col" execinfraPackagePrefix = "github.com/cockroachdb/cockroach/pkg/sql/execinfra" sqlColPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/col" sqlRowPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/row" - treePackagePrefix = "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + sqlSemPackagesPrefix = "github.com/cockroachdb/cockroach/pkg/sql/sem" ) // shouldCatchPanic checks whether the panic that was emitted from @@ -126,7 +132,7 @@ func shouldCatchPanic(panicEmittedFrom string) bool { strings.HasPrefix(panicEmittedFrom, execinfraPackagePrefix) || strings.HasPrefix(panicEmittedFrom, sqlColPackagesPrefix) || strings.HasPrefix(panicEmittedFrom, sqlRowPackagesPrefix) || - strings.HasPrefix(panicEmittedFrom, treePackagePrefix) + strings.HasPrefix(panicEmittedFrom, sqlSemPackagesPrefix) } // StorageError is an error that was created by a component below the sql