mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-2.1' into trunk
This commit is contained in:
commit
296d11b985
|
|
@ -142,6 +142,7 @@
|
|||
* 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)
|
||||
|
|
|
|||
|
|
@ -766,7 +766,7 @@ syntax_rules += r'''
|
|||
( "AND" [updateopt]=<usingOption> )* )?
|
||||
"SET" <assignment> ( "," <assignment> )*
|
||||
"WHERE" <whereClause>
|
||||
( "IF" <conditions> )?
|
||||
( "IF" ( "EXISTS" | <conditions> ))?
|
||||
;
|
||||
<assignment> ::= updatecol=<cident>
|
||||
( "=" update_rhs=( <term> | <cident> )
|
||||
|
|
|
|||
|
|
@ -562,7 +562,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
|
||||
|
|
|
|||
|
|
@ -387,18 +387,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);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -198,14 +198,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue