Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE86EE046 for ; Mon, 4 Feb 2013 09:45:20 +0000 (UTC) Received: (qmail 30982 invoked by uid 500); 4 Feb 2013 09:45:20 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 30781 invoked by uid 500); 4 Feb 2013 09:45:19 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 29909 invoked by uid 99); 4 Feb 2013 09:44:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 09:44:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 99797829AAF; Mon, 4 Feb 2013 09:44:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: slebresne@apache.org To: commits@cassandra.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: Deprecate but keep strings-as-blob support for now for compatibility sake Message-Id: <20130204094441.99797829AAF@tyr.zones.apache.org> Date: Mon, 4 Feb 2013 09:44:41 +0000 (UTC) Updated Branches: refs/heads/cassandra-1.2 60acf0d79 -> b251e7aec Deprecate but keep strings-as-blob support for now for compatibility sake Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b251e7ae Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b251e7ae Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b251e7ae Branch: refs/heads/cassandra-1.2 Commit: b251e7aec03273ac14eeae79bee13422068d508b Parents: 60acf0d Author: Sylvain Lebresne Authored: Mon Feb 4 10:44:30 2013 +0100 Committer: Sylvain Lebresne Committed: Mon Feb 4 10:44:30 2013 +0100 ---------------------------------------------------------------------- NEWS.txt | 5 +++- doc/cql3/CQL.textile | 3 +- src/java/org/apache/cassandra/cql3/Term.java | 22 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b251e7ae/NEWS.txt ---------------------------------------------------------------------- diff --git a/NEWS.txt b/NEWS.txt index 5a6e4f5..7e04b2e 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -16,7 +16,10 @@ Upgrading - CQL3 type validation for constants has been fixed, which may require fixing queries that were relying on the previous loose validation. Please refer to the CQL3 documentation (http://cassandra.apache.org/doc/cql3/CQL.html) - and in particular the changelog section for more details. + and in particular the changelog section for more details. Please note in + particular that inputing blobs as strings constants is now deprecated (in + favor of blob constants) and its support will be removed in a future + version. 1.2.1 http://git-wip-us.apache.org/repos/asf/cassandra/blob/b251e7ae/doc/cql3/CQL.textile ---------------------------------------------------------------------- diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile index 35b75bf..9611608 100644 --- a/doc/cql3/CQL.textile +++ b/doc/cql3/CQL.textile @@ -1007,7 +1007,8 @@ The following describes the addition/changes brought for each version of CQL. h3. 3.0.2 -- Type validation for the "constants":#constants has been fixed. For instance, the implementation used to allow @'2'@ as a valid value for an @int@ column (interpreting it has the equivalent of @2@), or @42@ as a valid @blob@ value (in which case @42@ was interpreted as an hexadecimal representation of the blob). This is no longer the case, type validation of constants is now more strict. See the "data types":#dataTypes section for details on which constant is allowed for which type, but note that this let to the introduction of "blobs constants":#constants. +- Type validation for the "constants":#constants has been fixed. For instance, the implementation used to allow @'2'@ as a valid value for an @int@ column (interpreting it has the equivalent of @2@), or @42@ as a valid @blob@ value (in which case @42@ was interpreted as an hexadecimal representation of the blob). This is no longer the case, type validation of constants is now more strict. See the "data types":#dataTypes section for details on which constant is allowed for which type. +- The type validation fixed of the previous point has lead to the introduction of "blobs constants":#constants to allow inputing blobs. Do note that while inputing blobs as strings constant is still supported by this version (to allow smoother transition to blob constant), it is now deprecated (in particular the "data types":#dataTypes section does not list strings constants as valid blobs) and will be removed by a future version. If you were using strings as blobs, you should thus update your client code asap to switch blob constants. h3. 3.0.1 http://git-wip-us.apache.org/repos/asf/cassandra/blob/b251e7ae/src/java/org/apache/cassandra/cql3/Term.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/Term.java b/src/java/org/apache/cassandra/cql3/Term.java index b3c312e..fb797d5 100644 --- a/src/java/org/apache/cassandra/cql3/Term.java +++ b/src/java/org/apache/cassandra/cql3/Term.java @@ -22,6 +22,9 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.db.marshal.BytesType; import org.apache.cassandra.db.marshal.MarshalException; @@ -30,6 +33,8 @@ import org.apache.cassandra.exceptions.InvalidRequestException; /** A term parsed from a CQL statement. */ public class Term { + private static final Logger logger = LoggerFactory.getLogger(Term.class); + public enum Type { STRING, INTEGER, UUID, FLOAT, BOOLEAN, HEX, QMARK; @@ -60,6 +65,9 @@ public class Term public final int bindIndex; public final boolean isToken; + // For transition post-5198, see below + private static volatile boolean stringAsBlobWarningLogged = false; + // This is a hack for the timeuuid functions (minTimeuuid, maxTimeuuid, now) because instead of handling them as // true function we let the TimeUUID.fromString() method handle it. We should probably clean that up someday private final boolean skipTypeValidation; @@ -168,6 +176,20 @@ public class Term if (!supported.contains(type)) { + // Blobs should now be inputed as hexadecimal constants. However, to allow people to upgrade, we still allow + // blob-as-strings, even though it is deprecated (see #5198). + if (type == Type.STRING && validator instanceof BytesType) + { + if (!stringAsBlobWarningLogged) + { + stringAsBlobWarningLogged = true; + logger.warn("Inputing CLQ3 blobs as strings (like %s = '%s') is now deprecated and will be removed in a future version. " + + "You should convert client code to use a blob constant (%s = %s) instead (see http://cassandra.apache.org/doc/cql3/CQL.html changelog section for more info).", + identifier, text, identifier, "0x" + text); + } + return; + } + // TODO: Ideallly we'd keep the declared CQL3 type of columns and use that in the following message, instead of the AbstracType class name. throw new InvalidRequestException(String.format("Invalid %s constant for %s of type %s", type, identifier, validator.asCQL3Type())); }