You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/02/04 18:27:26 UTC
[1/3] cassandra git commit: Add support for UPDATE ... IF EXISTS
Repository: cassandra
Updated Branches:
refs/heads/trunk 32b82879d -> 296d11b98
Add support for UPDATE ... IF EXISTS
Patch by Prajakta Bhosale; reviewed by Tyler Hobbs for CASSANDRA-8610
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0f5ab577
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0f5ab577
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0f5ab577
Branch: refs/heads/trunk
Commit: 0f5ab577bcc106aa487dd5b05ca0b991c9a96a04
Parents: 2d8bddb
Author: Prajakta Bhosale <pr...@yahoo.co.in>
Authored: Wed Feb 4 11:23:41 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Feb 4 11:23:41 2015 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/cql3handling.py | 2 +-
pylib/cqlshlib/helptopics.py | 3 ++-
src/java/org/apache/cassandra/cql3/Cql.g | 6 ++++--
.../apache/cassandra/cql3/statements/UpdateStatement.java | 8 +++++---
5 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0f5ab577/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 375dcfe..f4c96dc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.0.13:
+ * Add support for UPDATE ... IF EXISTS (CASSANDRA-8610)
* Fix reversal of list prepends (CASSANDRA-8733)
* Prevent non-zero default_time_to_live on tables with counters
(CASSANDRA-8678)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0f5ab577/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 0b7863c..9e9b6ad 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -15,7 +15,6 @@
# limitations under the License.
import re
-from warnings import warn
from .cqlhandling import CqlParsingRuleSet, Hint
from cql.cqltypes import (cql_types, lookup_casstype, CompositeType, UTF8Type,
ColumnToCollectionType, CounterColumnType, DateType)
@@ -715,6 +714,7 @@ syntax_rules += r'''
( "AND" [updateopt]=<usingOption> )* )?
"SET" <assignment> ( "," <assignment> )*
"WHERE" <whereClause>
+ ( "IF" "EXISTS" )?
;
<assignment> ::= updatecol=<cident>
( "=" update_rhs=( <value> | <cident> )
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0f5ab577/pylib/cqlshlib/helptopics.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/helptopics.py b/pylib/cqlshlib/helptopics.py
index 2af8db2..0b08726 100644
--- a/pylib/cqlshlib/helptopics.py
+++ b/pylib/cqlshlib/helptopics.py
@@ -563,7 +563,8 @@ class CQL3HelpTopics(CQLHelpTopics):
UPDATE [<keyspace>.]<columnFamily>
[USING [TIMESTAMP <timestamp>]
[AND TTL <timeToLive>]]
- SET name1 = value1, name2 = value2 WHERE <keycol> = keyval;
+ SET name1 = value1, name2 = value2 WHERE <keycol> = keyval
+ [IF EXISTS];
An UPDATE is used to write one or more columns to a record in a table.
No results are returned. The record's primary key must be completely
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0f5ab577/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g
index a80746c..0595c25 100644
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@ -360,18 +360,20 @@ updateStatement returns [UpdateStatement.ParsedUpdate expr]
@init {
Attributes.Raw attrs = new Attributes.Raw();
List<Pair<ColumnIdentifier.Raw, Operation.RawUpdate>> operations = new ArrayList<Pair<ColumnIdentifier.Raw, Operation.RawUpdate>>();
+ boolean ifExists = false;
}
: K_UPDATE cf=columnFamilyName
( usingClause[attrs] )?
K_SET columnOperation[operations] (',' columnOperation[operations])*
K_WHERE wclause=whereClause
- ( K_IF conditions=updateConditions )?
+ ( K_IF ( K_EXISTS { ifExists = true; } | conditions=updateConditions ))?
{
return new UpdateStatement.ParsedUpdate(cf,
attrs,
operations,
wclause,
- conditions == null ? Collections.<Pair<ColumnIdentifier.Raw, ColumnCondition.Raw>>emptyList() : conditions);
+ conditions == null ? Collections.<Pair<ColumnIdentifier.Raw, ColumnCondition.Raw>>emptyList() : conditions,
+ ifExists);
}
;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0f5ab577/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
index 9d98c84..594b5db 100644
--- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
@@ -207,14 +207,16 @@ public class UpdateStatement extends ModificationStatement
* @param attrs additional attributes for statement (timestamp, timeToLive)
* @param updates a map of column operations to perform
* @param whereClause the where clause
- */
+ * @param ifExists flag to check if row exists
+ * */
public ParsedUpdate(CFName name,
Attributes.Raw attrs,
List<Pair<ColumnIdentifier.Raw, Operation.RawUpdate>> updates,
List<Relation> whereClause,
- List<Pair<ColumnIdentifier.Raw, ColumnCondition.Raw>> conditions)
+ List<Pair<ColumnIdentifier.Raw, ColumnCondition.Raw>> conditions,
+ boolean ifExists)
{
- super(name, attrs, conditions, false, false);
+ super(name, attrs, conditions, false, ifExists);
this.updates = updates;
this.whereClause = whereClause;
}
[3/3] cassandra git commit: Merge branch 'cassandra-2.1' into trunk
Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/296d11b9
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/296d11b9
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/296d11b9
Branch: refs/heads/trunk
Commit: 296d11b985a7c15cedf8d95ca85a596db48dc470
Parents: 32b8287 bcfb652
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Feb 4 11:27:17 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Feb 4 11:27:17 2015 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/cql3handling.py | 2 +-
pylib/cqlshlib/helptopics.py | 3 ++-
src/java/org/apache/cassandra/cql3/Cql.g | 6 ++++--
.../apache/cassandra/cql3/statements/UpdateStatement.java | 8 +++++---
5 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/296d11b9/CHANGES.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/296d11b9/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/296d11b9/pylib/cqlshlib/helptopics.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/296d11b9/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/296d11b9/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------
[2/3] cassandra git commit: Merge branch 'cassandra-2.0' into
cassandra-2.1
Posted by ty...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts:
CHANGES.txt
pylib/cqlshlib/cql3handling.py
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bcfb652b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bcfb652b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bcfb652b
Branch: refs/heads/trunk
Commit: bcfb652b1a6dece77cce3e09ece2d0ef6fec9598
Parents: dc74ae6 0f5ab57
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Feb 4 11:26:55 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Feb 4 11:26:55 2015 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/cql3handling.py | 2 +-
pylib/cqlshlib/helptopics.py | 3 ++-
src/java/org/apache/cassandra/cql3/Cql.g | 6 ++++--
.../apache/cassandra/cql3/statements/UpdateStatement.java | 8 +++++---
5 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfb652b/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index f70db7a,f4c96dc..192939b
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,90 -1,5 +1,91 @@@
-2.0.13:
+2.1.3
+ * Upgrade libthrift to 0.9.2 (CASSANDRA-8685)
+ * Don't use the shared ref in sstableloader (CASSANDRA-8704)
+ * Purge internal prepared statements if related tables or
+ keyspaces are dropped (CASSANDRA-8693)
+ * (cqlsh) Handle unicode BOM at start of files (CASSANDRA-8638)
+ * Stop compactions before exiting offline tools (CASSANDRA-8623)
+ * Update tools/stress/README.txt to match current behaviour (CASSANDRA-7933)
+ * Fix schema from Thrift conversion with empty metadata (CASSANDRA-8695)
+ * Safer Resource Management (CASSANDRA-7705)
+ * Make sure we compact highly overlapping cold sstables with
+ STCS (CASSANDRA-8635)
+ * rpc_interface and listen_interface generate NPE on startup when specified
+ interface doesn't exist (CASSANDRA-8677)
+ * Fix ArrayIndexOutOfBoundsException in nodetool cfhistograms (CASSANDRA-8514)
+ * Switch from yammer metrics for nodetool cf/proxy histograms (CASSANDRA-8662)
+ * Make sure we don't add tmplink files to the compaction
+ strategy (CASSANDRA-8580)
+ * (cqlsh) Handle maps with blob keys (CASSANDRA-8372)
+ * (cqlsh) Handle DynamicCompositeType schemas correctly (CASSANDRA-8563)
+ * Duplicate rows returned when in clause has repeated values (CASSANDRA-6707)
+ * Add tooling to detect hot partitions (CASSANDRA-7974)
+ * Fix cassandra-stress user-mode truncation of partition generation (CASSANDRA-8608)
+ * Only stream from unrepaired sstables during inc repair (CASSANDRA-8267)
+ * Don't allow starting multiple inc repairs on the same sstables (CASSANDRA-8316)
+ * Invalidate prepared BATCH statements when related tables
+ or keyspaces are dropped (CASSANDRA-8652)
+ * Fix missing results in secondary index queries on collections
+ with ALLOW FILTERING (CASSANDRA-8421)
+ * Expose EstimatedHistogram metrics for range slices (CASSANDRA-8627)
+ * (cqlsh) Escape clqshrc passwords properly (CASSANDRA-8618)
+ * Fix NPE when passing wrong argument in ALTER TABLE statement (CASSANDRA-8355)
+ * Pig: Refactor and deprecate CqlStorage (CASSANDRA-8599)
+ * Don't reuse the same cleanup strategy for all sstables (CASSANDRA-8537)
+ * Fix case-sensitivity of index name on CREATE and DROP INDEX
+ statements (CASSANDRA-8365)
+ * Better detection/logging for corruption in compressed sstables (CASSANDRA-8192)
+ * Use the correct repairedAt value when closing writer (CASSANDRA-8570)
+ * (cqlsh) Handle a schema mismatch being detected on startup (CASSANDRA-8512)
+ * Properly calculate expected write size during compaction (CASSANDRA-8532)
+ * Invalidate affected prepared statements when a table's columns
+ are altered (CASSANDRA-7910)
+ * Stress - user defined writes should populate sequentally (CASSANDRA-8524)
+ * Fix regression in SSTableRewriter causing some rows to become unreadable
+ during compaction (CASSANDRA-8429)
+ * Run major compactions for repaired/unrepaired in parallel (CASSANDRA-8510)
+ * (cqlsh) Fix compression options in DESCRIBE TABLE output when compression
+ is disabled (CASSANDRA-8288)
+ * (cqlsh) Fix DESCRIBE output after keyspaces are altered (CASSANDRA-7623)
+ * Make sure we set lastCompactedKey correctly (CASSANDRA-8463)
+ * (cqlsh) Fix output of CONSISTENCY command (CASSANDRA-8507)
+ * (cqlsh) Fixed the handling of LIST statements (CASSANDRA-8370)
+ * Make sstablescrub check leveled manifest again (CASSANDRA-8432)
+ * Check first/last keys in sstable when giving out positions (CASSANDRA-8458)
+ * Disable mmap on Windows (CASSANDRA-6993)
+ * Add missing ConsistencyLevels to cassandra-stress (CASSANDRA-8253)
+ * Add auth support to cassandra-stress (CASSANDRA-7985)
+ * Fix ArrayIndexOutOfBoundsException when generating error message
+ for some CQL syntax errors (CASSANDRA-8455)
+ * Scale memtable slab allocation logarithmically (CASSANDRA-7882)
+ * cassandra-stress simultaneous inserts over same seed (CASSANDRA-7964)
+ * Reduce cassandra-stress sampling memory requirements (CASSANDRA-7926)
+ * Ensure memtable flush cannot expire commit log entries from its future (CASSANDRA-8383)
+ * Make read "defrag" async to reclaim memtables (CASSANDRA-8459)
+ * Remove tmplink files for offline compactions (CASSANDRA-8321)
+ * Reduce maxHintsInProgress (CASSANDRA-8415)
+ * BTree updates may call provided update function twice (CASSANDRA-8018)
+ * Release sstable references after anticompaction (CASSANDRA-8386)
+ * Handle abort() in SSTableRewriter properly (CASSANDRA-8320)
+ * Fix high size calculations for prepared statements (CASSANDRA-8231)
+ * Centralize shared executors (CASSANDRA-8055)
+ * Fix filtering for CONTAINS (KEY) relations on frozen collection
+ clustering columns when the query is restricted to a single
+ partition (CASSANDRA-8203)
+ * Do more aggressive entire-sstable TTL expiry checks (CASSANDRA-8243)
+ * Add more log info if readMeter is null (CASSANDRA-8238)
+ * add check of the system wall clock time at startup (CASSANDRA-8305)
+ * Support for frozen collections (CASSANDRA-7859)
+ * Fix overflow on histogram computation (CASSANDRA-8028)
+ * Have paxos reuse the timestamp generation of normal queries (CASSANDRA-7801)
+ * Fix incremental repair not remove parent session on remote (CASSANDRA-8291)
+ * Improve JBOD disk utilization (CASSANDRA-7386)
+ * Log failed host when preparing incremental repair (CASSANDRA-8228)
+ * Force config client mode in CQLSSTableWriter (CASSANDRA-8281)
+ * Fix sstableupgrade throws exception (CASSANDRA-8688)
+ * Fix hang when repairing empty keyspace (CASSANDRA-8694)
+Merged from 2.0:
+ * Add support for UPDATE ... IF EXISTS (CASSANDRA-8610)
* Fix reversal of list prepends (CASSANDRA-8733)
* Prevent non-zero default_time_to_live on tables with counters
(CASSANDRA-8678)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfb652b/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/cql3handling.py
index b7b052a,9e9b6ad..31f0de2
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@@ -754,19 -714,14 +754,19 @@@ syntax_rules += r''
( "AND" [updateopt]=<usingOption> )* )?
"SET" <assignment> ( "," <assignment> )*
"WHERE" <whereClause>
- ( "IF" <conditions> )?
- ( "IF" "EXISTS" )?
++ ( "IF" ( "EXISTS" | <conditions> ))?
;
<assignment> ::= updatecol=<cident>
- ( "=" update_rhs=( <value> | <cident> )
+ ( "=" update_rhs=( <term> | <cident> )
( counterop=( "+" | "-" ) inc=<wholenumber>
- | listadder="+" listcol=<cident> )
+ | listadder="+" listcol=<cident> )?
| indexbracket="[" <term> "]" "=" <term> )
;
+<conditions> ::= <condition> ( "AND" <condition> )*
+ ;
+<condition> ::= <cident> ( "[" <term> "]" )? ( ( "=" | "<" | ">" | "<=" | ">=" | "!=" ) <term>
+ | "IN" "(" <term> ( "," <term> )* ")")
+ ;
'''
@completer_for('updateStatement', 'updateopt')
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfb652b/pylib/cqlshlib/helptopics.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfb652b/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcfb652b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------