Merge branch 'cassandra-4.0' into cassandra-4.1

This commit is contained in:
Stefan Miklosovic 2022-10-03 16:26:14 +02:00
commit f0fd551c7c
3 changed files with 29 additions and 4 deletions

View File

@ -54,6 +54,7 @@ Merged from 3.11:
* Suppress CVE-2022-25857 and other snakeyaml CVEs (CASSANDRA-17907)
* Fix potential IndexOutOfBoundsException in PagingState in mixed mode clusters (CASSANDRA-17840)
Merged from 3.0:
* Fix auto-completing "WITH" when creating a materialized view (CASSANDRA-17879)
* Fix scrubber falling into infinite loop when the last partition is broken (CASSANDRA-17862)
* Fix resetting schema (CASSANDRA-17819)

View File

@ -388,6 +388,11 @@ completer_for('property', 'propeq')(prop_equals_completer)
def prop_name_completer(ctxt, cass):
if working_on_keyspace(ctxt):
return ks_prop_name_completer(ctxt, cass)
elif 'MATERIALIZED' == ctxt.get_binding('wat', '').upper():
props = cf_prop_name_completer(ctxt, cass)
props.remove('default_time_to_live')
props.remove('gc_grace_seconds')
return props
else:
return cf_prop_name_completer(ctxt, cass)
@ -697,7 +702,7 @@ def get_ut_layout(ctxt, cass):
def working_on_keyspace(ctxt):
wat = ctxt.get_binding('wat').upper()
wat = ctxt.get_binding('wat', '').upper()
if wat in ('KEYSPACE', 'SCHEMA'):
return True
return False
@ -1291,9 +1296,16 @@ syntax_rules += r'''
( "USING" <stringLiteral> ( "WITH" "OPTIONS" "=" <mapLiteral> )? )?
;
<createMaterializedViewStatement> ::= "CREATE" "MATERIALIZED" "VIEW" ("IF" "NOT" "EXISTS")? <materializedViewName>?
"AS" <selectStatement>
"PRIMARY" "KEY" <pkDef>
<colList> ::= "(" <cident> ( "," <cident> )* ")"
;
<createMaterializedViewStatement> ::= "CREATE" wat="MATERIALIZED" "VIEW" ("IF" "NOT" "EXISTS")? viewname=<materializedViewName>?
"AS" "SELECT" <selectClause>
"FROM" cf=<columnFamilyName>
"WHERE" <cident> "IS" "NOT" "NULL" ( "AND" <cident> "IS" "NOT" "NULL")*
"PRIMARY" "KEY" (<colList> | ( "(" <colList> ( "," <cident> )* ")" ))
( "WITH" <cfamProperty> ( "AND" <cfamProperty> )* )?
;
<createUserTypeStatement> ::= "CREATE" "TYPE" ( ks=<nonSystemKeyspaceName> dot="." )? typename=<cfOrKsName> "(" newcol=<cident> <storageType>
@ -1327,6 +1339,7 @@ syntax_rules += r'''
'''
explain_completion('createIndexStatement', 'indexname', '<new_index_name>')
explain_completion('createMaterializedViewStatement', 'viewname', '<new_view_name>')
explain_completion('createUserTypeStatement', 'typename', '<new_type_name>')
explain_completion('createUserTypeStatement', 'newcol', '<new_field_name>')

View File

@ -702,6 +702,17 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions('CREATE CO', immediate='LUMNFAMILY ')
self.create_columnfamily_table_template('COLUMNFAMILY')
def test_complete_in_create_materializedview(self):
self.trycompletions('CREATE MAT', immediate='ERIALIZED VIEW ')
self.trycompletions('CREATE MATERIALIZED VIEW AS ', choices=['AS', 'SELECT'])
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * ', immediate='FROM ')
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers ', immediate = 'WHERE ')
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers WHERE host_id ', immediate='IS NOT NULL ' )
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers WHERE host_id IS NOT NULL PR', immediate='IMARY KEY ( ')
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers WHERE host_id IS NOT NULL PRIMARY KEY (host_id) ', choices=[';','WITH'])
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers WHERE host_id IS NOT NULL PRIMARY KEY (a, b) ', choices=[';','WITH'])
self.trycompletions('CREATE MATERIALIZED VIEW AS SELECT * FROM system.peers WHERE host_id IS NOT NULL PRIMARY KEY ((a,b), c) ', choices=[';','WITH'])
def test_complete_in_create_table(self):
self.trycompletions('CREATE T', choices=['TRIGGER', 'TABLE', 'TYPE'])
self.trycompletions('CREATE TA', immediate='BLE ')