Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong key type used when creating non-frozen map virtual column #5165

Closed
kbr- opened this issue Oct 11, 2019 · 3 comments
Closed

wrong key type used when creating non-frozen map virtual column #5165

kbr- opened this issue Oct 11, 2019 · 3 comments

Comments

@kbr-
Copy link
Contributor

@kbr- kbr- commented Oct 11, 2019

version: master, been there for some time though
in db/view/view.cc:

        builder.with_column(name, map_type_impl::get_instance(mtype->get_values_type(), empty_type, true), column_kind::regular_column, column_view_virtual::yes);

should be mtype->get_keys_type().

kbr- added a commit to kbr-/scylla that referenced this issue Oct 11, 2019
When creating a virtual column of non-frozen map type,
the wrong type was used for the map's keys.

Fixes scylladb#5165.
avikivity added a commit that referenced this issue Nov 18, 2019
When creating a virtual column of non-frozen map type,
the wrong type was used for the map's keys.

Fixes #5165.

(cherry picked from commit ef9d575)
avikivity added a commit that referenced this issue Nov 18, 2019
When creating a virtual column of non-frozen map type,
the wrong type was used for the map's keys.

Fixes #5165.

(cherry picked from commit ef9d575)
@avikivity

This comment has been minimized.

Copy link
Contributor

@avikivity avikivity commented Nov 18, 2019

Backported to 3.0, 3.1.

avikivity added a commit that referenced this issue Nov 19, 2019
When creating a virtual column of non-frozen map type,
the wrong type was used for the map's keys.

Fixes #5165.

(cherry picked from commit ef9d575)
@tzach

This comment has been minimized.

Copy link
Contributor

@tzach tzach commented Nov 28, 2019

@kbr- when this might happen? can you give a CQL example?

@kbr-

This comment has been minimized.

Copy link
Contributor Author

@kbr- kbr- commented Nov 28, 2019

create table a (a int, b int, c map<int, text>, primary key (a, b));
create materialized view v as select a, b
create materialized view v AS select a, b from a where b is not null primary key (b, a);
select * from system_schema.view_virtual_columns ;

 keyspace_name | table_name | column_name | clustering_order | column_name_bytes | kind    | position | type
---------------+------------+-------------+------------------+-------------------+---------+----------+-----------------
             d |          v |           c |             NONE |              0x63 | regular |       -1 | map<int, empty>

the map<int, empty> would instead be map<text, empty>.

I'm not sure if this actually makes anything crash or work incorrectly. The virtual columns are there to check liveness, so we're only interested in timestamps in their mutations. But there is a piece of code that could serialize a text field while thinking that it's an int field, or the other way around. Maybe it could cause some undefined behavior. I tried to insert big text keys when the serialization code thought it was an int, but I didn't notice anything strange happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.