Avoid potential AttributeError in cqlsh due to no table metadata

Patch by Stefania Alborghetti; reviewed by Robert Stupp for CASSANDRA-12815


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/13b73624
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/13b73624
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/13b73624

Branch: refs/heads/trunk
Commit: 13b7362494c4c0ff3c5ce80b8e7ee7fe64d65785
Parents: 3cb0233
Author: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Authored: Thu Oct 20 10:06:50 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Committed: Tue Oct 25 10:03:21 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt  | 1 +
 bin/cqlsh.py | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/13b73624/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d1f2677..ef728c7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * Avoid potential AttributeError in cqlsh due to no table metadata 
(CASSANDRA-12815)
  * Fix RandomReplicationAwareTokenAllocatorTest.testExistingCluster 
(CASSANDRA-12812)
  * Upgrade commons-codec to 1.9 (CASSANDRA-12790)
  * Make the fanout size for LeveledCompactionStrategy to be configurable 
(CASSANDRA-11550)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/13b73624/bin/cqlsh.py
----------------------------------------------------------------------
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index e741752..072ef08 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -1334,7 +1334,8 @@ class Shell(cmd.Cmd):
 
         cql_types = []
         if result.column_types:
-            ks_meta = self.conn.metadata.keyspaces[table_meta.keyspace_name]
+            ks_name = table_meta.keyspace_name if table_meta else 
self.current_keyspace
+            ks_meta = self.conn.metadata.keyspaces.get(ks_name, None)
             cql_types = [CqlType(cql_typename(t), ks_meta) for t in 
result.column_types]
 
         formatted_values = [map(self.myformat_value, row.values(), cql_types) 
for row in result.current_rows]

Reply via email to