mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-4.0' into cassandra-4.1
This commit is contained in:
commit
b044009f0b
|
|
@ -1,5 +1,7 @@
|
|||
4.1.9
|
||||
* 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)
|
||||
|
||||
|
||||
4.1.8
|
||||
|
|
|
|||
|
|
@ -1481,9 +1481,9 @@ syntax_rules += r'''
|
|||
'''
|
||||
|
||||
syntax_rules += r'''
|
||||
<rolename> ::= <identifier>
|
||||
<rolename> ::= role=( <identifier>
|
||||
| <quotedName>
|
||||
| <unreservedKeyword>
|
||||
| <unreservedKeyword> )
|
||||
;
|
||||
|
||||
<createRoleStatement> ::= "CREATE" "ROLE" ( "IF" "NOT" "EXISTS" )? <rolename>
|
||||
|
|
@ -1584,32 +1584,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'''
|
||||
|
|
|
|||
|
|
@ -950,6 +950,10 @@ class TestCqlshCompletion(CqlshCompletionCase):
|
|||
def test_complete_in_alter_user(self):
|
||||
self.trycompletions('ALTER USER ', choices=['<identifier>', 'IF', '<pgStringLiteral>', '<quotedStringLiteral>'])
|
||||
|
||||
def test_complete_in_create_role(self):
|
||||
self.trycompletions('CREATE ROLE ', choices=['<rolename>', 'IF'])
|
||||
self.trycompletions('CREATE ROLE IF ', immediate='NOT EXISTS ')
|
||||
|
||||
def test_complete_in_alter_role(self):
|
||||
self.trycompletions('ALTER ROLE ', choices=['<identifier>', 'IF', '<quotedName>'])
|
||||
self.trycompletions('ALTER ROLE IF ', immediate='EXISTS ')
|
||||
|
|
@ -957,7 +961,3 @@ class TestCqlshCompletion(CqlshCompletionCase):
|
|||
def test_complete_in_create_user(self):
|
||||
self.trycompletions('CREATE USER ', choices=['<username>', 'IF'])
|
||||
self.trycompletions('CREATE USER IF ', immediate='NOT EXISTS ')
|
||||
|
||||
def test_complete_in_create_role(self):
|
||||
self.trycompletions('CREATE ROLE ', choices=['<identifier>', '<quotedName>', 'IF'])
|
||||
self.trycompletions('CREATE ROLE IF ', immediate='NOT EXISTS ')
|
||||
|
|
|
|||
Loading…
Reference in New Issue