CASSANDRA-21548: cqlsh prompt does not reset to default after dropping the current keyspace - #4994
Closed
arvindKandpal-ksolves wants to merge 2 commits into
Closed
Conversation
…g the current keyspace
driftx
reviewed
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where the
cqlshshell prompt remains stuck displaying a keyspace name even after that keyspace has been successfully dropped.Problem
When a user is currently inside a keyspace in
cqlsh(e.g.,cqlsh:test_ks>) and executesDROP KEYSPACE test_ks;, the server deletes the keyspace, but the client-sidecqlshprompt does not reset to the defaultcqlsh>prompt. Executing subsequent queries inside the dropped keyspace context throws aKeyspace does not existerror.Solution
perform_simple_statementinpylib/cqlshlib/cqlshmain.pyto check if an executed statement is aDROP KEYSPACEstatement.self.current_keyspace,self.current_keyspaceis reset toNone, which automatically updates the shell prompt back tocqlsh>..lower()normalization to handle edge cases like quoted keyspace names ("Test_KS") andIF EXISTSclauses.Testing
pylib/cqlshlib/test/test_cqlsh_output.pycovering:DROP KEYSPACE IF EXISTSsyntax.python3 -m pytest pylib/cqlshlib/test/test_cqlsh_output.py -k "test_drop_keyspace_prompt_behavior").patch by Arvind Kandpal; reviewed by TBA for CASSANDRA-21548