diff --git a/CHANGES.txt b/CHANGES.txt index 91d4861942..002e57dbc5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 5.1 + * Fix cqlsh CAPTURE command to save query results without trace details when TRACING is ON (CASSANDRA-19105) * Optionally prevent tombstone purging during repair (CASSANDRA-20071) * Add post-filtering support for the IN operator in SAI queries (CASSANDRA-20025) * Don’t finish ongoing decommission and move operations during startup (CASSANDRA-20040) diff --git a/pylib/cqlshlib/cqlshhandling.py b/pylib/cqlshlib/cqlshhandling.py index ef6ad28725..4098b54085 100644 --- a/pylib/cqlshlib/cqlshhandling.py +++ b/pylib/cqlshlib/cqlshhandling.py @@ -145,7 +145,7 @@ cqlsh_source_cmd_syntax_rules = r''' ''' cqlsh_capture_cmd_syntax_rules = r''' - ::= "CAPTURE" ( fname=( ) | "OFF" )? + ::= "CAPTURE" ( switch=( | "OFF" ) )? ; ''' diff --git a/pylib/cqlshlib/cqlshmain.py b/pylib/cqlshlib/cqlshmain.py index 2cac58ef22..a781efc7e1 100755 --- a/pylib/cqlshlib/cqlshmain.py +++ b/pylib/cqlshlib/cqlshmain.py @@ -1524,7 +1524,8 @@ class Shell(cmd.Cmd): To inspect the current capture configuration, use CAPTURE with no arguments. """ - fname = parsed.get_binding('fname') + fname = parsed.get_binding('switch') + if fname is None: if self.shunted_query_out is not None: print("Currently capturing query output to %r." % (self.query_out.name,)) diff --git a/pylib/cqlshlib/tracing.py b/pylib/cqlshlib/tracing.py index b7ee43c833..8b319906ba 100644 --- a/pylib/cqlshlib/tracing.py +++ b/pylib/cqlshlib/tracing.py @@ -38,6 +38,14 @@ def print_trace(shell, trace): """ Print an already populated cassandra.query.QueryTrace instance. """ + temp_query = None + temp_color = None + if shell.shunted_query_out is not None: + temp_query = shell.query_out + shell.query_out = shell.shunted_query_out + temp_color = shell.color + shell.color = shell.shunted_color + rows = make_trace_rows(trace) if not rows: shell.printerr("No rows for session %s found." % (trace.trace_id,)) @@ -54,6 +62,10 @@ def print_trace(shell, trace): shell.print_formatted_result(formatted_names, formatted_values, with_header=True, tty=shell.tty) shell.writeresult('') + if temp_query is not None: + shell.query_out = temp_query + shell.color = temp_color + def make_trace_rows(trace): if not trace.events: