demo@127.0.0.1:26257/demoapp/movr> CREATE TABLE public.table_w1_14 (i int not null);
CREATE TABLE
Time: 4ms total (execution 4ms / network 0ms)
Time: 175ms total (execution 174ms / network 0ms)
demo@127.0.0.1:26257/demoapp/movr> ALTER TABLE public.table_w1_14 ADD COLUMN col_w1_14_w1_122 BOX2D NULL UNIQUE, ALTER
-> PRIMARY KEY USING COLUMNS (i) USING HASH;
ERROR: internal error: building declarative schema change targets for ALTER TABLE: programming error: cannot find any KEY index columns in index 2 from table 113
SQLSTATE: XX000
DETAIL: stack trace:
...
called from shouldCreateUniqueIndexOnOldPrimaryKeyColumns.
Not entirely sure what is going on, but we intentionally call on this code with the ID of the new index for the PK and expect it to succeed so either we should readjust our expectations or the order of how we add IndexColumns to the builder is off for this case
This is coming from getting the IndexColumn elements in https://github.com/cockroachdb/cockroach/blob/3225b9a532e1a6650651fd548df88cb491b67178/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go#L584-L587
called from
shouldCreateUniqueIndexOnOldPrimaryKeyColumns
.Not entirely sure what is going on, but we intentionally call on this code with the ID of the new index for the PK and expect it to succeed so either we should readjust our expectations or the order of how we add IndexColumns to the builder is off for this case
Jira issue: CRDB-41003
Epic CRDB-40419