mirror of https://github.com/apache/cassandra
Send correct metadata on SELECT COUNT
patch by slebresne; reviewed by iamaleksey for CASSANDRA-6080
This commit is contained in:
parent
7c6e5525ac
commit
38ae1beef6
|
|
@ -2,6 +2,7 @@
|
|||
* Improve memory usage of metadata min/max column names (CASSANDRA-6077)
|
||||
* Fix thrift validation refusing row markers on CQL3 tables (CASSANDRA-6081)
|
||||
* Fix insertion of collections with CAS (CASSANDRA-6069)
|
||||
* Correctly send metadata on SELECT COUNT (CASSANDRA-6080)
|
||||
Merged from 1.2:
|
||||
* Allow where clause conditions to be in parenthesis (CASSANDRA-6037)
|
||||
* Do not open non-ssl storage port if encryption option is all (CASSANDRA-3916)
|
||||
|
|
|
|||
|
|
@ -102,13 +102,16 @@ public class ResultSet
|
|||
return makeCountResult(ksName, cfName, count, alias);
|
||||
}
|
||||
|
||||
public static ResultSet makeCountResult(String ksName, String cfName, long count, ColumnIdentifier alias)
|
||||
public static ResultSet.Metadata makeCountMetadata(String ksName, String cfName, ColumnIdentifier alias)
|
||||
{
|
||||
ColumnSpecification spec = new ColumnSpecification(ksName, cfName, alias == null ? COUNT_COLUMN : alias, LongType.instance);
|
||||
Metadata newMetadata = new Metadata(Collections.singletonList(spec));
|
||||
List<List<ByteBuffer>> newRows = Collections.singletonList(Collections.singletonList(ByteBufferUtil.bytes(count)));
|
||||
return new Metadata(Collections.singletonList(spec));
|
||||
}
|
||||
|
||||
return new ResultSet(newMetadata, newRows);
|
||||
public static ResultSet makeCountResult(String ksName, String cfName, long count, ColumnIdentifier alias)
|
||||
{
|
||||
List<List<ByteBuffer>> newRows = Collections.singletonList(Collections.singletonList(ByteBufferUtil.bytes(count)));
|
||||
return new ResultSet(makeCountMetadata(ksName, cfName, alias), newRows);
|
||||
}
|
||||
|
||||
public CqlResult toThriftResult()
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ public class SelectStatement implements CQLStatement
|
|||
|
||||
public ResultSet.Metadata getResultMetadata()
|
||||
{
|
||||
return selection.getResultMetadata();
|
||||
return parameters.isCount
|
||||
? ResultSet.makeCountMetadata(keyspace(), columnFamily(), parameters.countAlias)
|
||||
: selection.getResultMetadata();
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
|
|
|
|||
Loading…
Reference in New Issue