Detect (and warn) unintentional use of the cql2 thrift methods when cql3 was 
intended

patch by slebresne; reviewed by jbellis for CASSANDRA-5172


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

Branch: refs/heads/trunk
Commit: 056f38cc185702c865eb1d4a2f1ed1599300e1d3
Parents: 19972bd
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Fri Jan 18 17:03:23 2013 +0100
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Fri Jan 18 17:03:23 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 ++
 NEWS.txt                                           |    5 +++++
 .../apache/cassandra/thrift/CassandraServer.java   |   11 ++++++++++-
 3 files changed, 17 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/056f38cc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 16172ec..86743ca 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -40,6 +40,8 @@
  * Coverage analysis for low-CL queries (CASSANDRA-4858)
  * Stop interpreting dates as valid timeUUID value (CASSANDRA-4936)
  * Adds E notation for floating point numbers (CASSANDRA-4927)
+ * Detect (and warn) unintentional use of the cql2 thrift methods when cql3 was
+   intended (CASSANDRA-5172)
 Merged from 1.1:
  * Simplify CompressedRandomAccessReader to work around JDK FD bug 
(CASSANDRA-5088)
  * Improve handling a changing target throttle rate mid-compaction 
(CASSANDRA-5087)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/056f38cc/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 3902d05..e1e842c 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -21,6 +21,11 @@ Upgrading
       representation), but the new dateOf method can be used instead. Please
       refer to the reference documentation 
(http://cassandra.apache.org/doc/cql3/CQL.html)
       for more detail.
+    - Calling the set_cql_version of the thrift interface with a version that
+      don't start with 2 now raise an error (instead of being a no-op). Not
+      raising an error in that case makes it hard for CQL3 client that haven't
+      upgraded to use the new thrift CQL3 methods to understand what is going
+      wrong.
 
 
 1.2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/056f38cc/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java 
b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 7e5faf9..ce533f4 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -1842,9 +1842,18 @@ public class CassandraServer implements Cassandra.Iface
         }
     }
 
+    /*
+     * Deprecated, but if a client sets CQL2, it is a no-op for compatibility 
sake.
+     * If it sets CQL3 however, we throw an IRE because this mean the client
+     * hasn't been updated for Cassandra 1.2 and should start using the new
+     * execute_cql3_query, etc... and there is no point no warning it early.
+     */
     public void set_cql_version(String version) throws InvalidRequestException
     {
-        // Deprecated, no-op
+        if (version.trim().startsWith("2"))
+            return;
+
+        throw new InvalidRequestException("Invalid use of the CQL thrift 
interface. This most likely mean the client you are using has not been updated 
for Cassandra 1.2");
     }
 
     public ByteBuffer trace_next_query() throws TException

Reply via email to