From be5e6bf00b3185724dafac3756bdbfb86467cc27 Mon Sep 17 00:00:00 2001 From: miles Date: Thu, 15 Aug 2024 17:32:58 +0000 Subject: [PATCH] changefeedccl: don't hide error encountered during table resolution Stop masking the error returned if table resolution fails. The *backupresolver.MissingTableErr already includes the table name in its Error() method, in addition to the wrapped error, which is currently dropped. This is a debugging step for the linked issue. Part of: #128255 Release note: None --- pkg/ccl/changefeedccl/changefeed_stmt.go | 3 +-- pkg/ccl/changefeedccl/changefeed_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/ccl/changefeedccl/changefeed_stmt.go b/pkg/ccl/changefeedccl/changefeed_stmt.go index 7eb0db8b48db..47861b7fb939 100644 --- a/pkg/ccl/changefeedccl/changefeed_stmt.go +++ b/pkg/ccl/changefeedccl/changefeed_stmt.go @@ -807,8 +807,7 @@ func getTableDescriptors( if err != nil { var m *backupresolver.MissingTableErr if errors.As(err, &m) { - tableName := m.GetTableName() - err = errors.Errorf("table %q does not exist", tableName) + err = errors.Wrapf(m.Unwrap(), "table %q does not exist", m.GetTableName()) } err = errors.Wrap(err, "failed to resolve targets in the CHANGEFEED stmt") if !initialHighWater.IsEmpty() { diff --git a/pkg/ccl/changefeedccl/changefeed_test.go b/pkg/ccl/changefeedccl/changefeed_test.go index 28cb537a361c..bf29a99fe513 100644 --- a/pkg/ccl/changefeedccl/changefeed_test.go +++ b/pkg/ccl/changefeedccl/changefeed_test.go @@ -714,7 +714,7 @@ func TestMissingTableErr(t *testing.T) { t.Run("changefeed on non existing table fails", func(t *testing.T) { kvSQL := sqlutils.MakeSQLRunner(s.DB) - kvSQL.ExpectErr(t, `^pq: failed to resolve targets in the CHANGEFEED stmt: table "foo" does not exist$`, + kvSQL.ExpectErr(t, `^pq: failed to resolve targets in the CHANGEFEED stmt: table "foo" does not exist`, `CREATE CHANGEFEED FOR foo`, ) })