Merge branch 'cassandra-4.1' into cassandra-5.0

This commit is contained in:
Stefan Miklosovic 2025-02-04 10:52:49 +01:00
commit 36e46df4b1
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
3 changed files with 9 additions and 17 deletions

View File

@ -3,6 +3,8 @@
* Correct the default behavior of compareTo() when comparing WIDE and STATIC PrimaryKeys (CASSANDRA-20238)
Merged from 4.1:
* Fix WaitQueue.Signal.awaitUninterruptibly may block forever if invoking thread is interrupted (CASSANDRA-20084)
Merged from 4.0:
* Fix autocompletion for role names/user names (CASSANDRA-20175)
5.0.3

View File

@ -1499,9 +1499,9 @@ syntax_rules += r'''
'''
syntax_rules += r'''
<rolename> ::= <identifier>
<rolename> ::= role=( <identifier>
| <quotedName>
| <unreservedKeyword>
| <unreservedKeyword> )
;
<createRoleStatement> ::= "CREATE" "ROLE" ("IF" "NOT" "EXISTS")? <rolename>
@ -1606,32 +1606,22 @@ def permission_completer(ctxt, _):
@completer_for('username', 'name')
def username_name_completer(ctxt, cass):
def maybe_quote(name):
if CqlRuleSet.is_valid_cql3_name(name):
return name
return "'%s'" % name
# disable completion for CREATE USER.
if ctxt.matched[0][1].upper() == 'CREATE':
return [Hint('<username>')]
session = cass.session
return [maybe_quote(list(row.values())[0].replace("'", "''")) for row in session.execute("LIST USERS")]
return map(maybe_escape_name, [row['name'] for row in session.execute("LIST USERS")])
@completer_for('rolename', 'role')
def rolename_completer(ctxt, cass):
def maybe_quote(name):
if CqlRuleSet.is_valid_cql3_name(name):
return name
return "'%s'" % name
# disable completion for CREATE ROLE.
if ctxt.matched[0][1].upper() == 'CREATE':
return [Hint('<rolename>')]
session = cass.session
return [maybe_quote(row[0].replace("'", "''")) for row in session.execute("LIST ROLES")]
return map(maybe_escape_name, [row['role'] for row in session.execute("LIST ROLES")])
syntax_rules += r'''

View File

@ -1031,10 +1031,10 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions('ALTER USER ', choices=['<identifier>', 'IF', '<pgStringLiteral>', '<quotedStringLiteral>'])
def test_complete_in_create_role(self):
self.trycompletions('CREATE ROLE ', choices=['<identifier>', 'IF', '<quotedName>'])
self.trycompletions('CREATE ROLE IF ', immediate='NOT EXISTS ');
self.trycompletions('CREATE ROLE ', choices=['<rolename>', 'IF'])
self.trycompletions('CREATE ROLE IF ', immediate='NOT EXISTS ')
self.trycompletions('CREATE ROLE foo WITH ', choices=['ACCESS', 'HASHED', 'LOGIN', 'OPTIONS', 'PASSWORD', 'SUPERUSER'])
self.trycompletions('CREATE ROLE foo WITH HASHED ', immediate='PASSWORD = ');
self.trycompletions('CREATE ROLE foo WITH HASHED ', immediate='PASSWORD = ')
self.trycompletions('CREATE ROLE foo WITH ACCESS TO ', choices=['ALL', 'DATACENTERS'])
self.trycompletions('CREATE ROLE foo WITH ACCESS TO ALL ', immediate='DATACENTERS ')
self.trycompletions('CREATE ROLE foo WITH ACCESS FROM ', choices=['ALL', 'CIDRS'])