Merge branch 'cassandra-2.1' into cassandra-2.2 Conflicts: bin/cqlsh
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d6f9555b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d6f9555b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d6f9555b Branch: refs/heads/cassandra-2.2 Commit: d6f9555ba63f3c9d3e552cef14032add91aa5a9e Parents: 26bd512 5d9729b Author: Marcus Eriksson <marc...@apache.org> Authored: Fri Jun 26 08:21:06 2015 +0200 Committer: Marcus Eriksson <marc...@apache.org> Committed: Fri Jun 26 08:21:06 2015 +0200 ---------------------------------------------------------------------- CHANGES.txt | 2 +- bin/cqlsh | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 97 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/d6f9555b/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index d2f40af,70efc81..8cac598 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,23 -1,7 +1,23 @@@ -2.1.7 +2.2 * Allow JMX over SSL directly from nodetool (CASSANDRA-9090) - * Fix incorrect result for IN queries where column not found (CASSANDRA-9540) + * Update cqlsh for UDFs (CASSANDRA-7556) + * Change Windows kernel default timer resolution (CASSANDRA-9634) + * Deprected sstable2json and json2sstable (CASSANDRA-9618) + * Allow native functions in user-defined aggregates (CASSANDRA-9542) + * Don't repair system_distributed by default (CASSANDRA-9621) + * Fix mixing min, max, and count aggregates for blob type (CASSANRA-9622) + * Rename class for DATE type in Java driver (CASSANDRA-9563) + * Duplicate compilation of UDFs on coordinator (CASSANDRA-9475) + * Fix connection leak in CqlRecordWriter (CASSANDRA-9576) + * Mlockall before opening system sstables & remove boot_without_jna option (CASSANDRA-9573) + * Add functions to convert timeuuid to date or time, deprecate dateOf and unixTimestampOf (CASSANDRA-9229) + * Make sure we cancel non-compacting sstables from LifecycleTransaction (CASSANDRA-9566) + * Fix deprecated repair JMX API (CASSANDRA-9570) + * Add logback metrics (CASSANDRA-9378) + * Update and refactor ant test/test-compression to run the tests in parallel (CASSANDRA-9583) +Merged from 2.1: - + * Enable describe on indices (CASSANDRA-7814) + * Fix incorrect result for IN queries where column not found (CASSANDRA-9540) * ColumnFamilyStore.selectAndReference may block during compaction (CASSANDRA-9637) * Fix bug in cardinality check when compacting (CASSANDRA-9580) * Fix memory leak in Ref due to ConcurrentLinkedQueue.remove() behaviour (CASSANDRA-9549) http://git-wip-us.apache.org/repos/asf/cassandra/blob/d6f9555b/bin/cqlsh ---------------------------------------------------------------------- diff --cc bin/cqlsh index a556a92,9f872f8..ab295ed --- a/bin/cqlsh +++ b/bin/cqlsh @@@ -265,13 -264,10 +265,14 @@@ cqlsh_extra_syntax_rules = r'' ; <describeCommand> ::= ( "DESCRIBE" | "DESC" ) - ( "KEYSPACES" + ( "FUNCTIONS" ksname=<keyspaceName>? + | "FUNCTION" udf=<anyFunctionName> + | "AGGREGATES" ksname=<keyspaceName>? + | "AGGREGATE" uda=<userAggregateName> + | "KEYSPACES" | "KEYSPACE" ksname=<keyspaceName>? | ( "COLUMNFAMILY" | "TABLE" ) cf=<columnFamilyName> + | "INDEX" idx=<indexName> | ( "COLUMNFAMILIES" | "TABLES" ) | "FULL"? "SCHEMA" | "CLUSTER" @@@ -832,32 -802,42 +837,64 @@@ class Shell(cmd.Cmd) ksmeta = self.get_keyspace_meta(ksname) if tablename not in ksmeta.tables: + if ksname == 'system_auth' and tablename in ['roles', 'role_permissions']: + self.get_fake_auth_table_meta(ksname, tablename) + else: + raise ColumnFamilyNotFound("Column family %r not found" % tablename) + else: + return ksmeta.tables[tablename] + + def get_fake_auth_table_meta(self, ksname, tablename): + # may be using external auth implementation so internal tables + # aren't actually defined in schema. In this case, we'll fake + # them up + if tablename == 'roles': + ks_meta = KeyspaceMetadata(ksname, True, None, None) + table_meta = TableMetadata(ks_meta, 'roles') + table_meta.columns['role'] = ColumnMetadata(table_meta, 'role', cassandra.cqltypes.UTF8Type) + table_meta.columns['is_superuser'] = ColumnMetadata(table_meta, 'is_superuser', cassandra.cqltypes.BooleanType) + table_meta.columns['can_login'] = ColumnMetadata(table_meta, 'can_login', cassandra.cqltypes.BooleanType) + elif tablename == 'role_permissions': + ks_meta = KeyspaceMetadata(ksname, True, None, None) + table_meta = TableMetadata(ks_meta, 'role_permissions') + table_meta.columns['role'] = ColumnMetadata(table_meta, 'role', cassandra.cqltypes.UTF8Type) + table_meta.columns['resource'] = ColumnMetadata(table_meta, 'resource', cassandra.cqltypes.UTF8Type) + table_meta.columns['permission'] = ColumnMetadata(table_meta, 'permission', cassandra.cqltypes.UTF8Type) + else: raise ColumnFamilyNotFound("Column family %r not found" % tablename) - return ksmeta.tables[tablename] - + def get_index_meta(self, ksname, idxname): + if ksname is None: + ksname = self.current_keyspace + ksmeta = self.get_keyspace_meta(ksname) + + if idxname not in ksmeta.indexes: + raise IndexNotFound("Index %r not found" % idxname) + + return ksmeta.indexes[idxname] + + def get_object_meta(self, ks, name): + if name is None: + if ks and ks in self.conn.metadata.keyspaces: + return self.conn.metadata.keyspaces[ks] + elif self.current_keyspace is None: + raise ObjectNotFound("%r not found in keyspaces" % (ks)) + else: + name = ks + ks = self.current_keyspace + + if ks is None: + ks = self.current_keyspace + + ksmeta = self.get_keyspace_meta(ks) + + if name in ksmeta.tables: + return ksmeta.tables[name] + elif name in ksmeta.indexes: + return ksmeta.indexes[name] + + raise ObjectNotFound("%r not found in keyspace %r" % (name, ks)) + def get_usertypes_meta(self): data = self.session.execute("select * from system.schema_usertypes") if not data: @@@ -1476,40 -1414,16 +1549,45 @@@ Works as though "DESCRIBE KEYSPACE k" was invoked for each non-system keyspace k. Use DESCRIBE FULL SCHEMA to include the system keyspaces. + DESCRIBE FUNCTIONS <keyspace> + + Output the names of all user defined functions in the given keyspace. + + DESCRIBE FUNCTION [<keyspace>.]<function> + + Describe the given user defined function. + + DESCRIBE AGGREGATES <keyspace> + + Output the names of all user defined aggregates in the given keyspace. + + DESCRIBE AGGREGATE [<keyspace>.]<aggregate> + + Describe the given user defined aggregate. - """ ++ + DESCRIBE <objname> + + Output CQL commands that could be used to recreate the entire object schema, + where object can be either a keyspace or a table or an index (in this order). - - """ ++ """ what = parsed.matched[1][1].lower() - if what == 'keyspaces': + if what == 'functions': + ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) + self.describe_functions(ksname) + elif what == 'function': + ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) + functionname = self.cql_unprotect_name(parsed.get_binding('udfname')) + self.describe_function(ksname, functionname) + elif what == 'aggregates': + ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) + self.describe_aggregates(ksname) + elif what == 'aggregate': + ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) + aggregatename = self.cql_unprotect_name(parsed.get_binding('udaname')) + self.describe_aggregate(ksname, aggregatename) + elif what == 'keyspaces': self.describe_keyspaces() - if what == 'keyspace': + elif what == 'keyspace': ksname = self.cql_unprotect_name(parsed.get_binding('ksname', '')) if not ksname: ksname = self.current_keyspace