1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix recovery of utf-16 databases.

FossilOrigin-Name: 5b05be0861f35804270fbd184ad4b89c23e98cc2fbd56b9e4fe6197daef5fe49
This commit is contained in:
dan
2022-09-14 16:37:59 +00:00
parent 322967df59
commit b8eaf9a10d
7 changed files with 138 additions and 23 deletions

View File

@ -1548,6 +1548,47 @@ proc explain_i {sql {db db}} {
output2 "---- ------------ ------ ------ ------ ---------------- -- -"
}
proc execsql_pp {sql {db db}} {
set nCol 0
$db eval $sql A {
if {$nCol==0} {
set nCol [llength $A(*)]
foreach c $A(*) {
set aWidth($c) [string length $c]
lappend data $c
}
}
foreach c $A(*) {
set n [string length $A($c)]
if {$n > $aWidth($c)} {
set aWidth($c) $n
}
lappend data $A($c)
}
}
if {$nCol>0} {
set nTotal 0
foreach e [array names aWidth] { incr nTotal $aWidth($e) }
incr nTotal [expr ($nCol-1) * 3]
incr nTotal 4
set fmt ""
foreach c $A(*) {
lappend fmt "% -$aWidth($c)s"
}
set fmt "| [join $fmt { | }] |"
puts [string repeat - $nTotal]
for {set i 0} {$i < [llength $data]} {incr i $nCol} {
set vals [lrange $data $i [expr $i+$nCol-1]]
puts [format $fmt {*}$vals]
if {$i==0} { puts [string repeat - $nTotal] }
}
puts [string repeat - $nTotal]
}
}
# Show the VDBE program for an SQL statement but omit the Trace
# opcode at the beginning. This procedure can be used to prove
# that different SQL statements generate exactly the same VDBE code.