cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Edge (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CASSANDRA-10760) Counters are erroneously allowed as map key type
Date Wed, 25 Nov 2015 10:03:10 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-10760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15026524#comment-15026524
] 

Michael Edge edited comment on CASSANDRA-10760 at 11/25/15 10:02 AM:
---------------------------------------------------------------------

[~iamaleksey], if this is what you're expecting I'll create patches for v2.1 and v2.2.

{noformat}
cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor':
1};
cqlsh> create table test.test (id int primary key, amap map<counter, text>);
InvalidRequest: code=2200 [Invalid query] message="Counters are not allowed as keys inside
collections: map<counter, text>"
cqlsh> create table test.test (id int primary key, amap map<int, counter>);
InvalidRequest: code=2200 [Invalid query] message="Counters are not allowed as values inside
collections: map<int, counter>"
{noformat}

One thing I'm not 100% sure of is whether we allow counters as map keys for supercolumns.
Seems we do allow counters as map values for supercolumns. If we do not allow them as map
keys then the {{isInternal}} check in the patch can be removed.

{code}
+                    if (keys.isCounter() && !isInternal)
+                        throw new InvalidRequestException("Counters are not allowed as keys
inside collections: " + this);
{code}



was (Author: michaeledge):
[~iamaleksey], if this is what you're expecting I'll create patches for v2.1 and v2.2.

{noformat}
cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor':
1};
cqlsh> create table test.test (id int primary key, amap map<counter, text>);
InvalidRequest: code=2200 [Invalid query] message="Counters are not allowed as keys inside
collections: map<counter, text>"
cqlsh> create table test.test (id int primary key, amap map<int, counter>);
InvalidRequest: code=2200 [Invalid query] message="Counters are not allowed as values inside
collections: map<int, counter>"
{noformat}

> Counters are erroneously allowed as map key type
> ------------------------------------------------
>
>                 Key: CASSANDRA-10760
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10760
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>            Reporter: Aleksey Yeschenko
>            Priority: Minor
>             Fix For: 2.1.x, 2.2.x, 3.0.x
>
>
> We do validate collection value types, but not collection key types, which allows counters
to be used as map keys:
> {noformat}
> cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor':
1};
> cqlsh> use test;
> cqlsh:test> create table test.test (id int primary key, amap map<counter, text>);
> cqlsh:test> insert into test.test (id, amap) values (0, {1: '2'});
> cqlsh:test> select * from test.test;
>  id | amap
> ----+----------
>   0 | {1: '2'}
> (1 rows)
> {noformat}
> This should obviously not be allowed and must be rejected.
> /cc [~slebresne]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message