Skip to content

Commit

Permalink
Merge pull request #723 from sm-shaw/720
Browse files Browse the repository at this point in the history
Fix issues with PostgreSQL inline edit
  • Loading branch information
abondvt89 authored Jul 11, 2024
2 parents 71a14ea + 5aad82a commit e89e2f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
37 changes: 22 additions & 15 deletions src/generic/gencli.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -293,44 +293,51 @@ proc .ed_mainFrame.mainwin.textFrame.left.text { args } {
}
}
fastdelete {
#Request to delete characters
#puts "Request to delete :args 0 [ lindex $args 0 ]:args 1 [ lindex $args 1 ]:args 2 [ lindex $args 2 ]"
#Request to delete characters
#puts "Request to delete :args 0 [ lindex $args 0 ]:args 1 [ lindex $args 1 ]:args 2 [ lindex $args 2 ]"
if { [ string match *\+1l [ lindex $args 2 ] ] } {
#Requested to delete multiple lines
#Requested to delete multiple lines
set start [ lindex $args 1 ]
#Remove +1l from 2nd arg
#Remove +1l from 2nd arg
set end [ string range [ lindex $args 2 ] 0 end-3 ]
#puts "delete from $start to $end this will be the string deleted \"[ string range $_ED(package) $start $end ]\""
#puts "delete from $start to $end this will be the string deleted \"[ string range $_ED(package) $start $end ]\""
set stringtofind "\n"
#find next new line"
#find next new line"
set endnnl [ string first $stringtofind $_ED(package) $end ]
#if not able to find new line set last index as end of script
#if not able to find new line set last index as end of script
if { $endnnl eq -1 } { set endnnl [ string length $_ED(package) ] }
#puts "delete from $start to $endnnl this will be the string deleted \"[ string range $_ED(package) $start $endnnl ]\""
#puts "delete from $start to $endnnl this will be the string deleted \"[ string range $_ED(package) $start $endnnl ]\""
set _ED(package) [ string replace $_ED(package) $start $endnnl ]
} elseif { [ string match "*lineend + 1 char" [ lindex $args 2 ] ] } {
#Requested to delete from an index to the end of the line including newline character
#puts "Request to delete from [ lindex $args 1 ] to [ lindex $args 1 ] lineend incl newline"
set searchtonnl [ lindex [ split [ lindex $args 1 ] ] ]
#Requested to delete from an index to the end of the line including newline character
set start [regexp -inline -- {[0-9]+} [ lindex $args 1] ]
set end [regexp -inline -- {[0-9]+} [ lindex $args 2] ]
#puts "Request to delete from $start to $end lineend incl newline"
set searchtonnl $end
#puts "search to next new line is $searchtonnl"
set stringtofind "\n"
#Searching for next newline so do not need + 1 char
set nnl [ string first $stringtofind $_ED(package) $searchtonnl ]
#puts "delete from $searchtonnl to $nnl this will be the string deleted \"[ string range $_ED(package) $searchtonnl $nnl ]\""
set _ED(package) [ string replace $_ED(package) $searchtonnl $nnl ]
#puts "delete from $start to $nnl this will be the string deleted \"[ string range $_ED(package) $start $nnl ]\""
set _ED(package) [ string replace $_ED(package) $start $nnl ]
} else {
puts "Error: failed to match arguments for text delete in script : [ lindex $args 0 ] [ lindex $args 1 ]"
return
#delete all text from start to end without finding newlines
set start [regexp -inline -- {[0-9]+} [ lindex $args 1] ]
set end [regexp -inline -- {[0-9]+} [ lindex $args 2] ]
set _ED(package) [ string replace $_ED(package) $start $end ]
}
}
search {
set srchdirection [ lindex $args 1 ]
if { $srchdirection eq "-backwards" } {
set stringtofind [lindex $args 2]
set ind [ string last $stringtofind $_ED(package) ]
if { $ind eq -1 } { puts "Warning: searched backwards for string \"$stringtofind\" and was not found" }
return $ind
} elseif { $srchdirection eq "-forwards" } {
set stringtofind [lindex $args 2]
set ind [ string first $stringtofind $_ED(package) ]
if { $ind eq -1 } { puts "Warning: searched forwards for string \"$stringtofind\" and was not found" }
return $ind
} else {
puts "Error: failed to match arguments for text search in script : [ lindex $args 0 ] [ lindex $args 1 ]"
Expand Down
10 changes: 8 additions & 2 deletions src/postgresql/pgoltp.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ proc insert_pgconnectpool_drivescript { testtype timedtype } {
set syncdrvi(1b) [.ed_mainFrame.mainwin.textFrame.left.text search -backwards "pg_disconnect \$lda" end ]
#puts "indexes are $syncdrvi(1a) and $syncdrvi(1b)"
#Delete text from start and end points
.ed_mainFrame.mainwin.textFrame.left.text fastdelete $syncdrvi(1a) $syncdrvi(1b)
.ed_mainFrame.mainwin.textFrame.left.text fastdelete $syncdrvi(1a) "$syncdrvi(1b) lineend + 1 char"
#Replace with connect pool version
.ed_mainFrame.mainwin.textFrame.left.text fastinsert $syncdrvi(1a) $syncdrvt(1)
if { $testtype eq "timed" } {
Expand Down Expand Up @@ -2447,7 +2447,13 @@ proc insert_pgconnectpool_drivescript { testtype timedtype } {
#End of run loop is previous line
set syncdrvi(3b) [ expr $syncdrvi(3b) - 1 ]
#Delete run loop
if { [ string is entier $syncdrvi(3b) ] } {
#CLI
.ed_mainFrame.mainwin.textFrame.left.text fastdelete $syncdrvi(3a) $syncdrvi(3b)
} else {
#GUI
.ed_mainFrame.mainwin.textFrame.left.text fastdelete $syncdrvi(3a) $syncdrvi(3b)+1l
}
#Replace with asynchronous connect pool version
.ed_mainFrame.mainwin.textFrame.left.text fastinsert $syncdrvi(3a) $syncdrvt(3)
#Remove extra async connection
Expand All @@ -2471,7 +2477,7 @@ proc insert_pgconnectpool_drivescript { testtype timedtype } {
.ed_mainFrame.mainwin.textFrame.left.text fastinsert $syncdrvi(4a) $syncdrvt(4)
set syncdrvi(5a) [.ed_mainFrame.mainwin.textFrame.left.text search -backwards "tsv::set application abort 1" end ]
.ed_mainFrame.mainwin.textFrame.left.text fastinsert $syncdrvi(5a)+1l $syncdrvt(5)
set syncdrvi(6a) [.ed_mainFrame.mainwin.textFrame.left.text search -backwards {foreach lda [ dict values $connlist ] { pg_disconnect $lda }} end ]
set syncdrvi(6a) [.ed_mainFrame.mainwin.textFrame.left.text search -backwards "foreach lda \[ dict values \$connlist \] { pg_disconnect \$lda }" end ]
.ed_mainFrame.mainwin.textFrame.left.text fastinsert $syncdrvi(6a) $syncdrvt(6)
} else {
#Add client side counters for timed non-async only
Expand Down

0 comments on commit e89e2f7

Please sign in to comment.