/ Check-in [4be2b64b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use ansi escape codes to use different colored text for opcode names in the output of [explain_i]: Red for opcodes that insert or delete b-tree elements, blue for opcodes that move cursors and green for the ResultRow opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-rowid
Files: files | file ages | folders
SHA1:4be2b64b3e5237ee1fb156c06cffaf7d96f6c532
User & Date: dan 2013-11-06 14:52:40
Context
2013-11-06
16:28
Have the OP_NoConflict opcode set the VdbeCursor.seekResult variable. This speeds up subsequent OP_Insert and OP_IdxInsert opcodes. check-in: 47455500 user: dan tags: omit-rowid
14:52
Use ansi escape codes to use different colored text for opcode names in the output of [explain_i]: Red for opcodes that insert or delete b-tree elements, blue for opcodes that move cursors and green for the ResultRow opcode. check-in: 4be2b64b user: dan tags: omit-rowid
14:36
Allocate extra stack space for UnpackedRecord objects, reducing the need to malloc for them as often, and thereby get a performance improvement. check-in: a725a75f user: drh tags: omit-rowid
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/tester.tcl.

  1024   1024   }
  1025   1025   
  1026   1026   proc explain_i {sql {db db}} {
  1027   1027     puts ""
  1028   1028     puts "addr  opcode        p1      p2      p3      p4                p5  #"
  1029   1029     puts "----  ------------  ------  ------  ------  ----------------  --  -"
  1030   1030   
         1031  +
         1032  +  # Set up colors for the different opcodes. Scheme is as follows:
         1033  +  #
         1034  +  #   Red:   Opcodes that write to a b-tree.
         1035  +  #   Blue:  Opcodes that reposition or seek a cursor. 
         1036  +  #   Green: The ResultRow opcode.
         1037  +  #
         1038  +  set R "\033\[31;1m"        ;# Red fg
         1039  +  set G "\033\[32;1m"        ;# Green fg
         1040  +  set B "\033\[34;1m"        ;# Red fg
         1041  +  set D "\033\[39;0m"        ;# Default fg
         1042  +  foreach opcode {
         1043  +      Seek SeekGe SeekGt SeekLe SeekLt NotFound Last Rewind
         1044  +      NoConflict Next Prev
         1045  +  } {
         1046  +    set color($opcode) $B
         1047  +  }
         1048  +  foreach opcode {ResultRow} {
         1049  +    set color($opcode) $G
         1050  +  }
         1051  +  foreach opcode {IdxInsert Insert Delete IdxDelete} {
         1052  +    set color($opcode) $R
         1053  +  }
  1031   1054   
  1032   1055     set bSeenGoto 0
  1033   1056     $db eval "explain $sql" {} {
  1034   1057       set x($addr) 0
  1035   1058       set op($addr) $opcode
  1036   1059   
  1037   1060       if {$opcode == "Goto" && ($bSeenGoto==0 || ($p2 > $addr+10))} {
  1038   1061         set linebreak($p2) 1
  1039   1062         set bSeenGoto 1
  1040   1063       }
  1041   1064   
  1042         -    if {$opcode == "Next"} {
         1065  +    if {$opcode == "Next" || $opcode=="Prev"} {
  1043   1066         for {set i $p2} {$i<$addr} {incr i} {
  1044   1067           incr x($i) 2
  1045   1068         }
  1046   1069       }
  1047   1070   
  1048   1071       if {$opcode == "Goto" && $p2<$addr && $op($p2)=="Yield"} {
  1049   1072         for {set i [expr $p2+1]} {$i<$addr} {incr i} {
................................................................................
  1057   1080     }
  1058   1081   
  1059   1082     $db eval "explain $sql" {} {
  1060   1083       if {[info exists linebreak($addr)]} {
  1061   1084         puts ""
  1062   1085       }
  1063   1086       set I [string repeat " " $x($addr)]
  1064         -    puts [format {%-4d  %s%-12.12s  %-6d  %-6d  %-6d  % -17s %s  %s} \
  1065         -      $addr $I $opcode $p1 $p2 $p3 $p4 $p5 $comment
         1087  +
         1088  +    set col ""
         1089  +    catch { set col $color($opcode) }
         1090  +
         1091  +    puts [format {%-4d  %s%s%-12.12s%s  %-6d  %-6d  %-6d  % -17s %s  %s} \
         1092  +      $addr $I $col $opcode $D $p1 $p2 $p3 $p4 $p5 $comment
  1066   1093       ]
  1067   1094     }
  1068   1095     puts "----  ------------  ------  ------  ------  ----------------  --  -"
  1069   1096   }
  1070   1097   
  1071   1098   # Show the VDBE program for an SQL statement but omit the Trace
  1072   1099   # opcode at the beginning.  This procedure can be used to prove