cockroachdb / cockroachdb/cockroach
Alter Changefeed validation inside PREPARE statements is not working for `UNSET` and `ADD TABLE WITH`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
Alter Changefeed validation inside PREPARE statements is not working for `UNSET` and `ADD TABLE WITH`
**To Reproduce**
```
func TestAlterChangefeedOptionValidation(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
testFn := func(t *testing.T, s TestServer, f cdctest.TestFeedFactory) {
sqlDB := sqlutils.MakeSQLRunner(s.DB)
sqlDB.Exec(t, `CREATE TABLE foo (a INT PRIMARY KEY)`)
sqlDB.Exec(t, `CREATE TABLE bar (a INT PRIMARY KEY)`)
testFeed := feed(t, f, `CREATE CHANGEFEED FOR foo`)
defer closeFeed(t, testFeed)
feed, ok := testFeed.(cdctest.EnterpriseTestFeed)
require.True(t, ok)
sqlDB.Exec(t, `PAUSE JOB $1`, feed.JobID())
waitForJobState(sqlDB, t, feed.JobID(), `paused`)
sqlDB.ExpectErr(t,
`pq: invalid option "foobar"`,
fmt.Sprintf(`PREPARE add_bad_option AS ALTER CHANGEFEED %d ADD t1 WITH foobar`, feed.JobID()),
)
sqlDB.ExpectErr(t,
`pq: invalid option "foobar"`,
fmt.Sprintf(`PREPARE set_bad_option AS ALTER CHANGEFEED %d SET foobar`, feed.JobID()),
)
sqlDB.ExpectErr(t,
`pq: invalid option "foobar"`,
fmt.Sprintf(`PREPARE unset_bad_option AS ALTER CHANGEFEED %d UNSET foobar`, feed.JobID()),
)
}
cdcTest(t, testFn, feedTestEnterpriseSinks)
}
```
**Expected behavior**
The above test should pass.
Notes:
Because SET and UNSET representations as tree.AlterChangefeedCmd both have cmd.Options but the options are of different types, implementing this isn't quite as trivial as it should be.
Jira issue: CRDB-56199
Contributor guide
Assessment
This issue has not been assessed yet.