summaryrefslogtreecommitdiffstats
path: root/lib/libsqlite3/tool
diff options
context:
space:
mode:
authorjturner <jturner@openbsd.org>2014-09-29 22:55:55 +0000
committerjturner <jturner@openbsd.org>2014-09-29 22:55:55 +0000
commita586bd9e68992abfe8e47f70f665db82fd484f8a (patch)
treee9468eb44816e86d3baf5af9c8b385ece347f254 /lib/libsqlite3/tool
parentlightly document mailq; ok gilles (diff)
downloadwireguard-openbsd-a586bd9e68992abfe8e47f70f665db82fd484f8a.tar.xz
wireguard-openbsd-a586bd9e68992abfe8e47f70f665db82fd484f8a.zip
Update sqlite3 to 3.8.6. A list of changes are available here:
http://sqlite.org/releaselog/3_8_6.html. Tested in a bulk and ok landry@
Diffstat (limited to 'lib/libsqlite3/tool')
-rwxr-xr-xlib/libsqlite3/tool/build-all-msvc.bat30
-rw-r--r--lib/libsqlite3/tool/logest.c69
-rw-r--r--lib/libsqlite3/tool/mkkeywordhash.c2
-rw-r--r--lib/libsqlite3/tool/mksqlite3c-noext.tcl2
-rw-r--r--lib/libsqlite3/tool/mksqlite3c.tcl6
-rw-r--r--lib/libsqlite3/tool/mksqlite3internalh.tcl2
-rw-r--r--lib/libsqlite3/tool/mkvsix.tcl248
-rw-r--r--lib/libsqlite3/tool/showdb.c268
-rw-r--r--lib/libsqlite3/tool/showjournal.c19
-rw-r--r--lib/libsqlite3/tool/showstat4.c157
-rw-r--r--lib/libsqlite3/tool/showwal.c48
-rw-r--r--lib/libsqlite3/tool/warnings.sh2
-rw-r--r--lib/libsqlite3/tool/win/sqlite.vsixbin32825 -> 32825 bytes
13 files changed, 708 insertions, 145 deletions
diff --git a/lib/libsqlite3/tool/build-all-msvc.bat b/lib/libsqlite3/tool/build-all-msvc.bat
index 6e0aeb572c0..1fb61d4df8f 100755
--- a/lib/libsqlite3/tool/build-all-msvc.bat
+++ b/lib/libsqlite3/tool/build-all-msvc.bat
@@ -147,6 +147,17 @@ IF NOT DEFINED CONFIGURATIONS (
%_VECHO% Configurations = '%CONFIGURATIONS%'
REM
+REM NOTE: If the command used to invoke NMAKE is not already set, use the
+REM default.
+REM
+IF NOT DEFINED NMAKE_CMD (
+ SET NMAKE_CMD=nmake -B -f Makefile.msc
+)
+
+%_VECHO% NmakeCmd = '%NMAKE_CMD%'
+%_VECHO% NmakeArgs = '%NMAKE_ARGS%'
+
+REM
REM NOTE: Setup environment variables to translate between the MSVC platform
REM names and the names to be used for the platform-specific binary
REM directories.
@@ -238,6 +249,7 @@ GOTO set_vcvarsall_done
:set_vcvarsall_phone
SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat
:set_vcvarsall_done
+SET VCVARSALL=%VCVARSALL:\\=\%
REM
REM NOTE: This is the outer loop. There should be exactly one iteration per
@@ -265,9 +277,11 @@ FOR %%P IN (%PLATFORMS%) DO (
REM and/or Visual Studio. This block may need to be updated in the
REM future to account for additional environment variables.
REM
+ CALL :fn_UnsetVariable CommandPromptType
CALL :fn_UnsetVariable DevEnvDir
CALL :fn_UnsetVariable ExtensionSdkDir
CALL :fn_UnsetVariable Framework35Version
+ CALL :fn_UnsetVariable Framework40Version
CALL :fn_UnsetVariable FrameworkDir
CALL :fn_UnsetVariable FrameworkDir32
CALL :fn_UnsetVariable FrameworkVersion
@@ -283,6 +297,8 @@ FOR %%P IN (%PLATFORMS%) DO (
CALL :fn_UnsetVariable WindowsSdkDir
CALL :fn_UnsetVariable WindowsSdkDir_35
CALL :fn_UnsetVariable WindowsSdkDir_old
+ CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x86
+ CALL :fn_UnsetVariable WindowsSDK_ExecutablePath_x64
REM
REM NOTE: Reset the PATH here to the absolute bare minimum required.
@@ -299,6 +315,8 @@ FOR %%P IN (%PLATFORMS%) DO (
REM environment variables to be picked up by the MSVC makefile
REM itself.
REM
+ %_AECHO% Building the %%B configuration for platform %%P with name %%D...
+
IF /I "%%B" == "Debug" (
SET DEBUG=2
SET MEMDEBUG=1
@@ -374,11 +392,12 @@ FOR %%P IN (%PLATFORMS%) DO (
REM
REM NOTE: The Windows 8.1 SDK has a slightly different directory
- REM naming convention. Currently, this tool assumes that
- REM the Windows 8.1 SDK should only be used with MSVC 2013.
+ REM naming convention.
REM
- IF "%VisualStudioVersion%" == "12.0" (
+ IF DEFINED USE_WINV63_NSDKLIBPATH (
CALL :fn_AppendVariable NSDKLIBPATH \lib\winv6.3\um\x86
+ ) ELSE IF "%VisualStudioVersion%" == "12.0" (
+ CALL :fn_AppendVariable NSDKLIBPATH \..\8.0\lib\win8\um\x86
) ELSE (
CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86
)
@@ -392,7 +411,7 @@ FOR %%P IN (%PLATFORMS%) DO (
REM file, etc.
REM
IF NOT DEFINED NOCLEAN (
- %__ECHO% nmake -f Makefile.msc clean
+ %__ECHO% %NMAKE_CMD% clean
IF ERRORLEVEL 1 (
ECHO Failed to clean for platform %%P.
@@ -404,6 +423,7 @@ FOR %%P IN (%PLATFORMS%) DO (
REM need to remove the build output for the files we are
REM specifically wanting to build for each platform.
REM
+ %_AECHO% Cleaning final output files only...
%__ECHO% DEL /Q *.lo sqlite3.dll sqlite3.lib sqlite3.pdb
)
@@ -414,7 +434,7 @@ FOR %%P IN (%PLATFORMS%) DO (
REM Also, disable looking for and/or linking to the native Tcl
REM runtime library.
REM
- %__ECHO% nmake -f Makefile.msc sqlite3.dll XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
+ %__ECHO% %NMAKE_CMD% sqlite3.dll XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS%
IF ERRORLEVEL 1 (
ECHO Failed to build %%B "sqlite3.dll" for platform %%P.
diff --git a/lib/libsqlite3/tool/logest.c b/lib/libsqlite3/tool/logest.c
index 8dad6cc9b6e..347fa68a4f4 100644
--- a/lib/libsqlite3/tool/logest.c
+++ b/lib/libsqlite3/tool/logest.c
@@ -17,13 +17,7 @@
**
** ./LogEst ARGS
**
-** Arguments:
-**
-** 'x' Multiple the top two elements of the stack
-** '+' Add the top two elements of the stack
-** NUM Convert NUM from integer to LogEst and push onto the stack
-** ^NUM Interpret NUM as a LogEst and push onto stack.
-**
+** See the showHelp() routine for a description of valid arguments.
** Examples:
**
** To convert 123 from LogEst to integer:
@@ -89,7 +83,8 @@ static LogEst logEstFromDouble(double x){
LogEst e;
assert( sizeof(x)==8 && sizeof(a)==8 );
if( x<=0.0 ) return -32768;
- if( x<1.0 ) return -logEstFromDouble(1/x);
+ if( x<0.01 ) return -logEstFromDouble(1.0/x);
+ if( x<1.0 ) return logEstFromDouble(100.0*x) - 66;
if( x<1024.0 ) return logEstFromInteger((sqlite3_uint64)(1024.0*x)) - 100;
if( x<=2000000000.0 ) return logEstFromInteger((sqlite3_uint64)x);
memcpy(&a, &x, 8);
@@ -97,12 +92,31 @@ static LogEst logEstFromDouble(double x){
return e*10;
}
+int isInteger(const char *z){
+ while( z[0]>='0' && z[0]<='9' ) z++;
+ return z[0]==0;
+}
+
int isFloat(const char *z){
- while( z[0] ){
- if( z[0]=='.' || z[0]=='E' || z[0]=='e' ) return 1;
- z++;
- }
- return 0;
+ char c;
+ while( ((c=z[0])>='0' && c<='9') || c=='.' || c=='E' || c=='e'
+ || c=='+' || c=='-' ) z++;
+ return z[0]==0;
+}
+
+static void showHelp(const char *zArgv0){
+ printf("Usage: %s ARGS...\n", zArgv0);
+ printf("Arguments:\n"
+ " NUM Convert NUM from integer to LogEst and push onto the stack\n"
+ " ^NUM Interpret NUM as a LogEst and push onto stack\n"
+ " x Multiple the top two elements of the stack\n"
+ " + Add the top two elements of the stack\n"
+ " dup Dupliate the top element on the stack\n"
+ " inv Take the reciprocal of the top of stack. N = 1/N.\n"
+ " log Find the LogEst of the number on top of stack\n"
+ " nlogn Compute NlogN where N is the top of stack\n"
+ );
+ exit(1);
}
int main(int argc, char **argv){
@@ -111,30 +125,45 @@ int main(int argc, char **argv){
LogEst a[100];
for(i=1; i<argc; i++){
const char *z = argv[i];
- if( z[0]=='+' ){
+ if( strcmp(z,"+")==0 ){
if( n>=2 ){
a[n-2] = logEstAdd(a[n-2],a[n-1]);
n--;
}
- }else if( z[0]=='x' ){
+ }else if( strcmp(z,"x")==0 ){
if( n>=2 ){
a[n-2] = logEstMultiply(a[n-2],a[n-1]);
n--;
}
+ }else if( strcmp(z,"dup")==0 ){
+ if( n>0 ){
+ a[n] = a[n-1];
+ n++;
+ }
+ }else if( strcmp(z,"log")==0 ){
+ if( n>0 ) a[n-1] = logEstFromInteger(a[n-1]) - 33;
+ }else if( strcmp(z,"nlogn")==0 ){
+ if( n>0 ) a[n-1] += logEstFromInteger(a[n-1]) - 33;
+ }else if( strcmp(z,"inv")==0 ){
+ if( n>0 ) a[n-1] = -a[n-1];
}else if( z[0]=='^' ){
a[n++] = atoi(z+1);
- }else if( isFloat(z) ){
+ }else if( isInteger(z) ){
+ a[n++] = logEstFromInteger(atoi(z));
+ }else if( isFloat(z) && z[0]!='-' ){
a[n++] = logEstFromDouble(atof(z));
}else{
- a[n++] = logEstFromInteger(atoi(z));
+ showHelp(argv[0]);
}
}
for(i=n-1; i>=0; i--){
- if( a[i]<0 ){
- printf("%d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i]));
+ if( a[i]<-40 ){
+ printf("%5d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i]));
+ }else if( a[i]<10 ){
+ printf("%5d (%f)\n", a[i], logEstToInt(a[i]+100)/1024.0);
}else{
sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024;
- printf("%d (%lld.%02lld)\n", a[i], x/100, x%100);
+ printf("%5d (%lld.%02lld)\n", a[i], x/100, x%100);
}
}
return 0;
diff --git a/lib/libsqlite3/tool/mkkeywordhash.c b/lib/libsqlite3/tool/mkkeywordhash.c
index a467931c307..721611f5a36 100644
--- a/lib/libsqlite3/tool/mkkeywordhash.c
+++ b/lib/libsqlite3/tool/mkkeywordhash.c
@@ -370,7 +370,7 @@ int main(int argc, char **argv){
Keyword *p = &aKeywordTable[i];
p->len = (int)strlen(p->zName);
assert( p->len<sizeof(p->zOrigName) );
- strcpy(p->zOrigName, p->zName);
+ memcpy(p->zOrigName, p->zName, p->len+1);
totalLen += p->len;
p->hash = (UpperToLower[(int)p->zName[0]]*4) ^
(UpperToLower[(int)p->zName[p->len-1]]*3) ^ p->len;
diff --git a/lib/libsqlite3/tool/mksqlite3c-noext.tcl b/lib/libsqlite3/tool/mksqlite3c-noext.tcl
index 017ad6292fc..ecb9cb0439c 100644
--- a/lib/libsqlite3/tool/mksqlite3c-noext.tcl
+++ b/lib/libsqlite3/tool/mksqlite3c-noext.tcl
@@ -99,6 +99,8 @@ foreach hdr {
mutex.h
opcodes.h
os_common.h
+ os_setup.h
+ os_win.h
os.h
pager.h
parse.h
diff --git a/lib/libsqlite3/tool/mksqlite3c.tcl b/lib/libsqlite3/tool/mksqlite3c.tcl
index 7a4fe1b389f..64207727be2 100644
--- a/lib/libsqlite3/tool/mksqlite3c.tcl
+++ b/lib/libsqlite3/tool/mksqlite3c.tcl
@@ -103,6 +103,8 @@ foreach hdr {
mutex.h
opcodes.h
os_common.h
+ os_setup.h
+ os_win.h
os.h
pager.h
parse.h
@@ -168,7 +170,9 @@ proc copy_file {filename} {
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
}
} elseif {![info exists seen_hdr($hdr)]} {
- set seen_hdr($hdr) 1
+ if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {
+ set seen_hdr($hdr) 1
+ }
puts $out $line
} elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} {
# This include file must be kept because there was a "keep"
diff --git a/lib/libsqlite3/tool/mksqlite3internalh.tcl b/lib/libsqlite3/tool/mksqlite3internalh.tcl
index 406ef5c4575..7e92b3ad7dd 100644
--- a/lib/libsqlite3/tool/mksqlite3internalh.tcl
+++ b/lib/libsqlite3/tool/mksqlite3internalh.tcl
@@ -60,6 +60,8 @@ foreach hdr {
keywordhash.h
opcodes.h
os_common.h
+ os_setup.h
+ os_win.h
os.h
pager.h
parse.h
diff --git a/lib/libsqlite3/tool/mkvsix.tcl b/lib/libsqlite3/tool/mkvsix.tcl
index 65fa7312450..208ce2b1421 100644
--- a/lib/libsqlite3/tool/mkvsix.tcl
+++ b/lib/libsqlite3/tool/mkvsix.tcl
@@ -65,12 +65,16 @@
# argument is optional and if present must contain the name of the directory
# containing the root of the source tree for SQLite. The third argument is
# optional and if present must contain the flavor the VSIX package to build.
-# Currently, the only supported package flavors are "WinRT", "WinRT81", and
-# "WP80". The fourth argument is optional and if present must be a string
-# containing a list of platforms to include in the VSIX package. The format
-# of the platform list string is "platform1,platform2,platform3". Typically,
-# when on Windows, this script is executed using commands similar to the
-# following from a normal Windows command prompt:
+# Currently, the only supported package flavors are "WinRT", "WinRT81", "WP80",
+# "WP81", and "Win32". The fourth argument is optional and if present must be
+# a string containing a list of platforms to include in the VSIX package. The
+# platform list is "platform1,platform2,platform3". The fifth argument is
+# optional and if present must contain the version of Visual Studio required by
+# the package. Currently, the only supported versions are "2012" and "2013".
+# The package flavors "WinRT81" and "WP81" are only supported when the Visual
+# Studio version is "2013". Typically, when on Windows, this script is
+# executed using commands similar to the following from a normal Windows
+# command prompt:
#
# CD /D C:\dev\sqlite\core
# tclsh85 tool\mkvsix.tcl C:\Temp
@@ -100,7 +104,7 @@ proc fail { {error ""} {usage false} } {
puts stdout "usage:\
[file tail [info nameofexecutable]]\
[file tail [info script]] <binaryDirectory> \[sourceDirectory\]\
-\[packageFlavor\] \[platformNames\]"
+\[packageFlavor\] \[platformNames\] \[vsVersion\]"
exit 1
}
@@ -170,13 +174,81 @@ proc writeFile { fileName data } {
return ""
}
-proc substFile { fileName } {
+proc getMinVsVersionXmlChunk { vsVersion } {
+ switch -exact $vsVersion {
+ 2012 {
+ return [appendArgs \
+ "\r\n " {MinVSVersion="11.0"}]
+ }
+ 2013 {
+ return [appendArgs \
+ "\r\n " {MinVSVersion="12.0"}]
+ }
+ default {
+ return ""
+ }
+ }
+}
+
+proc getMaxPlatformVersionXmlChunk { packageFlavor vsVersion } {
#
- # NOTE: Performs all Tcl command, variable, and backslash substitutions in
- # the specified file and then rewrites the contents of that same file
- # with the substituted data.
+ # NOTE: Only Visual Studio 2013 supports this SDK manifest attribute.
#
- return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]]
+ if {![string equal $vsVersion 2013]} then {
+ return ""
+ }
+
+ switch -exact $packageFlavor {
+ WinRT {
+ return [appendArgs \
+ "\r\n " {MaxPlatformVersion="8.0"}]
+ }
+ WinRT81 {
+ return [appendArgs \
+ "\r\n " {MaxPlatformVersion="8.1"}]
+ }
+ WP80 {
+ return [appendArgs \
+ "\r\n " {MaxPlatformVersion="8.0"}]
+ }
+ WP81 {
+ return [appendArgs \
+ "\r\n " {MaxPlatformVersion="8.1"}]
+ }
+ default {
+ return ""
+ }
+ }
+}
+
+proc getExtraFileListXmlChunk { packageFlavor vsVersion } {
+ #
+ # NOTE: Windows Phone 8.0 does not require any extra attributes in its VSIX
+ # package SDK manifests; however, it appears that Windows Phone 8.1
+ # does.
+ #
+ if {[string equal $packageFlavor WP80]} then {
+ return ""
+ }
+
+ set appliesTo [expr {[string equal $packageFlavor Win32] ? \
+ "VisualC" : "WindowsAppContainer"}]
+
+ switch -exact $vsVersion {
+ 2012 {
+ return [appendArgs \
+ "\r\n " AppliesTo=\" $appliesTo \" \
+ "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}]
+ }
+ 2013 {
+ return [appendArgs \
+ "\r\n " AppliesTo=\" $appliesTo \" \
+ "\r\n " {DependsOn="Microsoft.VCLibs, version=12.0"}]
+ }
+ default {
+ return ""
+ }
+ }
}
proc replaceFileNameTokens { fileName name buildName platformName } {
@@ -188,6 +260,15 @@ proc replaceFileNameTokens { fileName name buildName platformName } {
<name> $name] $fileName]
}
+proc substFile { fileName } {
+ #
+ # NOTE: Performs all Tcl command, variable, and backslash substitutions in
+ # the specified file and then rewrites the contents of that same file
+ # with the substituted data.
+ #
+ return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]]
+}
+
#
# NOTE: This is the entry point for this script.
#
@@ -206,7 +287,7 @@ set rootName [file rootname [file tail $script]]
# NOTE: Process and verify all the command line arguments.
#
set argc [llength $argv]
-if {$argc < 1 || $argc > 4} then {fail}
+if {$argc < 1 || $argc > 5} then {fail}
set binaryDirectory [lindex $argv 0]
@@ -251,56 +332,121 @@ if {[string length $packageFlavor] == 0} then {
fail "invalid package flavor"
}
-if {[string equal -nocase $packageFlavor WinRT]} then {
- set shortName SQLite.WinRT
- set displayName "SQLite for Windows Runtime"
+if {$argc >= 4} then {
+ set platformNames [list]
+
+ foreach platformName [split [lindex $argv 3] ", "] {
+ set platformName [string trim $platformName]
+
+ if {[string length $platformName] > 0} then {
+ lappend platformNames $platformName
+ }
+ }
+}
+
+if {$argc >= 5} then {
+ set vsVersion [lindex $argv 4]
+} else {
+ set vsVersion 2012
+}
+
+if {[string length $vsVersion] == 0} then {
+ fail "invalid Visual Studio version"
+}
+
+if {![string equal $vsVersion 2012] && ![string equal $vsVersion 2013]} then {
+ fail [appendArgs \
+ "unsupported Visual Studio version, must be one of: " \
+ [list 2012 2013]]
+}
+
+set shortNames(WinRT,2012) SQLite.WinRT
+set shortNames(WinRT,2013) SQLite.WinRT.2013
+set shortNames(WinRT81,2013) SQLite.WinRT81
+set shortNames(WP80,2012) SQLite.WP80
+set shortNames(WP80,2013) SQLite.WP80.2013
+set shortNames(WP81,2013) SQLite.WP81
+set shortNames(Win32,2012) SQLite.Win32
+set shortNames(Win32,2013) SQLite.Win32.2013
+
+set displayNames(WinRT,2012) "SQLite for Windows Runtime"
+set displayNames(WinRT,2013) "SQLite for Windows Runtime"
+set displayNames(WinRT81,2013) "SQLite for Windows Runtime (Windows 8.1)"
+set displayNames(WP80,2012) "SQLite for Windows Phone"
+set displayNames(WP80,2013) "SQLite for Windows Phone"
+set displayNames(WP81,2013) "SQLite for Windows Phone 8.1"
+set displayNames(Win32,2012) "SQLite for Windows"
+set displayNames(Win32,2013) "SQLite for Windows"
+
+if {[string equal $packageFlavor WinRT]} then {
+ set shortName $shortNames($packageFlavor,$vsVersion)
+ set displayName $displayNames($packageFlavor,$vsVersion)
set targetPlatformIdentifier Windows
set targetPlatformVersion v8.0
- set minVsVersion 11.0
+ set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+ set maxPlatformVersion \
+ [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
set extraSdkPath ""
- set extraFileListAttributes [appendArgs \
- "\r\n " {AppliesTo="WindowsAppContainer"} \
- "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}]
-} elseif {[string equal -nocase $packageFlavor WinRT81]} then {
- set shortName SQLite.WinRT81
- set displayName "SQLite for Windows Runtime (Windows 8.1)"
+ set extraFileListAttributes \
+ [getExtraFileListXmlChunk $packageFlavor $vsVersion]
+} elseif {[string equal $packageFlavor WinRT81]} then {
+ if {$vsVersion ne "2013"} then {
+ fail [appendArgs \
+ "unsupported combination, package flavor " $packageFlavor \
+ " is only supported with Visual Studio 2013"]
+ }
+ set shortName $shortNames($packageFlavor,$vsVersion)
+ set displayName $displayNames($packageFlavor,$vsVersion)
set targetPlatformIdentifier Windows
set targetPlatformVersion v8.1
- set minVsVersion 12.0
+ set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+ set maxPlatformVersion \
+ [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
set extraSdkPath ""
- set extraFileListAttributes [appendArgs \
- "\r\n " {AppliesTo="WindowsAppContainer"} \
- "\r\n " {DependsOn="Microsoft.VCLibs, version=12.0"}]
-} elseif {[string equal -nocase $packageFlavor WP80]} then {
- set shortName SQLite.WP80
- set displayName "SQLite for Windows Phone"
+ set extraFileListAttributes \
+ [getExtraFileListXmlChunk $packageFlavor $vsVersion]
+} elseif {[string equal $packageFlavor WP80]} then {
+ set shortName $shortNames($packageFlavor,$vsVersion)
+ set displayName $displayNames($packageFlavor,$vsVersion)
set targetPlatformIdentifier "Windows Phone"
set targetPlatformVersion v8.0
- set minVsVersion 11.0
+ set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+ set maxPlatformVersion \
+ [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
set extraSdkPath "\\..\\$targetPlatformIdentifier"
- set extraFileListAttributes ""
-} elseif {[string equal -nocase $packageFlavor Win32]} then {
- set shortName SQLite.Win32
- set displayName "SQLite for Windows"
+ set extraFileListAttributes \
+ [getExtraFileListXmlChunk $packageFlavor $vsVersion]
+} elseif {[string equal $packageFlavor WP81]} then {
+ if {$vsVersion ne "2013"} then {
+ fail [appendArgs \
+ "unsupported combination, package flavor " $packageFlavor \
+ " is only supported with Visual Studio 2013"]
+ }
+ set shortName $shortNames($packageFlavor,$vsVersion)
+ set displayName $displayNames($packageFlavor,$vsVersion)
+ set targetPlatformIdentifier WindowsPhoneApp
+ set targetPlatformVersion v8.1
+ set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+ set maxPlatformVersion \
+ [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
+ set extraSdkPath "\\..\\$targetPlatformIdentifier"
+ set extraFileListAttributes \
+ [getExtraFileListXmlChunk $packageFlavor $vsVersion]
+} elseif {[string equal $packageFlavor Win32]} then {
+ set shortName $shortNames($packageFlavor,$vsVersion)
+ set displayName $displayNames($packageFlavor,$vsVersion)
set targetPlatformIdentifier Windows
set targetPlatformVersion v8.0
- set minVsVersion 11.0
+ set minVsVersion [getMinVsVersionXmlChunk $vsVersion]
+ set maxPlatformVersion \
+ [getMaxPlatformVersionXmlChunk $packageFlavor $vsVersion]
set extraSdkPath ""
- set extraFileListAttributes [appendArgs \
- "\r\n " {AppliesTo="VisualC"} \
- "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}]
+ set extraFileListAttributes \
+ [getExtraFileListXmlChunk $packageFlavor $vsVersion]
} else {
- fail "unsupported package flavor, must be one of: WinRT WinRT81 WP80 Win32"
-}
-
-if {$argc >= 4} then {
- set platformNames [list]
-
- foreach platformName [split [lindex $argv 3] ", "] {
- if {[string length $platformName] > 0} then {
- lappend platformNames $platformName
- }
- }
+ fail [appendArgs \
+ "unsupported package flavor, must be one of: " \
+ [list WinRT WinRT81 WP80 WP81 Win32]]
}
###############################################################################
@@ -490,7 +636,7 @@ if {![info exists buildNames]} then {
# overridden via the command line or the user-specific customizations
# file.
#
-if {![info exists platformNames]} then {
+if {![info exists platformNames] || [llength $platformNames] == 0} then {
set platformNames [list x86 x64 ARM]
}
diff --git a/lib/libsqlite3/tool/showdb.c b/lib/libsqlite3/tool/showdb.c
index 4d274a7aacb..1a51e9d1a2a 100644
--- a/lib/libsqlite3/tool/showdb.c
+++ b/lib/libsqlite3/tool/showdb.c
@@ -9,6 +9,8 @@
#if !defined(_MSC_VER)
#include <unistd.h>
+#else
+#include <io.h>
#endif
#include <stdlib.h>
@@ -66,7 +68,7 @@ static unsigned char *getContent(int ofst, int nByte){
if( aData==0 ) out_of_memory();
memset(aData, 0, nByte+32);
lseek(db, ofst, SEEK_SET);
- read(db, aData, nByte);
+ if( read(db, aData, nByte)<nByte ) memset(aData, 0, nByte);
return aData;
}
@@ -129,6 +131,7 @@ static void print_page(int iPg){
free(aData);
}
+
/* Print a line of decode output showing a 4-byte integer.
*/
static void print_decode_line(
@@ -140,7 +143,7 @@ static void print_decode_line(
int val = aData[ofst];
char zBuf[100];
sprintf(zBuf, " %03x: %02x", ofst, aData[ofst]);
- i = strlen(zBuf);
+ i = (int)strlen(zBuf);
for(j=1; j<4; j++){
if( j>=nByte ){
sprintf(&zBuf[i], " ");
@@ -148,7 +151,7 @@ static void print_decode_line(
sprintf(&zBuf[i], " %02x", aData[ofst+j]);
val = val*256 + aData[ofst+j];
}
- i += strlen(&zBuf[i]);
+ i += (int)strlen(&zBuf[i]);
}
sprintf(&zBuf[i], " %9d", val);
printf("%s %s\n", zBuf, zMsg);
@@ -189,14 +192,14 @@ static void print_db_header(void){
/*
** Describe cell content.
*/
-static int describeContent(
+static i64 describeContent(
unsigned char *a, /* Cell content */
- int nLocal, /* Bytes in a[] */
+ i64 nLocal, /* Bytes in a[] */
char *zDesc /* Write description here */
){
- int nDesc = 0;
- int n, i, j;
- i64 x, v;
+ i64 nDesc = 0;
+ int n, j;
+ i64 i, x, v;
const unsigned char *pData;
const unsigned char *pLimit;
char sep = ' ';
@@ -236,15 +239,15 @@ static int describeContent(
}else if( x==9 ){
sprintf(zDesc, "1");
}else if( x>=12 ){
- int size = (x-12)/2;
+ i64 size = (x-12)/2;
if( (x&1)==0 ){
- sprintf(zDesc, "blob(%d)", size);
+ sprintf(zDesc, "blob(%lld)", size);
}else{
- sprintf(zDesc, "txt(%d)", size);
+ sprintf(zDesc, "txt(%lld)", size);
}
pData += size;
}
- j = strlen(zDesc);
+ j = (int)strlen(zDesc);
zDesc += j;
nDesc += j;
}
@@ -255,11 +258,11 @@ static int describeContent(
** Compute the local payload size given the total payload size and
** the page size.
*/
-static int localPayload(i64 nPayload, char cType){
- int maxLocal;
- int minLocal;
- int surplus;
- int nLocal;
+static i64 localPayload(i64 nPayload, char cType){
+ i64 maxLocal;
+ i64 minLocal;
+ i64 surplus;
+ i64 nLocal;
if( cType==13 ){
/* Table leaf */
maxLocal = pagesize-35;
@@ -287,19 +290,19 @@ static int localPayload(i64 nPayload, char cType){
**
** The return value is the local cell size.
*/
-static int describeCell(
+static i64 describeCell(
unsigned char cType, /* Page type */
unsigned char *a, /* Cell content */
int showCellContent, /* Show cell content if true */
char **pzDesc /* Store description here */
){
int i;
- int nDesc = 0;
+ i64 nDesc = 0;
int n = 0;
int leftChild;
i64 nPayload;
i64 rowid;
- int nLocal;
+ i64 nLocal;
static char zDesc[1000];
i = 0;
if( cType<=5 ){
@@ -341,6 +344,180 @@ static int describeCell(
return nLocal+n;
}
+/* Print an offset followed by nByte bytes. Add extra white-space
+** at the end so that subsequent text is aligned.
+*/
+static void printBytes(
+ unsigned char *aData, /* Content being decoded */
+ unsigned char *aStart, /* Start of content to be printed */
+ int nByte /* Number of bytes to print */
+){
+ int j;
+ printf(" %03x: ", (int)(aStart-aData));
+ for(j=0; j<9; j++){
+ if( j>=nByte ){
+ printf(" ");
+ }else{
+ printf("%02x ", aStart[j]);
+ }
+ }
+}
+
+
+/*
+** Write a full decode on stdout for the cell at a[ofst].
+** Assume the page contains a header of size szPgHdr bytes.
+*/
+static void decodeCell(
+ unsigned char *a, /* Page content (without the page-1 header) */
+ unsigned pgno, /* Page number */
+ int iCell, /* Cell index */
+ int szPgHdr, /* Size of the page header. 0 or 100 */
+ int ofst /* Cell begins at a[ofst] */
+){
+ int i, j;
+ int leftChild;
+ i64 k;
+ i64 nPayload;
+ i64 rowid;
+ i64 nHdr;
+ i64 iType;
+ i64 nLocal;
+ unsigned char *x = a + ofst;
+ unsigned char *end;
+ unsigned char cType = a[0];
+ int nCol = 0;
+ int szCol[2000];
+ int ofstCol[2000];
+ int typeCol[2000];
+
+ printf("Cell[%d]:\n", iCell);
+ if( cType<=5 ){
+ leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3];
+ printBytes(a, x, 4);
+ printf("left child page:: %d\n", leftChild);
+ x += 4;
+ }
+ if( cType!=5 ){
+ i = decodeVarint(x, &nPayload);
+ printBytes(a, x, i);
+ nLocal = localPayload(nPayload, cType);
+ if( nLocal==nPayload ){
+ printf("payload-size: %lld\n", nPayload);
+ }else{
+ printf("payload-size: %lld (%lld local, %lld overflow)\n",
+ nPayload, nLocal, nPayload-nLocal);
+ }
+ x += i;
+ }else{
+ nPayload = nLocal = 0;
+ }
+ end = x + nLocal;
+ if( cType==5 || cType==13 ){
+ i = decodeVarint(x, &rowid);
+ printBytes(a, x, i);
+ printf("rowid: %lld\n", rowid);
+ x += i;
+ }
+ if( nLocal>0 ){
+ i = decodeVarint(x, &nHdr);
+ printBytes(a, x, i);
+ printf("record-header-size: %d\n", (int)nHdr);
+ j = i;
+ nCol = 0;
+ k = nHdr;
+ while( x+j<end && j<nHdr ){
+ const char *zTypeName;
+ int sz = 0;
+ char zNm[30];
+ i = decodeVarint(x+j, &iType);
+ printBytes(a, x+j, i);
+ printf("typecode[%d]: %d - ", nCol, (int)iType);
+ switch( iType ){
+ case 0: zTypeName = "NULL"; sz = 0; break;
+ case 1: zTypeName = "int8"; sz = 1; break;
+ case 2: zTypeName = "int16"; sz = 2; break;
+ case 3: zTypeName = "int24"; sz = 3; break;
+ case 4: zTypeName = "int32"; sz = 4; break;
+ case 5: zTypeName = "int48"; sz = 6; break;
+ case 6: zTypeName = "int64"; sz = 8; break;
+ case 7: zTypeName = "double"; sz = 8; break;
+ case 8: zTypeName = "zero"; sz = 0; break;
+ case 9: zTypeName = "one"; sz = 0; break;
+ case 10:
+ case 11: zTypeName = "error"; sz = 0; break;
+ default: {
+ sz = (int)(iType-12)/2;
+ sprintf(zNm, (iType&1)==0 ? "blob(%d)" : "text(%d)", sz);
+ zTypeName = zNm;
+ break;
+ }
+ }
+ printf("%s\n", zTypeName);
+ szCol[nCol] = sz;
+ ofstCol[nCol] = (int)k;
+ typeCol[nCol] = (int)iType;
+ k += sz;
+ nCol++;
+ j += i;
+ }
+ for(i=0; i<nCol && ofstCol[i]+szCol[i]<=nLocal; i++){
+ int s = ofstCol[i];
+ i64 v;
+ const unsigned char *pData;
+ if( szCol[i]==0 ) continue;
+ printBytes(a, x+s, szCol[i]);
+ printf("data[%d]: ", i);
+ pData = x+s;
+ if( typeCol[i]<=7 ){
+ v = (signed char)pData[0];
+ for(k=1; k<szCol[i]; k++){
+ v = (v<<8) + pData[k];
+ }
+ if( typeCol[i]==7 ){
+ double r;
+ memcpy(&r, &v, sizeof(r));
+ printf("%#g\n", r);
+ }else{
+ printf("%lld\n", v);
+ }
+ }else{
+ int ii, jj;
+ char zConst[32];
+ if( (typeCol[i]&1)==0 ){
+ zConst[0] = 'x';
+ zConst[1] = '\'';
+ for(ii=2, jj=0; jj<szCol[i] && ii<24; jj++, ii+=2){
+ sprintf(zConst+ii, "%02x", pData[jj]);
+ }
+ }else{
+ zConst[0] = '\'';
+ for(ii=1, jj=0; jj<szCol[i] && ii<24; jj++, ii++){
+ zConst[ii] = isprint(pData[jj]) ? pData[jj] : '.';
+ }
+ zConst[ii] = 0;
+ }
+ if( jj<szCol[i] ){
+ memcpy(zConst+ii, "...'", 5);
+ }else{
+ memcpy(zConst+ii, "'", 2);
+ }
+ printf("%s\n", zConst);
+ }
+ j = ofstCol[i] + szCol[i];
+ }
+ }
+ if( j<nLocal ){
+ printBytes(a, x+j, 0);
+ printf("... %lld bytes of content ...\n", nLocal-j);
+ }
+ if( nLocal<nPayload ){
+ printBytes(a, x+nLocal, 4);
+ printf("overflow-page: %d\n", decodeInt32(x+nLocal));
+ }
+}
+
+
/*
** Decode a btree page
*/
@@ -356,6 +533,7 @@ static void decode_btree_page(
int iCellPtr;
int showCellContent = 0;
int showMap = 0;
+ int cellToDecode = -2;
char *zMap = 0;
switch( a[0] ){
case 2: zType = "index interior node"; break;
@@ -367,23 +545,37 @@ static void decode_btree_page(
switch( zArgs[0] ){
case 'c': showCellContent = 1; break;
case 'm': showMap = 1; break;
+ case 'd': {
+ if( !isdigit(zArgs[1]) ){
+ cellToDecode = -1;
+ }else{
+ cellToDecode = 0;
+ while( isdigit(zArgs[1]) ){
+ zArgs++;
+ cellToDecode = cellToDecode*10 + zArgs[0] - '0';
+ }
+ }
+ break;
+ }
}
zArgs++;
}
- printf("Decode of btree page %d:\n", pgno);
+ nCell = a[3]*256 + a[4];
+ iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8;
+ if( cellToDecode>=nCell ){
+ printf("Page %d has only %d cells\n", pgno, nCell);
+ return;
+ }
+ printf("Header on btree page %d:\n", pgno);
print_decode_line(a, 0, 1, zType);
print_decode_line(a, 1, 2, "Offset to first freeblock");
print_decode_line(a, 3, 2, "Number of cells on this page");
- nCell = a[3]*256 + a[4];
print_decode_line(a, 5, 2, "Offset to cell content area");
print_decode_line(a, 7, 1, "Fragmented byte count");
if( a[0]==2 || a[0]==5 ){
print_decode_line(a, 8, 4, "Right child");
- iCellPtr = 12;
- }else{
- iCellPtr = 8;
}
- if( nCell>0 ){
+ if( cellToDecode==(-2) && nCell>0 ){
printf(" key: lx=left-child n=payload-size r=rowid\n");
}
if( showMap ){
@@ -396,27 +588,32 @@ static void decode_btree_page(
for(i=0; i<nCell; i++){
int cofst = iCellPtr + i*2;
char *zDesc;
- int n;
+ i64 n;
cofst = a[cofst]*256 + a[cofst+1];
n = describeCell(a[0], &a[cofst-hdrSize], showCellContent, &zDesc);
if( showMap ){
char zBuf[30];
- memset(&zMap[cofst], '*', n);
+ memset(&zMap[cofst], '*', (size_t)n);
zMap[cofst] = '[';
zMap[cofst+n-1] = ']';
sprintf(zBuf, "%d", i);
- j = strlen(zBuf);
+ j = (int)strlen(zBuf);
if( j<=n-2 ) memcpy(&zMap[cofst+1], zBuf, j);
}
- printf(" %03x: cell[%d] %s\n", cofst, i, zDesc);
+ if( cellToDecode==(-2) ){
+ printf(" %03x: cell[%d] %s\n", cofst, i, zDesc);
+ }else if( cellToDecode==(-1) || cellToDecode==i ){
+ decodeCell(a, pgno, i, hdrSize, cofst-hdrSize);
+ }
}
if( showMap ){
+ printf("Page map: (H=header P=cell-index 1=page-1-header .=free-space)\n");
for(i=0; i<pagesize; i+=64){
printf(" %03x: %.64s\n", i, &zMap[i]);
}
free(zMap);
- }
+ }
}
/*
@@ -498,7 +695,7 @@ static void page_usage_cell(
int n = 0;
i64 nPayload;
i64 rowid;
- int nLocal;
+ i64 nLocal;
i = 0;
if( cType<=5 ){
a += 4;
@@ -699,12 +896,12 @@ static void page_usage_report(const char *zDbName){
** Try to figure out how every page in the database file is being used.
*/
static void ptrmap_coverage_report(const char *zDbName){
- unsigned int pgno;
+ int pgno;
unsigned char *aHdr;
unsigned char *a;
int usable;
int perPage;
- unsigned int i;
+ int i;
/* Avoid the pathological case */
if( mxPage<1 ){
@@ -757,6 +954,7 @@ static void usage(const char *argv0){
" NNNb Decode btree page NNN\n"
" NNNbc Decode btree page NNN and show content\n"
" NNNbm Decode btree page NNN and show a layout map\n"
+ " NNNbdCCC Decode cell CCC on btree page NNN\n"
" NNNt Decode freelist trunk page NNN\n"
" NNNtd Show leaf freelist pages on the decode\n"
" NNNtr Recurisvely decode freelist starting at NNN\n"
@@ -778,7 +976,7 @@ int main(int argc, char **argv){
zPgSz[0] = 0;
zPgSz[1] = 0;
lseek(db, 16, SEEK_SET);
- read(db, zPgSz, 2);
+ if( read(db, zPgSz, 2)<2 ) memset(zPgSz, 0, 2);
pagesize = zPgSz[0]*256 + zPgSz[1]*65536;
if( pagesize==0 ) pagesize = 1024;
printf("Pagesize: %d\n", pagesize);
diff --git a/lib/libsqlite3/tool/showjournal.c b/lib/libsqlite3/tool/showjournal.c
index 5724f52974b..19220f5196a 100644
--- a/lib/libsqlite3/tool/showjournal.c
+++ b/lib/libsqlite3/tool/showjournal.c
@@ -12,7 +12,6 @@
static int pageSize = 1024;
static int sectorSize = 512;
static FILE *db = 0;
-static int showPageContent = 0;
static int fileSize = 0;
static unsigned cksumNonce = 0;
@@ -26,9 +25,9 @@ static void out_of_memory(void){
** Read N bytes of memory starting at iOfst into space obtained
** from malloc().
*/
-static char *read_content(int N, int iOfst){
+static unsigned char *read_content(int N, int iOfst){
int got;
- char *pBuf = malloc(N);
+ unsigned char *pBuf = malloc(N);
if( pBuf==0 ) out_of_memory();
fseek(db, iOfst, SEEK_SET);
got = fread(pBuf, 1, N, db);
@@ -46,14 +45,14 @@ static char *read_content(int N, int iOfst){
/* Print a line of decode output showing a 4-byte integer.
*/
static unsigned print_decode_line(
- unsigned char *aData, /* Content being decoded */
- int ofst, int nByte, /* Start and size of decode */
- const char *zMsg /* Message to append */
+ const unsigned char *aData, /* Content being decoded */
+ int ofst, int nByte, /* Start and size of decode */
+ const char *zMsg /* Message to append */
){
int i, j;
unsigned val = aData[ofst];
char zBuf[100];
- sprintf(zBuf, " %03x: %02x", ofst, aData[ofst]);
+ sprintf(zBuf, " %05x: %02x", ofst, aData[ofst]);
i = strlen(zBuf);
for(j=1; j<4; j++){
if( j>=nByte ){
@@ -74,7 +73,7 @@ static unsigned print_decode_line(
** in global variables.
*/
static unsigned decode_journal_header(int iOfst){
- char *pHdr = read_content(64, iOfst);
+ unsigned char *pHdr = read_content(64, iOfst);
unsigned nPage;
printf("Header at offset %d:\n", iOfst);
print_decode_line(pHdr, 0, 4, "Header part 1 (3654616569)");
@@ -101,12 +100,11 @@ static void print_page(int iOfst){
char zTitle[50];
aData = read_content(pageSize+8, iOfst);
sprintf(zTitle, "page number for page at offset %d", iOfst);
- print_decode_line(aData, 0, 4, zTitle);
+ print_decode_line(aData-iOfst, iOfst, 4, zTitle);
free(aData);
}
int main(int argc, char **argv){
- int rc;
int nPage, cnt;
int iOfst;
if( argc!=2 ){
@@ -136,4 +134,5 @@ int main(int argc, char **argv){
iOfst = (iOfst/sectorSize + 1)*sectorSize;
}
fclose(db);
+ return 0;
}
diff --git a/lib/libsqlite3/tool/showstat4.c b/lib/libsqlite3/tool/showstat4.c
new file mode 100644
index 00000000000..668d2106af2
--- /dev/null
+++ b/lib/libsqlite3/tool/showstat4.c
@@ -0,0 +1,157 @@
+/*
+** This utility program decodes and displays the content of the
+** sqlite_stat4 table in the database file named on the command
+** line.
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "sqlite3.h"
+
+typedef sqlite3_int64 i64; /* 64-bit signed integer type */
+
+
+/*
+** Convert the var-int format into i64. Return the number of bytes
+** in the var-int. Write the var-int value into *pVal.
+*/
+static int decodeVarint(const unsigned char *z, i64 *pVal){
+ i64 v = 0;
+ int i;
+ for(i=0; i<8; i++){
+ v = (v<<7) + (z[i]&0x7f);
+ if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; }
+ }
+ v = (v<<8) + (z[i]&0xff);
+ *pVal = v;
+ return 9;
+}
+
+
+
+int main(int argc, char **argv){
+ sqlite3 *db;
+ sqlite3_stmt *pStmt;
+ char *zIdx = 0;
+ int rc, j, x, y, mxHdr;
+ const unsigned char *aSample;
+ int nSample;
+ i64 iVal;
+ const char *zSep;
+
+ if( argc!=2 ){
+ fprintf(stderr, "Usage: %s DATABASE-FILE\n", argv[0]);
+ exit(1);
+ }
+ rc = sqlite3_open(argv[1], &db);
+ if( rc!=SQLITE_OK || db==0 ){
+ fprintf(stderr, "Cannot open database file [%s]\n", argv[1]);
+ exit(1);
+ }
+ rc = sqlite3_prepare_v2(db,
+ "SELECT tbl||'.'||idx, nEq, nLT, nDLt, sample "
+ "FROM sqlite_stat4 ORDER BY 1", -1,
+ &pStmt, 0);
+ if( rc!=SQLITE_OK || pStmt==0 ){
+ fprintf(stderr, "%s\n", sqlite3_errmsg(db));
+ sqlite3_close(db);
+ exit(1);
+ }
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
+ if( zIdx==0 || strcmp(zIdx, (const char*)sqlite3_column_text(pStmt,0))!=0 ){
+ if( zIdx ) printf("\n");
+ sqlite3_free(zIdx);
+ zIdx = sqlite3_mprintf("%s", sqlite3_column_text(pStmt,0));
+ printf("%s:\n", zIdx);
+ }else{
+ printf(" -----------------------------------------------------------\n");
+ }
+ printf(" nEq = %s\n", sqlite3_column_text(pStmt,1));
+ printf(" nLt = %s\n", sqlite3_column_text(pStmt,2));
+ printf(" nDLt = %s\n", sqlite3_column_text(pStmt,3));
+ printf(" sample = x'");
+ aSample = sqlite3_column_blob(pStmt,4);
+ nSample = sqlite3_column_bytes(pStmt,4);
+ for(j=0; j<nSample; j++) printf("%02x", aSample[j]);
+ printf("'\n ");
+ zSep = " ";
+ x = decodeVarint(aSample, &iVal);
+ if( iVal<x || iVal>nSample ){
+ printf(" <error>\n");
+ continue;
+ }
+ y = mxHdr = (int)iVal;
+ while( x<mxHdr ){
+ int sz;
+ i64 v;
+ x += decodeVarint(aSample+x, &iVal);
+ if( x>mxHdr ) break;
+ if( iVal<0 ) break;
+ switch( iVal ){
+ case 0: sz = 0; break;
+ case 1: sz = 1; break;
+ case 2: sz = 2; break;
+ case 3: sz = 3; break;
+ case 4: sz = 4; break;
+ case 5: sz = 6; break;
+ case 6: sz = 8; break;
+ case 7: sz = 8; break;
+ case 8: sz = 0; break;
+ case 9: sz = 0; break;
+ case 10:
+ case 11: sz = 0; break;
+ default: sz = (int)(iVal-12)/2; break;
+ }
+ if( y+sz>nSample ) break;
+ if( iVal==0 ){
+ printf("%sNULL", zSep);
+ }else if( iVal==8 || iVal==9 ){
+ printf("%s%d", zSep, ((int)iVal)-8);
+ }else if( iVal<=7 ){
+ v = (signed char)aSample[y];
+ for(j=1; j<sz; j++){
+ v = (v<<8) + aSample[y+j];
+ }
+ if( iVal==7 ){
+ double r;
+ memcpy(&r, &v, sizeof(r));
+ printf("%s%#g", zSep, r);
+ }else{
+ printf("%s%lld", zSep, v);
+ }
+ }else if( (iVal&1)==0 ){
+ printf("%sx'", zSep);
+ for(j=0; j<sz; j++){
+ printf("%02x", aSample[y+j]);
+ }
+ printf("'");
+ }else{
+ printf("%s\"", zSep);
+ for(j=0; j<sz; j++){
+ char c = (char)aSample[y+j];
+ if( isprint(c) ){
+ if( c=='"' || c=='\\' ) putchar('\\');
+ putchar(c);
+ }else if( c=='\n' ){
+ printf("\\n");
+ }else if( c=='\t' ){
+ printf("\\t");
+ }else if( c=='\r' ){
+ printf("\\r");
+ }else{
+ printf("\\%03o", c);
+ }
+ }
+ printf("\"");
+ }
+ zSep = ",";
+ y += sz;
+ }
+ printf("\n");
+ }
+ sqlite3_free(zIdx);
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ return 0;
+}
diff --git a/lib/libsqlite3/tool/showwal.c b/lib/libsqlite3/tool/showwal.c
index 2888c10aa59..6dc1de173f3 100644
--- a/lib/libsqlite3/tool/showwal.c
+++ b/lib/libsqlite3/tool/showwal.c
@@ -6,7 +6,13 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+
+#if !defined(_MSC_VER)
#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
@@ -172,7 +178,7 @@ static void print_decode_line(
int val = aData[ofst];
char zBuf[100];
sprintf(zBuf, " %03x: %02x", ofst, aData[ofst]);
- i = strlen(zBuf);
+ i = (int)strlen(zBuf);
for(j=1; j<4; j++){
if( j>=nByte ){
sprintf(&zBuf[i], " ");
@@ -180,7 +186,7 @@ static void print_decode_line(
sprintf(&zBuf[i], " %02x", aData[ofst+j]);
val = val*256 + aData[ofst+j];
}
- i += strlen(&zBuf[i]);
+ i += (int)strlen(&zBuf[i]);
}
if( asHex ){
sprintf(&zBuf[i], " 0x%08x", val);
@@ -273,14 +279,14 @@ static void print_wal_header(Cksum *pCksum){
/*
** Describe cell content.
*/
-static int describeContent(
+static i64 describeContent(
unsigned char *a, /* Cell content */
- int nLocal, /* Bytes in a[] */
+ i64 nLocal, /* Bytes in a[] */
char *zDesc /* Write description here */
){
int nDesc = 0;
- int n, i, j;
- i64 x, v;
+ int n, j;
+ i64 i, x, v;
const unsigned char *pData;
const unsigned char *pLimit;
char sep = ' ';
@@ -320,15 +326,15 @@ static int describeContent(
}else if( x==9 ){
sprintf(zDesc, "1");
}else if( x>=12 ){
- int size = (x-12)/2;
+ i64 size = (x-12)/2;
if( (x&1)==0 ){
- sprintf(zDesc, "blob(%d)", size);
+ sprintf(zDesc, "blob(%lld)", size);
}else{
- sprintf(zDesc, "txt(%d)", size);
+ sprintf(zDesc, "txt(%lld)", size);
}
pData += size;
}
- j = strlen(zDesc);
+ j = (int)strlen(zDesc);
zDesc += j;
nDesc += j;
}
@@ -339,11 +345,11 @@ static int describeContent(
** Compute the local payload size given the total payload size and
** the page size.
*/
-static int localPayload(i64 nPayload, char cType){
- int maxLocal;
- int minLocal;
- int surplus;
- int nLocal;
+static i64 localPayload(i64 nPayload, char cType){
+ i64 maxLocal;
+ i64 minLocal;
+ i64 surplus;
+ i64 nLocal;
if( cType==13 ){
/* Table leaf */
maxLocal = pagesize-35;
@@ -370,19 +376,19 @@ static int localPayload(i64 nPayload, char cType){
**
** The return value is the local cell size.
*/
-static int describeCell(
+static i64 describeCell(
unsigned char cType, /* Page type */
unsigned char *a, /* Cell content */
int showCellContent, /* Show cell content if true */
char **pzDesc /* Store description here */
){
int i;
- int nDesc = 0;
+ i64 nDesc = 0;
int n = 0;
int leftChild;
i64 nPayload;
i64 rowid;
- int nLocal;
+ i64 nLocal;
static char zDesc[1000];
i = 0;
if( cType<=5 ){
@@ -479,17 +485,17 @@ static void decode_btree_page(
for(i=0; i<nCell; i++){
int cofst = iCellPtr + i*2;
char *zDesc;
- int n;
+ i64 n;
cofst = a[cofst]*256 + a[cofst+1];
n = describeCell(a[0], &a[cofst-hdrSize], showCellContent, &zDesc);
if( showMap ){
char zBuf[30];
- memset(&zMap[cofst], '*', n);
+ memset(&zMap[cofst], '*', (size_t)n);
zMap[cofst] = '[';
zMap[cofst+n-1] = ']';
sprintf(zBuf, "%d", i);
- j = strlen(zBuf);
+ j = (int)strlen(zBuf);
if( j<=n-2 ) memcpy(&zMap[cofst+1], zBuf, j);
}
printf(" %03x: cell[%d] %s\n", cofst, i, zDesc);
diff --git a/lib/libsqlite3/tool/warnings.sh b/lib/libsqlite3/tool/warnings.sh
index 246bccbe23a..5d71361138d 100644
--- a/lib/libsqlite3/tool/warnings.sh
+++ b/lib/libsqlite3/tool/warnings.sh
@@ -4,7 +4,7 @@
# compiler warnings in SQLite.
#
rm -f sqlite3.c
-make sqlite3.c-debug
+make sqlite3.c
echo '********** No optimizations. Includes FTS4 and RTREE *********'
gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \
-ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \
diff --git a/lib/libsqlite3/tool/win/sqlite.vsix b/lib/libsqlite3/tool/win/sqlite.vsix
index ac4afb3f4bc..1450011266b 100644
--- a/lib/libsqlite3/tool/win/sqlite.vsix
+++ b/lib/libsqlite3/tool/win/sqlite.vsix
Binary files differ