sql/schemachanger: ALTER PRIMARY KEY .. USING HASH can make the hash column public too late
Previously, in the legacy schema changer, when executing ALTER TABLE PRIMARY KEY .. USING HASH... we have stages where a new primary index is public without all the columns inside it being public. This is unexpected, since the key columns / storing referenced in the primary key should be public at the same time as the index. This can cause issues for CDC: https://github.com/wenyihu6/cockroach/blob/2d4f2a14a05b8e23a134cad42b435886657f8172/pkg/ccl/changefeedccl/cdcevent/event.go#L312
We should ideally make sure the columns referenced by the primary key index are public at the same time. Or at the very least ensure this is guaranteed for key columns.
Jira issue: CRDB-41028
Epic CRDB-40419
Digging into this more, I don't think there is any nice options here. I think it makes sense to have the column not be public but still be in the primary index, otherwise we can't support comma syntax properly (i.e. rollbacks would break). I'm going to make a patch for the CDC logic to tolerate this and add coverage.
While working on this, can you also see if you can identify why https://github.com/cockroachdb/cockroach/issues/128420 is happening?