mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 14:33:08 +00:00
To allow adding a GSI to an existing table (refs #11567), we plan to re-implement GSIs to stop forcing their key attribute to become a real column in the schema - and let it remains a member of the map ":attrs" like all non-key attributes. But since LSIs can only be defined on table creation time, we don't have to change the LSI implementation, and these can still force their key to become a real column. What the test in this patch does is to verify that using the same attribute as a key of *both* GSI and LSI on the same table works. There's a high risk that it won't work: After all, the LSI should force the attribute to become a real column (to which base reads and writes go), but the GSI will use a computed column which reads from ":attrs", no? Well, it turns out that view.cc's value_getter::operator() always had a surprising exception which "rescues" this test and makes it pass: Before using a computed column, this code checks if a base-table column with the same name exists, and if it does, it is used instead of the computed column! It's not clear why this logic was chosen, but it turns out to be really useful for making the test in this test pass. And it's important that if we ever change that unintuitive behavior, we will have this test as a regression test. The new test unsurprisingly passes on current Scylla because its implementation of GSI and LSI is still the same. But it's an important regression test for when we change the GSI implementation. Signed-off-by: Nadav Har'El <nyh@scylladb.com>