[
https://issues.apache.org/jira/browse/CASSANDRA-6643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13887915#comment-13887915
]
Russ Hatch commented on CASSANDRA-6643:
---------------------------------------
[~slebresne]
yeah, I can currently rename to another keyspace but think maybe we shouldn't
allow it (or at least implicitly name into the same ks implicitly when no ks
prefix is on the rename's 'destination').
The rename to another ks works even if a table in the 'old' keyspace depends on
the type, so I do think as-is it would be possible to get the types/tables into
a weird or at least confusing state.
This scenario shows we can make a table depend on a type then rename that type
into another keyspace:
{noformat}
cqlsh> create keyspace user_types with replication = {'class':'SimpleStrategy',
'replication_factor':3} ;
cqlsh> create keyspace user_types2 with replication =
{'class':'SimpleStrategy', 'replication_factor':3} ;
cqlsh> CREATE TYPE user_types.simple_type (user_number int);
cqlsh> CREATE TABLE user_types.simple_table (
... id uuid PRIMARY KEY,
... number simple_type
... );
cqlsh> alter type user_types.simple_type rename to user_types2.simple_type;
{noformat}
We do still enforce the correct relationship when trying to drop the type in
use though, but now there's a type in one ks dependent on a table in another ks:
{noformat}
cqlsh> drop type user_types2.simple_type;
Bad Request: Cannot drop user type user_types2.simple_type as it is still used
by table user_types.simple_table
{noformat}
> ALTER TYPE RENAME allows renaming to another keyspace
> -----------------------------------------------------
>
> Key: CASSANDRA-6643
> URL: https://issues.apache.org/jira/browse/CASSANDRA-6643
> Project: Cassandra
> Issue Type: Bug
> Environment: java version "1.7.0_51"
> cassandra from trunk, 4b54b8...
> Reporter: Russ Hatch
> Priority: Minor
>
> I'm not 100% certain this is a bug.
> The current syntax for "alter type rename" requires the keyspace on the old
> and new table name (if a keyspace is not active). So, to rename the type
> 'foo' to 'bar', you have to issue this statement:
> ALTER TYPE ks.foo rename to ks.bar .
> As a result, this syntax will also allow renaming the type into another
> existing keyspace, which updates the metadata in system.schema_usertypes.
> I'm wondering if perhaps we can omit the second keyspace prefix and
> implicitly rename into the same keyspace.
> To reproduce:
> {noformat}
> cqlsh> create keyspace user_types with replication =
> {'class':'SimpleStrategy', 'replication_factor':3} ;
> cqlsh> create keyspace user_types2 with replication =
> {'class':'SimpleStrategy', 'replication_factor':3} ;
> cqlsh> CREATE TYPE user_types.simple_type (user_number int);
> cqlsh> alter type user_types.simple_type rename to user_types2.simple_type;
> {noformat}
> Renaming to another keyspace is also possible when a keyspace is active, like
> so:
> {noformat}
> cqlsh:user_types> alter type simple_type rename to user_types2.simple_type;
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)