This is an automated email from the ASF dual-hosted git repository.

smiklosovic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 510c20fec1 Fix cqlsh CAPTURE command to save query results without 
trace details when TRACING is ON
510c20fec1 is described below

commit 510c20fec1f294edf1024dce9b27f19a5ce04bb6
Author: Gottipati Gautam <[email protected]>
AuthorDate: Tue Jul 16 01:20:04 2024 -0500

    Fix cqlsh CAPTURE command to save query results without trace details when 
TRACING is ON
    
    This patch also opportunistically fixes CAPTURE OFF.
    
    patch by Gottipati Gautam; reviewed by Stefan Miklosovic, Brad Schoening 
for CASSANDRA-19105
---
 CHANGES.txt                     |  1 +
 pylib/cqlshlib/cqlshhandling.py |  2 +-
 pylib/cqlshlib/cqlshmain.py     |  3 ++-
 pylib/cqlshlib/tracing.py       | 12 ++++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

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'''
-<captureCommand> ::= "CAPTURE" ( fname=( <stringLiteral>) | "OFF" )?
+<captureCommand> ::= "CAPTURE" ( switch=( <stringLiteral> | "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:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to