Version History
-
1.0.89.0 - October XX, 2013 (release scheduled)
+
1.0.89.0 - September XX, 2013 (release scheduled)
- Updated to SQLite 3.8.1 .
- Add AutoCommit property to the SQLiteConnection class. Fix for [9ba9346f75] .
+ Updated to SQLite 3.8.1 .
Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605] .
Check the result of sqlite3_column_name function against NULL.
Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.
Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801] .
- Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.
Revise how the extra object data is passed to the static SQLiteConnection.Changed event. ** Potentially Incompatible Change **
- Make sure the database cannot be changed by a query when the CommandBehavior.SchemaOnly flag is used. Fix for [f8dbab8baf] . ** Potentially Incompatible Change **
Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6] .
- Add InteropVersion, InteropSourceId, ProviderVersion, and ProviderSourceId properties to the SQLiteConnection class.
- Add experimental support for interfacing with the authorizer callback in the SQLite core library.
1.0.88.0 - August 7, 2013
Various fixes to managed virtual table integration infrastructure.
Implement workaround for an incorrect PROCESSOR_ARCHITECTURE being reported. Fix for [9ac9862611] .
Index: Doc/buildChm.tcl
==================================================================
--- Doc/buildChm.tcl
+++ Doc/buildChm.tcl
@@ -31,65 +31,16 @@
regsub -all -- {&} $data {\\\&} data
regsub -all -- {\\(\d+)} $data {\\\\\1} data
return $data
}
-proc getFileHash { fileName } {
- if {[catch {
- exec fossil.exe sha1sum [file nativename $fileName]
- } result] == 0} then {
- return [string trim [lindex [split $result " "] 0]]
- }
- return ""
-}
-
-#
-# HACK: Copy our local [fixed] copy of the MSDN documenter assembly into the
-# installed location of NDoc3, if necessary. Actually copying the file
-# will require elevated administrator privileges; otherwise, it will
-# fail. Any errors encountered while copying the file are reported via
-# the console; however, they will not halt further processing (i.e. the
-# CHM file will probably still get built, but it may contain some links
-# to built-in types that are blank).
-#
-proc copyMsdnDocumenter { sourceDirectory destinationDirectory } {
- set fileNameOnly NDoc3.Documenter.Msdn.dll
-
- set sourceFileName [file join $sourceDirectory bin $fileNameOnly]
- set destinationFileName [file join $destinationDirectory bin $fileNameOnly]
-
- set sourceFileHash [getFileHash $sourceFileName]
- # puts stdout "Hashed \"$sourceFileName\" ==> \"$sourceFileHash\""
-
- set destinationFileHash [getFileHash $destinationFileName]
- # puts stdout "Hashed \"$destinationFileName\" ==> \"$destinationFileHash\""
-
- if {[string length $sourceFileHash] > 0 && \
- [string length $destinationFileHash] > 0 && \
- $sourceFileHash ne $destinationFileHash} then {
- if {[catch {
- file copy -force $destinationFileName $destinationFileName.bak
- file copy -force $sourceFileName $destinationFileName
- } result] == 0} then {
- puts stdout \
- "finished copying \"$sourceFileName\" to \"$destinationFileName\""
- } else {
- puts stdout $result
- }
- } else {
- puts stdout \
- "skipped copying \"$sourceFileName\" to \"$destinationFileName\""
- }
-}
-
-set path [file normalize [file dirname [info script]]]
-
-set nDocExtPath [file join [file dirname $path] Externals NDoc3]
-set nDocInstPath [file join $env(ProgramFiles) NDoc3]
-
-if {![file isdirectory $nDocInstPath]} then {
- puts stdout "NDoc3 must be installed to: $nDocInstPath"
+set path [file dirname [info script]]
+
+set nDocPath [file join $env(ProgramFiles) NDoc3]
+
+if {![file isdirectory $nDocPath]} then {
+ puts stdout "NDoc3 must be installed to: $nDocPath"
exit 1
}
set hhcPath [file join $env(ProgramFiles) "HTML Help Workshop"]
@@ -144,25 +95,20 @@
#
# TODO: If the NDoc version number ever changes, the next line of code will
# probably need to be updated.
#
-set outputPath [file join Output]
-set temporaryPath [file join $outputPath ndoc3_msdn_temp]
-
-if {[file isdirectory $nDocExtPath]} then {
- copyMsdnDocumenter $nDocExtPath $nDocInstPath
-}
-
-set code [catch {exec [file join $nDocInstPath bin NDoc3Console.exe] \
+set outputPath [file join Output ndoc3_msdn_temp]
+
+set code [catch {exec [file join $nDocPath bin NDoc3Console.exe] \
"-project=[file nativename $projectFile]"} result]
puts stdout $result; if {$code != 0} then {exit $code}
set fileNames [list SQLite.NET.hhp SQLite.NET.hhc]
-foreach fileName [glob -nocomplain [file join $temporaryPath *.html]] {
+foreach fileName [glob -nocomplain [file join $outputPath *.html]] {
lappend fileNames [file tail $fileName]
}
set patterns(.hhc,1) {}
@@ -206,11 +152,11 @@
set subSpecs(.html,6) {"\1~Overloads.html"}
set subSpecs(.html,7) {"\1~Overloads.html"}
set subSpecs(.html,8) {"\1~Overloads.html"}
foreach fileName $fileNames {
- set fileName [file join $path $temporaryPath $fileName]
+ set fileName [file join $path $outputPath $fileName]
#
# NOTE: Make sure the file we need actually exists.
#
if {![file isfile $fileName]} then {
@@ -256,17 +202,17 @@
writeFile $fileName $data
}
}
set code [catch {exec [file join $hhcPath hhc.exe] \
- [file nativename [file join $path $temporaryPath SQLite.NET.hhp]]} result]
+ [file nativename [file join $path $outputPath SQLite.NET.hhp]]} result]
#
# NOTE: For hhc.exe, zero means failure.
#
puts stdout $result; if {$code == 0} then {exit 1}
-file copy -force [file join $path $temporaryPath SQLite.NET.chm] \
+file copy -force [file join $path $outputPath SQLite.NET.chm] \
[file join $path SQLite.NET.chm]
puts stdout SUCCESS
exit 0
Index: Externals/Eagle/bin/Eagle.dll
==================================================================
--- Externals/Eagle/bin/Eagle.dll
+++ Externals/Eagle/bin/Eagle.dll
cannot compute difference between binary files
Index: Externals/Eagle/bin/EagleShell.exe
==================================================================
--- Externals/Eagle/bin/EagleShell.exe
+++ Externals/Eagle/bin/EagleShell.exe
cannot compute difference between binary files
Index: Externals/Eagle/bin/EagleShell.exe.mda.config
==================================================================
--- Externals/Eagle/bin/EagleShell.exe.mda.config
+++ Externals/Eagle/bin/EagleShell.exe.mda.config
@@ -10,22 +10,10 @@
*
* RCS: @(#) $Id: $
*
-->
-
- */
- #endregion
- }
-
- #region BuildNameTables
-
- private void BuildNameTables(XmlDocument xmlDocumentation, bool mergeNamespaces) {
- XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocumentation.NameTable);
- nsmgr.AddNamespace("ns", "urn:ndoc-schema");
- XmlNodeList assemblies = xmlDocumentation.SelectNodes("/ns:ndoc/ns:assembly", nsmgr);
- if(assemblies == null) throw new Exception("No assemblies found");
- foreach (XmlElement assemblyNode in assemblies) {
- string assemblyName = GetNodeName(assemblyNode);
- RegisterAssembly(assemblyName);
-
- // build list of assemblyReferences
- XmlNodeList assemblyReferenceNodes = assemblyNode.SelectNodes("ns:assemblyReference", nsmgr);
- if(assemblyReferenceNodes == null) throw new Exception("No assembly reference nodes found");
- List assemblyReferenceNames = new List();
- foreach (XmlNode assemblyReferenceNode in assemblyReferenceNodes) {
- assemblyReferenceNames.Add(GetNodeName(assemblyReferenceNode));
- }
- assemblyReferences.Add(assemblyName, assemblyReferenceNames.ToArray());
-
- // foreach namespace
- XmlNodeList namespaces = assemblyNode.SelectNodes("ns:module/ns:namespace", nsmgr);
- if(namespaces == null) throw new Exception("No namespaces found");
- foreach (XmlElement namespaceNode in namespaces) {
- string namespaceName = GetNodeName(namespaceNode);
- // register namespace
- RegisterNamespace((mergeNamespaces ? string.Empty : assemblyName), namespaceName);
-
- XmlNodeList types = namespaceNode.SelectNodes("*[@id]", nsmgr);
- if(types == null) throw new Exception("No types found");
- foreach (XmlElement typeNode in types) {
- string typeId = GetNodeId(typeNode);
- //TODO The rest should also use displayName ((EE): clarify what above line means - shall we remove 'name' attribute then?)
- string typeDisplayName = GetNodeDisplayName(typeNode);
- RegisterType(assemblyName, typeId, typeDisplayName);
-
- // foreach member
- XmlNodeList members = typeNode.SelectNodes("*[@id]");
- if(members == null) throw new Exception("No type members found");
- foreach (XmlElement memberNode in members) {
- string memberId = GetNodeId(memberNode);
- switch (memberNode.Name) {
- case "constructor": {
- string overload = XmlUtils.GetAttributeString(memberNode, "overload", false);
- RegisterConstructor(assemblyName, typeId, memberId, overload);
- }
- break;
- case "field": {
- bool isEnum = (typeNode.Name == "enumeration");
- string memberName = GetNodeName(memberNode);
- RegisterField(assemblyName, typeId, memberId, isEnum, memberName);
- }
- break;
- case "property": {
- string overload = GetNodeOverload(memberNode);
- string memberName = GetNodeName(memberNode);
- RegisterProperty(assemblyName, memberId, memberName, overload);
- }
- break;
- case "method": {
- string overload = GetNodeOverload(memberNode);
- string memberDisplayName = GetNodeDisplayName(memberNode);
- RegisterMethod(assemblyName, memberId, memberDisplayName, overload);
- }
- break;
- case "operator": {
- string overload = GetNodeOverload(memberNode);
- string memberName = GetNodeName(memberNode);
- RegisterOperator(assemblyName, memberId, memberName, overload);
- }
- break;
- case "event": {
- string memberName = GetNodeName(memberNode);
- RegisterEvent(assemblyName, memberId, memberName);
- }
- break;
- }
- }
- }
- }
- }
- }
-
- private void RegisterAssembly(string assemblyName) {
- Register(assemblyName, null, assemblyName, CalculateFilenameForId(assemblyName, null, null));
- }
-
- private void RegisterNamespace(string assemblyName, string namespaceName) {
- if (string.IsNullOrEmpty(namespaceName)) {
- namespaceName = "(global)";
- }
- string namespaceId = "N:" + namespaceName;
- Register(assemblyName, namespaceId, namespaceName, CalculateFilenameForId(assemblyName, namespaceId, null));
- }
-
- private void RegisterType(string assemblyName, string typeId, string displayName) {
- Register(assemblyName, typeId, displayName, CalculateFilenameForId(assemblyName, typeId, null));
- }
-
- private void RegisterConstructor(string assemblyName, string typeId, string id, string overload) {
- Register(assemblyName, id, GetDisplayNameForId(assemblyName, typeId), CalculateFilenameForId(assemblyName, id, overload));
- }
-
- private void RegisterOperator(string assemblyName, string memberId, string memberName, string overload) {
- Register(assemblyName, memberId, memberName, CalculateFilenameForId(assemblyName, memberId, overload));
- }
-
- private void RegisterMethod(string assemblyName, string memberId, string memberDisplayName, string overload) {
- Register(assemblyName, memberId, memberDisplayName, CalculateFilenameForId(assemblyName, memberId, overload));
- }
-
- private void RegisterProperty(string assemblyName, string memberId, string memberName, string overload) {
- Register(assemblyName, memberId, memberName, CalculateFilenameForId(assemblyName, memberId, overload));
- }
-
- private void RegisterField(string assemblyName, string typeId, string memberId, bool isEnum, string memberName) {
- if (isEnum) {
- Register(assemblyName, memberId, memberName, GetFilenameForId(assemblyName, typeId));
- } else {
- Register(assemblyName, memberId, memberName, CalculateFilenameForId(assemblyName, memberId, null));
- }
- }
-
- private void RegisterEvent(string assemblyName, string memberId, string memberName) {
- Register(assemblyName, memberId, memberName, CalculateFilenameForId(assemblyName, memberId, null));
- }
-
-
- #endregion
-
- #region Registration & Lookup Logic
-
- private string GetFilenameForIdInternal(string currentAssemblyName, string memberId) {
- string filename = fileNames[currentAssemblyName + memberId];
- if (filename == null) {
- // search for identifier in referenced assemblies
- string[] assemblyReference = assemblyReferences[currentAssemblyName];
- if (assemblyReference != null) {
- foreach (string assemblyName in assemblyReference) {
- filename = fileNames[assemblyName + memberId];
- if (filename != null)
- break;
- }
- }
- }
-
- if (filename == null && memberId != null) {
- filename = fileNames[memberId];
- }
-
- // Debug.Assert(filename != null, string.Format("Filename for assembly:memberId [{0}:{1}] not found", currentAssemblyName, memberId));
- // Debug.WriteLine(string.Format("GetFilenameForIdInternal('{0}','{1}') => {2}", currentAssemblyName, memberId, filename));
- if (filename != null)
- return filename;
-
- if (utilities != null)
- {
- if (memberId.Length > 2 && memberId[1] == ':')
- memberId = memberId.Substring(2);
-
- filename = utilities.FormatOnlineSDKLink(memberId);
-
- if (filename != null)
- return filename;
- }
-
- return String.Empty;
- }
-
- private string GetFilenameForIdSpecial(string assemblyName, string memberId, string postfix) {
- string fn = GetFilenameForIdInternal(assemblyName, memberId);
- if (fn != null && fn.Length > EXT.Length) {
- fn = fn.Insert(fn.Length - EXT.Length, postfix);
- }
- // Debug.WriteLine(string.Format("GetFilenameForIdSpecial('{0}','{1}') => {2}", assemblyName, memberId, fn));
- return fn;
- }
-
- private void Register(string assemblyName, string id, string displayName, string fileName) {
- // Debug.WriteLine(string.Format("Registering [{0},{1}]=[{2},{3}]", assemblyName, id, displayName, fileName));
- fileNames[assemblyName + id] = fileName;
- elemNames[assemblyName + id] = displayName;
- }
-
- ///
- /// of the form "T:XXX", "F:XXX" etc
- ///
- private static string CalculateFilenameForId(string assemblyName, string id, string overload) {
- if (id == null) {
- return assemblyName + EXT;
- }
-
- // char idType = '\0';
- int ix = id.IndexOf(':');
- // if (ix > -1) {
- // idType = id[0];
- // }
- id = id.Substring(ix + 1);
-
- // constructors could be #ctor or #cctor
- // int ixDotHash = id.IndexOf(".#c");
- // if (ixDotHash > -1)
- // id = id.Substring(0, ixDotHash);
-
- // methods could have "("
- int ixLBrace = id.IndexOf("(");
- if (ixLBrace > -1)
- id = id.Substring(0, ixLBrace);
-
- if (overload != null) {
- id += overload;
- }
-
- id = id.Replace('#', '~');
- // generic methods have the form "methodname"
- id = id.Replace('<', '{');
- id = id.Replace('>', '}');
-
- id = id.Replace('`', '$');
- return assemblyName + "~" + id + EXT;
- }
-
- #endregion
-
- #region Xml Utility Methods
-
- private static string GetNodeOverload(XmlNode memberNode) {
- return XmlUtils.GetAttributeString(memberNode, "overload", false);
- }
-
- private static string GetNodeId(XmlNode node) {
- return XmlUtils.GetNodeId(node);
- }
-
- private static string GetNodeName(XmlNode node) {
- return XmlUtils.GetNodeName(node);
- }
-
- private static string GetNodeDisplayName(XmlNode node) {
- return XmlUtils.GetNodeDisplayName(node);
- }
-
- #endregion
- }
-}
Index: SQLite.Interop/SQLite.Interop.2005.vcproj
==================================================================
--- SQLite.Interop/SQLite.Interop.2005.vcproj
+++ SQLite.Interop/SQLite.Interop.2005.vcproj
@@ -949,78 +949,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
true
- true
-
-
true
true
Index: SQLite.Interop/SQLite.Interop.2010.vcxproj.filters
==================================================================
--- SQLite.Interop/SQLite.Interop.2010.vcxproj.filters
+++ SQLite.Interop/SQLite.Interop.2010.vcxproj.filters
@@ -33,13 +33,10 @@
Source Files
Source Files
-
- Source Files
-
Source Files
Source Files
Index: SQLite.Interop/SQLite.Interop.2012.vcxproj
==================================================================
--- SQLite.Interop/SQLite.Interop.2012.vcxproj
+++ SQLite.Interop/SQLite.Interop.2012.vcxproj
@@ -480,13 +480,10 @@
true
- true
-
-
true
true
Index: SQLite.Interop/SQLite.Interop.2012.vcxproj.filters
==================================================================
--- SQLite.Interop/SQLite.Interop.2012.vcxproj.filters
+++ SQLite.Interop/SQLite.Interop.2012.vcxproj.filters
@@ -33,13 +33,10 @@
Source Files
Source Files
-
- Source Files
-
Source Files
Source Files
Index: SQLite.Interop/SQLite.Interop.CE.2005.vcproj
==================================================================
--- SQLite.Interop/SQLite.Interop.CE.2005.vcproj
+++ SQLite.Interop/SQLite.Interop.CE.2005.vcproj
@@ -735,62 +735,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
true
- true
-
-
true
true
Index: SQLite.Interop/SQLite.Interop.Static.2010.vcxproj.filters
==================================================================
--- SQLite.Interop/SQLite.Interop.Static.2010.vcxproj.filters
+++ SQLite.Interop/SQLite.Interop.Static.2010.vcxproj.filters
@@ -33,13 +33,10 @@
Source Files
Source Files
-
- Source Files
-
Source Files
Source Files
Index: SQLite.Interop/SQLite.Interop.Static.2012.vcxproj
==================================================================
--- SQLite.Interop/SQLite.Interop.Static.2012.vcxproj
+++ SQLite.Interop/SQLite.Interop.Static.2012.vcxproj
@@ -480,13 +480,10 @@
true
- true
-
-
true
true
Index: SQLite.Interop/SQLite.Interop.Static.2012.vcxproj.filters
==================================================================
--- SQLite.Interop/SQLite.Interop.Static.2012.vcxproj.filters
+++ SQLite.Interop/SQLite.Interop.Static.2012.vcxproj.filters
@@ -33,13 +33,10 @@
Source Files
Source Files
-
- Source Files
-
Source Files
Source Files
Index: SQLite.Interop/props/SQLite.Interop.2005.vsprops
==================================================================
--- SQLite.Interop/props/SQLite.Interop.2005.vsprops
+++ SQLite.Interop/props/SQLite.Interop.2005.vsprops
@@ -57,11 +57,11 @@
Value="INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1"
PerformEnvironmentSet="true"
/>
1,0,89,0
src\core
INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1
- INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_TOTYPE_EXTENSION=1
+ INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1
/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp
$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk
SQLite.Interop
System.Data.SQLite
Index: SQLite.Interop/props/SQLite.Interop.2012.props
==================================================================
--- SQLite.Interop/props/SQLite.Interop.2012.props
+++ SQLite.Interop/props/SQLite.Interop.2012.props
@@ -16,11 +16,11 @@
1,0,89,0
src\core
INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1
- INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_TOTYPE_EXTENSION=1
+ INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1
/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp
$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk
SQLite.Interop
System.Data.SQLite
Index: SQLite.Interop/src/core/sqlite3.c
==================================================================
--- SQLite.Interop/src/core/sqlite3.c
+++ SQLite.Interop/src/core/sqlite3.c
@@ -23,10 +23,531 @@
# define SQLITE_PRIVATE static
#endif
#ifndef SQLITE_API
# define SQLITE_API
#endif
+/************** Begin file sqliteInt.h ***************************************/
+/*
+** 2001 September 15
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** Internal interface definitions for SQLite.
+**
+*/
+#ifndef _SQLITEINT_H_
+#define _SQLITEINT_H_
+
+/*
+** These #defines should enable >2GB file support on POSIX if the
+** underlying operating system supports it. If the OS lacks
+** large file support, or if the OS is windows, these should be no-ops.
+**
+** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
+** system #includes. Hence, this block of code must be the very first
+** code in all source files.
+**
+** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
+** on the compiler command line. This is necessary if you are compiling
+** on a recent machine (ex: Red Hat 7.2) but you want your code to work
+** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
+** without this option, LFS is enable. But LFS does not exist in the kernel
+** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
+** portability you should omit LFS.
+**
+** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
+*/
+#ifndef SQLITE_DISABLE_LFS
+# define _LARGE_FILE 1
+# ifndef _FILE_OFFSET_BITS
+# define _FILE_OFFSET_BITS 64
+# endif
+# define _LARGEFILE_SOURCE 1
+#endif
+
+/*
+** Include the configuration header output by 'configure' if we're using the
+** autoconf-based build
+*/
+#ifdef _HAVE_SQLITE_CONFIG_H
+#include "config.h"
+#endif
+
+/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
+/************** Begin file sqliteLimit.h *************************************/
+/*
+** 2007 May 7
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file defines various limits of what SQLite can process.
+*/
+
+/*
+** The maximum length of a TEXT or BLOB in bytes. This also
+** limits the size of a row in a table or index.
+**
+** The hard limit is the ability of a 32-bit signed integer
+** to count the size: 2^31-1 or 2147483647.
+*/
+#ifndef SQLITE_MAX_LENGTH
+# define SQLITE_MAX_LENGTH 1000000000
+#endif
+
+/*
+** This is the maximum number of
+**
+** * Columns in a table
+** * Columns in an index
+** * Columns in a view
+** * Terms in the SET clause of an UPDATE statement
+** * Terms in the result set of a SELECT statement
+** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
+** * Terms in the VALUES clause of an INSERT statement
+**
+** The hard upper limit here is 32676. Most database people will
+** tell you that in a well-normalized database, you usually should
+** not have more than a dozen or so columns in any table. And if
+** that is the case, there is no point in having more than a few
+** dozen values in any of the other situations described above.
+*/
+#ifndef SQLITE_MAX_COLUMN
+# define SQLITE_MAX_COLUMN 2000
+#endif
+
+/*
+** The maximum length of a single SQL statement in bytes.
+**
+** It used to be the case that setting this value to zero would
+** turn the limit off. That is no longer true. It is not possible
+** to turn this limit off.
+*/
+#ifndef SQLITE_MAX_SQL_LENGTH
+# define SQLITE_MAX_SQL_LENGTH 1000000000
+#endif
+
+/*
+** The maximum depth of an expression tree. This is limited to
+** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
+** want to place more severe limits on the complexity of an
+** expression.
+**
+** A value of 0 used to mean that the limit was not enforced.
+** But that is no longer true. The limit is now strictly enforced
+** at all times.
+*/
+#ifndef SQLITE_MAX_EXPR_DEPTH
+# define SQLITE_MAX_EXPR_DEPTH 1000
+#endif
+
+/*
+** The maximum number of terms in a compound SELECT statement.
+** The code generator for compound SELECT statements does one
+** level of recursion for each term. A stack overflow can result
+** if the number of terms is too large. In practice, most SQL
+** never has more than 3 or 4 terms. Use a value of 0 to disable
+** any limit on the number of terms in a compount SELECT.
+*/
+#ifndef SQLITE_MAX_COMPOUND_SELECT
+# define SQLITE_MAX_COMPOUND_SELECT 500
+#endif
+
+/*
+** The maximum number of opcodes in a VDBE program.
+** Not currently enforced.
+*/
+#ifndef SQLITE_MAX_VDBE_OP
+# define SQLITE_MAX_VDBE_OP 25000
+#endif
+
+/*
+** The maximum number of arguments to an SQL function.
+*/
+#ifndef SQLITE_MAX_FUNCTION_ARG
+# define SQLITE_MAX_FUNCTION_ARG 127
+#endif
+
+/*
+** The maximum number of in-memory pages to use for the main database
+** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
+*/
+#ifndef SQLITE_DEFAULT_CACHE_SIZE
+# define SQLITE_DEFAULT_CACHE_SIZE 2000
+#endif
+#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
+# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
+#endif
+
+/*
+** The default number of frames to accumulate in the log file before
+** checkpointing the database in WAL mode.
+*/
+#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
+# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
+#endif
+
+/*
+** The maximum number of attached databases. This must be between 0
+** and 62. The upper bound on 62 is because a 64-bit integer bitmap
+** is used internally to track attached databases.
+*/
+#ifndef SQLITE_MAX_ATTACHED
+# define SQLITE_MAX_ATTACHED 10
+#endif
+
+
+/*
+** The maximum value of a ?nnn wildcard that the parser will accept.
+*/
+#ifndef SQLITE_MAX_VARIABLE_NUMBER
+# define SQLITE_MAX_VARIABLE_NUMBER 999
+#endif
+
+/* Maximum page size. The upper bound on this value is 65536. This a limit
+** imposed by the use of 16-bit offsets within each page.
+**
+** Earlier versions of SQLite allowed the user to change this value at
+** compile time. This is no longer permitted, on the grounds that it creates
+** a library that is technically incompatible with an SQLite library
+** compiled with a different limit. If a process operating on a database
+** with a page-size of 65536 bytes crashes, then an instance of SQLite
+** compiled with the default page-size limit will not be able to rollback
+** the aborted transaction. This could lead to database corruption.
+*/
+#ifdef SQLITE_MAX_PAGE_SIZE
+# undef SQLITE_MAX_PAGE_SIZE
+#endif
+#define SQLITE_MAX_PAGE_SIZE 65536
+
+
+/*
+** The default size of a database page.
+*/
+#ifndef SQLITE_DEFAULT_PAGE_SIZE
+# define SQLITE_DEFAULT_PAGE_SIZE 1024
+#endif
+#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
+# undef SQLITE_DEFAULT_PAGE_SIZE
+# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
+#endif
+
+/*
+** Ordinarily, if no value is explicitly provided, SQLite creates databases
+** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
+** device characteristics (sector-size and atomic write() support),
+** SQLite may choose a larger value. This constant is the maximum value
+** SQLite will choose on its own.
+*/
+#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
+# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
+#endif
+#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
+# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
+# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
+#endif
+
+
+/*
+** Maximum number of pages in one database file.
+**
+** This is really just the default value for the max_page_count pragma.
+** This value can be lowered (or raised) at run-time using that the
+** max_page_count macro.
+*/
+#ifndef SQLITE_MAX_PAGE_COUNT
+# define SQLITE_MAX_PAGE_COUNT 1073741823
+#endif
+
+/*
+** Maximum length (in bytes) of the pattern in a LIKE or GLOB
+** operator.
+*/
+#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
+# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
+#endif
+
+/*
+** Maximum depth of recursion for triggers.
+**
+** A value of 1 means that a trigger program will not be able to itself
+** fire any triggers. A value of 0 means that no trigger programs at all
+** may be executed.
+*/
+#ifndef SQLITE_MAX_TRIGGER_DEPTH
+# define SQLITE_MAX_TRIGGER_DEPTH 1000
+#endif
+
+/************** End of sqliteLimit.h *****************************************/
+/************** Continuing where we left off in sqliteInt.h ******************/
+
+/* Disable nuisance warnings on Borland compilers */
+#if defined(__BORLANDC__)
+#pragma warn -rch /* unreachable code */
+#pragma warn -ccc /* Condition is always true or false */
+#pragma warn -aus /* Assigned value is never used */
+#pragma warn -csu /* Comparing signed and unsigned */
+#pragma warn -spa /* Suspicious pointer arithmetic */
+#endif
+
+/* Needed for various definitions... */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
+# define _BSD_SOURCE
+#endif
+
+/*
+** Include standard header files as necessary
+*/
+#ifdef HAVE_STDINT_H
+#include
+#endif
+#ifdef HAVE_INTTYPES_H
+#include
+#endif
+
+/*
+** The following macros are used to cast pointers to integers and
+** integers to pointers. The way you do this varies from one compiler
+** to the next, so we have developed the following set of #if statements
+** to generate appropriate macros for a wide range of compilers.
+**
+** The correct "ANSI" way to do this is to use the intptr_t type.
+** Unfortunately, that typedef is not available on all compilers, or
+** if it is available, it requires an #include of specific headers
+** that vary from one machine to the next.
+**
+** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
+** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
+** So we have to define the macros in different ways depending on the
+** compiler.
+*/
+#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
+# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
+# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
+#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
+# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
+# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
+#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
+# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
+# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
+#else /* Generates a warning - but it always works */
+# define SQLITE_INT_TO_PTR(X) ((void*)(X))
+# define SQLITE_PTR_TO_INT(X) ((int)(X))
+#endif
+
+/*
+** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
+** 0 means mutexes are permanently disable and the library is never
+** threadsafe. 1 means the library is serialized which is the highest
+** level of threadsafety. 2 means the library is multithreaded - multiple
+** threads can use SQLite as long as no two threads try to use the same
+** database connection at the same time.
+**
+** Older versions of SQLite used an optional THREADSAFE macro.
+** We support that for legacy.
+*/
+#if !defined(SQLITE_THREADSAFE)
+# if defined(THREADSAFE)
+# define SQLITE_THREADSAFE THREADSAFE
+# else
+# define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */
+# endif
+#endif
+
+/*
+** Powersafe overwrite is on by default. But can be turned off using
+** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
+*/
+#ifndef SQLITE_POWERSAFE_OVERWRITE
+# define SQLITE_POWERSAFE_OVERWRITE 1
+#endif
+
+/*
+** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
+** It determines whether or not the features related to
+** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
+** be overridden at runtime using the sqlite3_config() API.
+*/
+#if !defined(SQLITE_DEFAULT_MEMSTATUS)
+# define SQLITE_DEFAULT_MEMSTATUS 1
+#endif
+
+/*
+** Exactly one of the following macros must be defined in order to
+** specify which memory allocation subsystem to use.
+**
+** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
+** SQLITE_WIN32_MALLOC // Use Win32 native heap API
+** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails
+** SQLITE_MEMDEBUG // Debugging version of system malloc()
+**
+** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
+** assert() macro is enabled, each call into the Win32 native heap subsystem
+** will cause HeapValidate to be called. If heap validation should fail, an
+** assertion will be triggered.
+**
+** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
+** the default.
+*/
+#if defined(SQLITE_SYSTEM_MALLOC) \
+ + defined(SQLITE_WIN32_MALLOC) \
+ + defined(SQLITE_ZERO_MALLOC) \
+ + defined(SQLITE_MEMDEBUG)>1
+# error "Two or more of the following compile-time configuration options\
+ are defined but at most one is allowed:\
+ SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\
+ SQLITE_ZERO_MALLOC"
+#endif
+#if defined(SQLITE_SYSTEM_MALLOC) \
+ + defined(SQLITE_WIN32_MALLOC) \
+ + defined(SQLITE_ZERO_MALLOC) \
+ + defined(SQLITE_MEMDEBUG)==0
+# define SQLITE_SYSTEM_MALLOC 1
+#endif
+
+/*
+** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
+** sizes of memory allocations below this value where possible.
+*/
+#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
+# define SQLITE_MALLOC_SOFT_LIMIT 1024
+#endif
+
+/*
+** We need to define _XOPEN_SOURCE as follows in order to enable
+** recursive mutexes on most Unix systems and fchmod() on OpenBSD.
+** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit
+** it.
+*/
+#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
+# define _XOPEN_SOURCE 600
+#endif
+
+/*
+** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
+** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
+** make it true by defining or undefining NDEBUG.
+**
+** Setting NDEBUG makes the code smaller and faster by disabling the
+** assert() statements in the code. So we want the default action
+** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
+** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
+** feature.
+*/
+#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
+# define NDEBUG 1
+#endif
+#if defined(NDEBUG) && defined(SQLITE_DEBUG)
+# undef NDEBUG
+#endif
+
+/*
+** The testcase() macro is used to aid in coverage testing. When
+** doing coverage testing, the condition inside the argument to
+** testcase() must be evaluated both true and false in order to
+** get full branch coverage. The testcase() macro is inserted
+** to help ensure adequate test coverage in places where simple
+** condition/decision coverage is inadequate. For example, testcase()
+** can be used to make sure boundary values are tested. For
+** bitmask tests, testcase() can be used to make sure each bit
+** is significant and used at least once. On switch statements
+** where multiple cases go to the same block of code, testcase()
+** can insure that all cases are evaluated.
+**
+*/
+#ifdef SQLITE_COVERAGE_TEST
+SQLITE_PRIVATE void sqlite3Coverage(int);
+# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
+#else
+# define testcase(X)
+#endif
+
+/*
+** The TESTONLY macro is used to enclose variable declarations or
+** other bits of code that are needed to support the arguments
+** within testcase() and assert() macros.
+*/
+#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
+# define TESTONLY(X) X
+#else
+# define TESTONLY(X)
+#endif
+
+/*
+** Sometimes we need a small amount of code such as a variable initialization
+** to setup for a later assert() statement. We do not want this code to
+** appear when assert() is disabled. The following macro is therefore
+** used to contain that setup code. The "VVA" acronym stands for
+** "Verification, Validation, and Accreditation". In other words, the
+** code within VVA_ONLY() will only run during verification processes.
+*/
+#ifndef NDEBUG
+# define VVA_ONLY(X) X
+#else
+# define VVA_ONLY(X)
+#endif
+
+/*
+** The ALWAYS and NEVER macros surround boolean expressions which
+** are intended to always be true or false, respectively. Such
+** expressions could be omitted from the code completely. But they
+** are included in a few cases in order to enhance the resilience
+** of SQLite to unexpected behavior - to make the code "self-healing"
+** or "ductile" rather than being "brittle" and crashing at the first
+** hint of unplanned behavior.
+**
+** In other words, ALWAYS and NEVER are added for defensive code.
+**
+** When doing coverage testing ALWAYS and NEVER are hard-coded to
+** be true and false so that the unreachable code they specify will
+** not be counted as untested code.
+*/
+#if defined(SQLITE_COVERAGE_TEST)
+# define ALWAYS(X) (1)
+# define NEVER(X) (0)
+#elif !defined(NDEBUG)
+# define ALWAYS(X) ((X)?1:(assert(0),0))
+# define NEVER(X) ((X)?(assert(0),1):0)
+#else
+# define ALWAYS(X) (X)
+# define NEVER(X) (X)
+#endif
+
+/*
+** Return true (non-zero) if the input is a integer that is too large
+** to fit in 32-bits. This macro is used inside of various testcase()
+** macros to verify that we have tested SQLite for large-file support.
+*/
+#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
+
+/*
+** The macro unlikely() is a hint that surrounds a boolean
+** expression that is usually false. Macro likely() surrounds
+** a boolean expression that is usually true. These hints could,
+** in theory, be used by the compiler to generate better code, but
+** currently they are just comments for human readers.
+*/
+#define likely(X) (X)
+#define unlikely(X) (X)
+
+/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
/************** Begin file sqlite3.h *****************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code. In place of
@@ -135,11 +656,11 @@
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.8.1"
#define SQLITE_VERSION_NUMBER 3008001
-#define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
+#define SQLITE_SOURCE_ID "2013-09-12 02:09:05 75a8a8c1b39725d36db627536d0c69401f8e0815"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version, sqlite3_sourceid
**
@@ -1643,31 +2164,31 @@
** supplied by the application must not invoke any SQLite interface.
** In a multi-threaded application, the application-defined logger
** function must be threadsafe.
**
** [[SQLITE_CONFIG_URI]] SQLITE_CONFIG_URI
-** ^(This option takes a single argument of type int. If non-zero, then
+** This option takes a single argument of type int. If non-zero, then
** URI handling is globally enabled. If the parameter is zero, then URI handling
-** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
+** is globally disabled. If URI handling is globally enabled, all filenames
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
-** connection is opened. ^If it is globally disabled, filenames are
+** connection is opened. If it is globally disabled, filenames are
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
-** database connection is opened. ^(By default, URI handling is globally
+** database connection is opened. By default, URI handling is globally
** disabled. The default value may be changed by compiling with the
-** [SQLITE_USE_URI] symbol defined.)^
+** [SQLITE_USE_URI] symbol defined.
**
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] SQLITE_CONFIG_COVERING_INDEX_SCAN
-** ^This option takes a single integer argument which is interpreted as
+** This option takes a single integer argument which is interpreted as
** a boolean in order to enable or disable the use of covering indices for
-** full table scans in the query optimizer. ^The default setting is determined
+** full table scans in the query optimizer. The default setting is determined
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
** if that compile-time option is omitted.
** The ability to disable the use of covering indices for full table scans
** is because some incorrectly coded legacy applications might malfunction
-** when the optimization is enabled. Providing the ability to
+** malfunction when the optimization is enabled. Providing the ability to
** disable the optimization allows the older, buggy application code to work
** without change even with newer versions of SQLite.
**
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
** SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +2213,20 @@
** configuration option can be seen in the "test_sqllog.c" source file in
** the canonical SQLite source tree.
**
** [[SQLITE_CONFIG_MMAP_SIZE]]
** SQLITE_CONFIG_MMAP_SIZE
-** ^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
+** SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
** that are the default mmap size limit (the default setting for
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
-** ^The default setting can be overridden by each database connection using
+** The default setting can be overridden by each database connection using
** either the [PRAGMA mmap_size] command, or by using the
-** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
+** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
** cannot be changed at run-time. Nor may the maximum allowed mmap size
** exceed the compile-time maximum mmap size set by the
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
-** ^If either argument to this option is negative, then that argument is
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.
+** If either argument to this option is negative, then that argument is
** changed to its compile-time default.
**
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -7325,530 +7846,11 @@
#endif /* ifndef _SQLITE3RTREE_H_ */
/************** End of sqlite3.h *********************************************/
-/************** Begin file sqliteInt.h ***************************************/
-/*
-** 2001 September 15
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** Internal interface definitions for SQLite.
-**
-*/
-#ifndef _SQLITEINT_H_
-#define _SQLITEINT_H_
-
-/*
-** These #defines should enable >2GB file support on POSIX if the
-** underlying operating system supports it. If the OS lacks
-** large file support, or if the OS is windows, these should be no-ops.
-**
-** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
-** system #includes. Hence, this block of code must be the very first
-** code in all source files.
-**
-** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
-** on the compiler command line. This is necessary if you are compiling
-** on a recent machine (ex: Red Hat 7.2) but you want your code to work
-** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
-** without this option, LFS is enable. But LFS does not exist in the kernel
-** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
-** portability you should omit LFS.
-**
-** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
-*/
-#ifndef SQLITE_DISABLE_LFS
-# define _LARGE_FILE 1
-# ifndef _FILE_OFFSET_BITS
-# define _FILE_OFFSET_BITS 64
-# endif
-# define _LARGEFILE_SOURCE 1
-#endif
-
-/*
-** Include the configuration header output by 'configure' if we're using the
-** autoconf-based build
-*/
-#ifdef _HAVE_SQLITE_CONFIG_H
-#include "config.h"
-#endif
-
-/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
-/************** Begin file sqliteLimit.h *************************************/
-/*
-** 2007 May 7
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-**
-** This file defines various limits of what SQLite can process.
-*/
-
-/*
-** The maximum length of a TEXT or BLOB in bytes. This also
-** limits the size of a row in a table or index.
-**
-** The hard limit is the ability of a 32-bit signed integer
-** to count the size: 2^31-1 or 2147483647.
-*/
-#ifndef SQLITE_MAX_LENGTH
-# define SQLITE_MAX_LENGTH 1000000000
-#endif
-
-/*
-** This is the maximum number of
-**
-** * Columns in a table
-** * Columns in an index
-** * Columns in a view
-** * Terms in the SET clause of an UPDATE statement
-** * Terms in the result set of a SELECT statement
-** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
-** * Terms in the VALUES clause of an INSERT statement
-**
-** The hard upper limit here is 32676. Most database people will
-** tell you that in a well-normalized database, you usually should
-** not have more than a dozen or so columns in any table. And if
-** that is the case, there is no point in having more than a few
-** dozen values in any of the other situations described above.
-*/
-#ifndef SQLITE_MAX_COLUMN
-# define SQLITE_MAX_COLUMN 2000
-#endif
-
-/*
-** The maximum length of a single SQL statement in bytes.
-**
-** It used to be the case that setting this value to zero would
-** turn the limit off. That is no longer true. It is not possible
-** to turn this limit off.
-*/
-#ifndef SQLITE_MAX_SQL_LENGTH
-# define SQLITE_MAX_SQL_LENGTH 1000000000
-#endif
-
-/*
-** The maximum depth of an expression tree. This is limited to
-** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
-** want to place more severe limits on the complexity of an
-** expression.
-**
-** A value of 0 used to mean that the limit was not enforced.
-** But that is no longer true. The limit is now strictly enforced
-** at all times.
-*/
-#ifndef SQLITE_MAX_EXPR_DEPTH
-# define SQLITE_MAX_EXPR_DEPTH 1000
-#endif
-
-/*
-** The maximum number of terms in a compound SELECT statement.
-** The code generator for compound SELECT statements does one
-** level of recursion for each term. A stack overflow can result
-** if the number of terms is too large. In practice, most SQL
-** never has more than 3 or 4 terms. Use a value of 0 to disable
-** any limit on the number of terms in a compount SELECT.
-*/
-#ifndef SQLITE_MAX_COMPOUND_SELECT
-# define SQLITE_MAX_COMPOUND_SELECT 500
-#endif
-
-/*
-** The maximum number of opcodes in a VDBE program.
-** Not currently enforced.
-*/
-#ifndef SQLITE_MAX_VDBE_OP
-# define SQLITE_MAX_VDBE_OP 25000
-#endif
-
-/*
-** The maximum number of arguments to an SQL function.
-*/
-#ifndef SQLITE_MAX_FUNCTION_ARG
-# define SQLITE_MAX_FUNCTION_ARG 127
-#endif
-
-/*
-** The maximum number of in-memory pages to use for the main database
-** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
-*/
-#ifndef SQLITE_DEFAULT_CACHE_SIZE
-# define SQLITE_DEFAULT_CACHE_SIZE 2000
-#endif
-#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
-# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
-#endif
-
-/*
-** The default number of frames to accumulate in the log file before
-** checkpointing the database in WAL mode.
-*/
-#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
-# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
-#endif
-
-/*
-** The maximum number of attached databases. This must be between 0
-** and 62. The upper bound on 62 is because a 64-bit integer bitmap
-** is used internally to track attached databases.
-*/
-#ifndef SQLITE_MAX_ATTACHED
-# define SQLITE_MAX_ATTACHED 10
-#endif
-
-
-/*
-** The maximum value of a ?nnn wildcard that the parser will accept.
-*/
-#ifndef SQLITE_MAX_VARIABLE_NUMBER
-# define SQLITE_MAX_VARIABLE_NUMBER 999
-#endif
-
-/* Maximum page size. The upper bound on this value is 65536. This a limit
-** imposed by the use of 16-bit offsets within each page.
-**
-** Earlier versions of SQLite allowed the user to change this value at
-** compile time. This is no longer permitted, on the grounds that it creates
-** a library that is technically incompatible with an SQLite library
-** compiled with a different limit. If a process operating on a database
-** with a page-size of 65536 bytes crashes, then an instance of SQLite
-** compiled with the default page-size limit will not be able to rollback
-** the aborted transaction. This could lead to database corruption.
-*/
-#ifdef SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_MAX_PAGE_SIZE
-#endif
-#define SQLITE_MAX_PAGE_SIZE 65536
-
-
-/*
-** The default size of a database page.
-*/
-#ifndef SQLITE_DEFAULT_PAGE_SIZE
-# define SQLITE_DEFAULT_PAGE_SIZE 1024
-#endif
-#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_DEFAULT_PAGE_SIZE
-# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
-#endif
-
-/*
-** Ordinarily, if no value is explicitly provided, SQLite creates databases
-** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
-** device characteristics (sector-size and atomic write() support),
-** SQLite may choose a larger value. This constant is the maximum value
-** SQLite will choose on its own.
-*/
-#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
-# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
-#endif
-#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
-# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
-#endif
-
-
-/*
-** Maximum number of pages in one database file.
-**
-** This is really just the default value for the max_page_count pragma.
-** This value can be lowered (or raised) at run-time using that the
-** max_page_count macro.
-*/
-#ifndef SQLITE_MAX_PAGE_COUNT
-# define SQLITE_MAX_PAGE_COUNT 1073741823
-#endif
-
-/*
-** Maximum length (in bytes) of the pattern in a LIKE or GLOB
-** operator.
-*/
-#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
-# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
-#endif
-
-/*
-** Maximum depth of recursion for triggers.
-**
-** A value of 1 means that a trigger program will not be able to itself
-** fire any triggers. A value of 0 means that no trigger programs at all
-** may be executed.
-*/
-#ifndef SQLITE_MAX_TRIGGER_DEPTH
-# define SQLITE_MAX_TRIGGER_DEPTH 1000
-#endif
-
-/************** End of sqliteLimit.h *****************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
-
-/* Disable nuisance warnings on Borland compilers */
-#if defined(__BORLANDC__)
-#pragma warn -rch /* unreachable code */
-#pragma warn -ccc /* Condition is always true or false */
-#pragma warn -aus /* Assigned value is never used */
-#pragma warn -csu /* Comparing signed and unsigned */
-#pragma warn -spa /* Suspicious pointer arithmetic */
-#endif
-
-/* Needed for various definitions... */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
-# define _BSD_SOURCE
-#endif
-
-/*
-** Include standard header files as necessary
-*/
-#ifdef HAVE_STDINT_H
-#include
-#endif
-#ifdef HAVE_INTTYPES_H
-#include
-#endif
-
-/*
-** The following macros are used to cast pointers to integers and
-** integers to pointers. The way you do this varies from one compiler
-** to the next, so we have developed the following set of #if statements
-** to generate appropriate macros for a wide range of compilers.
-**
-** The correct "ANSI" way to do this is to use the intptr_t type.
-** Unfortunately, that typedef is not available on all compilers, or
-** if it is available, it requires an #include of specific headers
-** that vary from one machine to the next.
-**
-** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
-** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
-** So we have to define the macros in different ways depending on the
-** compiler.
-*/
-#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
-# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
-#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
-# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
-# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
-#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
-# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
-#else /* Generates a warning - but it always works */
-# define SQLITE_INT_TO_PTR(X) ((void*)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(X))
-#endif
-
-/*
-** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
-** 0 means mutexes are permanently disable and the library is never
-** threadsafe. 1 means the library is serialized which is the highest
-** level of threadsafety. 2 means the library is multithreaded - multiple
-** threads can use SQLite as long as no two threads try to use the same
-** database connection at the same time.
-**
-** Older versions of SQLite used an optional THREADSAFE macro.
-** We support that for legacy.
-*/
-#if !defined(SQLITE_THREADSAFE)
-# if defined(THREADSAFE)
-# define SQLITE_THREADSAFE THREADSAFE
-# else
-# define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */
-# endif
-#endif
-
-/*
-** Powersafe overwrite is on by default. But can be turned off using
-** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
-*/
-#ifndef SQLITE_POWERSAFE_OVERWRITE
-# define SQLITE_POWERSAFE_OVERWRITE 1
-#endif
-
-/*
-** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
-** It determines whether or not the features related to
-** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
-** be overridden at runtime using the sqlite3_config() API.
-*/
-#if !defined(SQLITE_DEFAULT_MEMSTATUS)
-# define SQLITE_DEFAULT_MEMSTATUS 1
-#endif
-
-/*
-** Exactly one of the following macros must be defined in order to
-** specify which memory allocation subsystem to use.
-**
-** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
-** SQLITE_WIN32_MALLOC // Use Win32 native heap API
-** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails
-** SQLITE_MEMDEBUG // Debugging version of system malloc()
-**
-** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
-** assert() macro is enabled, each call into the Win32 native heap subsystem
-** will cause HeapValidate to be called. If heap validation should fail, an
-** assertion will be triggered.
-**
-** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
-** the default.
-*/
-#if defined(SQLITE_SYSTEM_MALLOC) \
- + defined(SQLITE_WIN32_MALLOC) \
- + defined(SQLITE_ZERO_MALLOC) \
- + defined(SQLITE_MEMDEBUG)>1
-# error "Two or more of the following compile-time configuration options\
- are defined but at most one is allowed:\
- SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\
- SQLITE_ZERO_MALLOC"
-#endif
-#if defined(SQLITE_SYSTEM_MALLOC) \
- + defined(SQLITE_WIN32_MALLOC) \
- + defined(SQLITE_ZERO_MALLOC) \
- + defined(SQLITE_MEMDEBUG)==0
-# define SQLITE_SYSTEM_MALLOC 1
-#endif
-
-/*
-** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
-** sizes of memory allocations below this value where possible.
-*/
-#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
-# define SQLITE_MALLOC_SOFT_LIMIT 1024
-#endif
-
-/*
-** We need to define _XOPEN_SOURCE as follows in order to enable
-** recursive mutexes on most Unix systems and fchmod() on OpenBSD.
-** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit
-** it.
-*/
-#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
-# define _XOPEN_SOURCE 600
-#endif
-
-/*
-** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
-** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
-** make it true by defining or undefining NDEBUG.
-**
-** Setting NDEBUG makes the code smaller and faster by disabling the
-** assert() statements in the code. So we want the default action
-** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
-** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
-** feature.
-*/
-#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
-# define NDEBUG 1
-#endif
-#if defined(NDEBUG) && defined(SQLITE_DEBUG)
-# undef NDEBUG
-#endif
-
-/*
-** The testcase() macro is used to aid in coverage testing. When
-** doing coverage testing, the condition inside the argument to
-** testcase() must be evaluated both true and false in order to
-** get full branch coverage. The testcase() macro is inserted
-** to help ensure adequate test coverage in places where simple
-** condition/decision coverage is inadequate. For example, testcase()
-** can be used to make sure boundary values are tested. For
-** bitmask tests, testcase() can be used to make sure each bit
-** is significant and used at least once. On switch statements
-** where multiple cases go to the same block of code, testcase()
-** can insure that all cases are evaluated.
-**
-*/
-#ifdef SQLITE_COVERAGE_TEST
-SQLITE_PRIVATE void sqlite3Coverage(int);
-# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
-#else
-# define testcase(X)
-#endif
-
-/*
-** The TESTONLY macro is used to enclose variable declarations or
-** other bits of code that are needed to support the arguments
-** within testcase() and assert() macros.
-*/
-#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
-# define TESTONLY(X) X
-#else
-# define TESTONLY(X)
-#endif
-
-/*
-** Sometimes we need a small amount of code such as a variable initialization
-** to setup for a later assert() statement. We do not want this code to
-** appear when assert() is disabled. The following macro is therefore
-** used to contain that setup code. The "VVA" acronym stands for
-** "Verification, Validation, and Accreditation". In other words, the
-** code within VVA_ONLY() will only run during verification processes.
-*/
-#ifndef NDEBUG
-# define VVA_ONLY(X) X
-#else
-# define VVA_ONLY(X)
-#endif
-
-/*
-** The ALWAYS and NEVER macros surround boolean expressions which
-** are intended to always be true or false, respectively. Such
-** expressions could be omitted from the code completely. But they
-** are included in a few cases in order to enhance the resilience
-** of SQLite to unexpected behavior - to make the code "self-healing"
-** or "ductile" rather than being "brittle" and crashing at the first
-** hint of unplanned behavior.
-**
-** In other words, ALWAYS and NEVER are added for defensive code.
-**
-** When doing coverage testing ALWAYS and NEVER are hard-coded to
-** be true and false so that the unreachable code they specify will
-** not be counted as untested code.
-*/
-#if defined(SQLITE_COVERAGE_TEST)
-# define ALWAYS(X) (1)
-# define NEVER(X) (0)
-#elif !defined(NDEBUG)
-# define ALWAYS(X) ((X)?1:(assert(0),0))
-# define NEVER(X) ((X)?(assert(0),1):0)
-#else
-# define ALWAYS(X) (X)
-# define NEVER(X) (X)
-#endif
-
-/*
-** Return true (non-zero) if the input is a integer that is too large
-** to fit in 32-bits. This macro is used inside of various testcase()
-** macros to verify that we have tested SQLite for large-file support.
-*/
-#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
-
-/*
-** The macro unlikely() is a hint that surrounds a boolean
-** expression that is usually false. Macro likely() surrounds
-** a boolean expression that is usually true. These hints could,
-** in theory, be used by the compiler to generate better code, but
-** currently they are just comments for human readers.
-*/
-#define likely(X) (X)
-#define unlikely(X) (X)
-
/************** Include hash.h in the middle of sqliteInt.h ******************/
/************** Begin file hash.h ********************************************/
/*
** 2001 September 22
**
@@ -8270,35 +8272,10 @@
typedef u64 tRowcnt; /* 64-bit only if requested at compile-time */
#else
typedef u32 tRowcnt; /* 32-bit is the default */
#endif
-/*
-** Estimated quantities used for query planning are stored as 16-bit
-** logarithms. For quantity X, the value stored is 10*log2(X). This
-** gives a possible range of values of approximately 1.0e986 to 1e-986.
-** But the allowed values are "grainy". Not every value is representable.
-** For example, quantities 16 and 17 are both represented by a LogEst
-** of 40. However, since LogEst quantatites are suppose to be estimates,
-** not exact values, this imprecision is not a problem.
-**
-** "LogEst" is short for "Logarithimic Estimate".
-**
-** Examples:
-** 1 -> 0 20 -> 43 10000 -> 132
-** 2 -> 10 25 -> 46 25000 -> 146
-** 3 -> 16 100 -> 66 1000000 -> 199
-** 4 -> 20 1000 -> 99 1048576 -> 200
-** 10 -> 33 1024 -> 100 4294967296 -> 320
-**
-** The LogEst can be negative to indicate fractional values.
-** Examples:
-**
-** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
-*/
-typedef INT16_TYPE LogEst;
-
/*
** Macros to determine whether the machine is big or little endian,
** evaluated at runtime.
*/
#ifdef SQLITE_AMALGAMATION
@@ -10275,11 +10252,10 @@
#define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
#define SQLITE_Stat3 0x0800 /* Use the SQLITE_STAT3 table */
-#define SQLITE_AdjustOutEst 0x1000 /* Adjust output estimates using WHERE */
#define SQLITE_AllOpts 0xffff /* All optimizations */
/*
** Macros for testing whether or not optimizations are enabled or disabled.
*/
@@ -10442,12 +10418,11 @@
char *zDflt; /* Original text of the default value */
char *zType; /* Data type for this column */
char *zColl; /* Collating sequence. If NULL, use the default */
u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
char affinity; /* One of the SQLITE_AFF_... values */
- u8 szEst; /* Estimated size of this column. INT==1 */
- u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
+ u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
};
/* Allowed values for Column.colFlags:
*/
#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */
@@ -10607,11 +10582,10 @@
tRowcnt nRowEst; /* Estimated rows in table - from sqlite_stat1 table */
int tnum; /* Root BTree node for this table (see note above) */
i16 iPKey; /* If not negative, use aCol[iPKey] as the primary key */
i16 nCol; /* Number of columns in this table */
u16 nRef; /* Number of pointers to this Table */
- LogEst szTabRow; /* Estimated size of each table row in bytes */
u8 tabFlags; /* Mask of TF_* values */
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
#ifndef SQLITE_OMIT_ALTERTABLE
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
#endif
@@ -10719,11 +10693,11 @@
#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
#define OE_SetNull 7 /* Set the foreign key value to NULL */
#define OE_SetDflt 8 /* Set the foreign key value to its default */
#define OE_Cascade 9 /* Cascade the changes */
-#define OE_Default 10 /* Do whatever the default action is */
+#define OE_Default 99 /* Do whatever the default action is */
/*
** An instance of the following structure is passed as the first
** argument to sqlite3VdbeKeyCompare and is used to control the
@@ -10806,11 +10780,10 @@
Schema *pSchema; /* Schema containing this index */
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
char **azColl; /* Array of collation sequence names for index */
Expr *pPartIdxWhere; /* WHERE clause for partial indices */
int tnum; /* DB Page containing root of this index */
- LogEst szIdxRow; /* Estimated average row size in bytes */
u16 nColumn; /* Number of columns in table used by this index */
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
unsigned bUnordered:1; /* Use this index for == or IN queries only */
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
@@ -10971,11 +10944,11 @@
** allocated, regardless of whether or not EP_Reduced is set.
*/
struct Expr {
u8 op; /* Operation performed by this node */
char affinity; /* The affinity of the column or 0 if not a column */
- u32 flags; /* Various flags. EP_* See below */
+ u16 flags; /* Various flags. EP_* See below */
union {
char *zToken; /* Token value. Zero terminated and dequoted */
int iValue; /* Non-negative integer value if EP_IntValue */
} u;
@@ -10985,12 +10958,12 @@
*********************************************************************/
Expr *pLeft; /* Left subnode */
Expr *pRight; /* Right subnode */
union {
- ExprList *pList; /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */
- Select *pSelect; /* EP_xIsSelect and op = IN, EXISTS, SELECT */
+ ExprList *pList; /* Function arguments or in " IN ( IN ()" */
} x;
/* If the EP_Reduced flag is set in the Expr.flags mask, then no
** space is allocated for the fields below this point. An attempt to
** access them will result in a segfault or malfunction.
@@ -10999,16 +10972,16 @@
#if SQLITE_MAX_EXPR_DEPTH>0
int nHeight; /* Height of the tree headed by this node */
#endif
int iTable; /* TK_COLUMN: cursor number of table holding column
** TK_REGISTER: register number
- ** TK_TRIGGER: 1 -> new, 0 -> old
- ** EP_Unlikely: 1000 times likelihood */
+ ** TK_TRIGGER: 1 -> new, 0 -> old */
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
** TK_VARIABLE: variable number (always >= 1). */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ u8 flags2; /* Second set of flags. EP2_... */
u8 op2; /* TK_REGISTER: original value of Expr.op
** TK_COLUMN: the value of p5 for OP_Column
** TK_AGG_FUNCTION: nesting depth */
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
Table *pTab; /* Table for TK_COLUMN expressions. */
@@ -11015,49 +10988,54 @@
};
/*
** The following are the meanings of bits in the Expr.flags field.
*/
-#define EP_FromJoin 0x000001 /* Originated in ON or USING clause of a join */
-#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
-#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
-#define EP_Error 0x000008 /* Expression contains one or more errors */
-#define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
-#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
-#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
-#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
-#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE opeartor */
-#define EP_FixedDest 0x000200 /* Result needed in a specific register */
-#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
-#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
-#define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */
-#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
-#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
-#define EP_Static 0x008000 /* Held in memory not obtained from malloc() */
-#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
-#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
-#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
+#define EP_FromJoin 0x0001 /* Originated in ON or USING clause of a join */
+#define EP_Agg 0x0002 /* Contains one or more aggregate functions */
+#define EP_Resolved 0x0004 /* IDs have been resolved to COLUMNs */
+#define EP_Error 0x0008 /* Expression contains one or more errors */
+#define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */
+#define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */
+#define EP_DblQuoted 0x0040 /* token.z was originally in "..." */
+#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
+#define EP_Collate 0x0100 /* Tree contains a TK_COLLATE opeartor */
+#define EP_FixedDest 0x0200 /* Result needed in a specific register */
+#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
+#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
+#define EP_Hint 0x1000 /* Not used */
+#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
+#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
+#define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
+
+/*
+** The following are the meanings of bits in the Expr.flags2 field.
+*/
+#define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */
+#define EP2_Irreducible 0x0002 /* Cannot EXPRDUP_REDUCE this Expr */
+
+/*
+** The pseudo-routine sqlite3ExprSetIrreducible sets the EP2_Irreducible
+** flag on an expression structure. This flag is used for VV&A only. The
+** routine is implemented as a macro that only works when in debugging mode,
+** so as not to burden production code.
+*/
+#ifdef SQLITE_DEBUG
+# define ExprSetIrreducible(X) (X)->flags2 |= EP2_Irreducible
+#else
+# define ExprSetIrreducible(X)
+#endif
/*
** These macros can be used to test, set, or clear bits in the
** Expr.flags field.
*/
-#define ExprHasProperty(E,P) (((E)->flags&(P))!=0)
-#define ExprHasAllProperty(E,P) (((E)->flags&(P))==(P))
+#define ExprHasProperty(E,P) (((E)->flags&(P))==(P))
+#define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0)
#define ExprSetProperty(E,P) (E)->flags|=(P)
#define ExprClearProperty(E,P) (E)->flags&=~(P)
-/* The ExprSetVVAProperty() macro is used for Verification, Validation,
-** and Accreditation only. It works like ExprSetProperty() during VVA
-** processes but is a no-op for delivery.
-*/
-#ifdef SQLITE_DEBUG
-# define ExprSetVVAProperty(E,P) (E)->flags|=(P)
-#else
-# define ExprSetVVAProperty(E,P)
-#endif
-
/*
** Macros to determine the number of bytes required by a normal Expr
** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
** and an Expr struct with the EP_TokenOnly flag set.
*/
@@ -11662,11 +11640,10 @@
*/
typedef struct DbFixer DbFixer;
struct DbFixer {
Parse *pParse; /* The parsing context. Error messages written here */
Schema *pSchema; /* Fix items to this schema */
- int bVarOnly; /* Check for variable references only */
const char *zDb; /* Make sure all objects are contained in this database */
const char *zType; /* Type of the container - used for error messages */
const Token *pName; /* Name of the container - used for error messages */
};
@@ -12201,11 +12178,11 @@
# define sqlite3AuthContextPush(a,b,c)
# define sqlite3AuthContextPop(a) ((void)(a))
#endif
SQLITE_PRIVATE void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);
SQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);
-SQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
+SQLITE_PRIVATE int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
@@ -12213,16 +12190,10 @@
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
SQLITE_PRIVATE int sqlite3Atoi(const char*);
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);
-SQLITE_PRIVATE LogEst sqlite3LogEst(u64);
-SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
-#endif
-SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
/*
** Routines to read and write variable-length integers. These used to
** be defined locally, but now we use the varint routines in the util.c
** file. Code should use the MACRO forms below, as the Varint32 versions
@@ -12335,11 +12306,11 @@
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
-SQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);
+SQLITE_PRIVATE char sqlite3AffinityType(const char*);
SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*);
SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
@@ -12439,11 +12410,10 @@
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
SQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
-SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
@@ -12468,14 +12438,14 @@
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
#else
#define sqlite3FkActions(a,b,c,d,e,f)
- #define sqlite3FkCheck(a,b,c,d,e,f)
+ #define sqlite3FkCheck(a,b,c,d)
#define sqlite3FkDropTable(a,b,c)
- #define sqlite3FkOldmask(a,b) 0
- #define sqlite3FkRequired(a,b,c,d) 0
+ #define sqlite3FkOldmask(a,b) 0
+ #define sqlite3FkRequired(a,b,c,d,e,f) 0
#endif
#ifndef SQLITE_OMIT_FOREIGN_KEY
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
#else
@@ -13618,11 +13588,10 @@
int iStatement; /* Statement number (or 0 if has not opened stmt) */
u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
#ifndef SQLITE_OMIT_TRACE
i64 startTime; /* Time when query started - used for profiling */
#endif
- i64 iCurrentTime; /* Value of julianday('now') for this statement */
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
char *zSql; /* Text of the SQL statement that generated this */
void *pFree; /* Free this when deleting the vdbe */
@@ -14298,12 +14267,12 @@
** Set the time to the current time reported by the VFS.
**
** Return the number of errors.
*/
static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
- p->iJD = sqlite3StmtCurrentTime(context);
- if( p->iJD>0 ){
+ sqlite3 *db = sqlite3_context_db_handle(context);
+ if( sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD)==SQLITE_OK ){
p->validJD = 1;
return 0;
}else{
return 1;
}
@@ -14430,14 +14399,10 @@
** is available. This routine returns 0 on success and
** non-zero on any kind of error.
**
** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
** routine will always fail.
-**
-** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
-** library function localtime_r() is used to assist in the calculation of
-** local time.
*/
static int osLocaltime(time_t *t, struct tm *pTm){
int rc;
#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
&& (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14490,15 +14455,10 @@
memset(&sLocal, 0, sizeof(sLocal));
x = *p;
computeYMD_HMS(&x);
if( x.Y<1971 || x.Y>=2038 ){
- /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
- ** works for years between 1970 and 2037. For dates outside this range,
- ** SQLite attempts to map the year into an equivalent year within this
- ** range, do the calculation, then map the year back.
- */
x.Y = 2000;
x.M = 1;
x.D = 1;
x.h = 0;
x.m = 0;
@@ -15091,12 +15051,12 @@
char zBuf[20];
UNUSED_PARAMETER(argc);
UNUSED_PARAMETER(argv);
- iT = sqlite3StmtCurrentTime(context);
- if( iT<=0 ) return;
+ db = sqlite3_context_db_handle(context);
+ if( sqlite3OsCurrentTimeInt64(db->pVfs, &iT) ) return;
t = iT/1000 - 10000*(sqlite3_int64)21086676;
#ifdef HAVE_GMTIME_R
pTm = gmtime_r(&t, &sNow);
#else
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
@@ -19298,11 +19258,10 @@
** Free memory that might be associated with a particular database
** connection.
*/
SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){
assert( db==0 || sqlite3_mutex_held(db->mutex) );
- if( p==0 ) return;
if( db ){
if( db->pnBytesFreed ){
*db->pnBytesFreed += sqlite3DbMallocSize(db, p);
return;
}
@@ -21414,12 +21373,11 @@
case '"': break;
case '`': break; /* For MySQL compatibility */
case '[': quote = ']'; break; /* For MS SqlServer compatibility */
default: return -1;
}
- for(i=1, j=0;; i++){
- assert( z[i] );
+ for(i=1, j=0; ALWAYS(z[i]); i++){
if( z[i]==quote ){
if( z[i+1]==quote ){
z[j++] = quote;
i++;
}else{
@@ -22430,87 +22388,10 @@
if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
}
}
#endif
-/*
-** Find (an approximate) sum of two LogEst values. This computation is
-** not a simple "+" operator because LogEst is stored as a logarithmic
-** value.
-**
-*/
-SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst a, LogEst b){
- static const unsigned char x[] = {
- 10, 10, /* 0,1 */
- 9, 9, /* 2,3 */
- 8, 8, /* 4,5 */
- 7, 7, 7, /* 6,7,8 */
- 6, 6, 6, /* 9,10,11 */
- 5, 5, 5, /* 12-14 */
- 4, 4, 4, 4, /* 15-18 */
- 3, 3, 3, 3, 3, 3, /* 19-24 */
- 2, 2, 2, 2, 2, 2, 2, /* 25-31 */
- };
- if( a>=b ){
- if( a>b+49 ) return a;
- if( a>b+31 ) return a+1;
- return a+x[a-b];
- }else{
- if( b>a+49 ) return b;
- if( b>a+31 ) return b+1;
- return b+x[b-a];
- }
-}
-
-/*
-** Convert an integer into a LogEst. In other words, compute a
-** good approximatation for 10*log2(x).
-*/
-SQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){
- static LogEst a[] = { 0, 2, 3, 5, 6, 7, 8, 9 };
- LogEst y = 40;
- if( x<8 ){
- if( x<2 ) return 0;
- while( x<8 ){ y -= 10; x <<= 1; }
- }else{
- while( x>255 ){ y += 40; x >>= 4; }
- while( x>15 ){ y += 10; x >>= 1; }
- }
- return a[x&7] + y - 10;
-}
-
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-/*
-** Convert a double into a LogEst
-** In other words, compute an approximation for 10*log2(x).
-*/
-SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){
- u64 a;
- LogEst e;
- assert( sizeof(x)==8 && sizeof(a)==8 );
- if( x<=1 ) return 0;
- if( x<=2000000000 ) return sqlite3LogEst((u64)x);
- memcpy(&a, &x, 8);
- e = (a>>52) - 1022;
- return e*10;
-}
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-
-/*
-** Convert a LogEst into an integer.
-*/
-SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
- u64 n;
- if( x<10 ) return 1;
- n = x%10;
- x /= 10;
- if( n>=5 ) n -= 2;
- else if( n>=1 ) n -= 1;
- if( x>=3 ) return (n+8)<<(x-3);
- return (n+8)>>(3-x);
-}
-
/************** End of util.c ************************************************/
/************** Begin file hash.c ********************************************/
/*
** 2001 September 22
**
@@ -31501,98 +31382,89 @@
#endif
#define osGetVersionExA ((BOOL(WINAPI*)( \
LPOSVERSIONINFOA))aSyscall[34].pCurrent)
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
- { "GetVersionExW", (SYSCALL)GetVersionExW, 0 },
-#else
- { "GetVersionExW", (SYSCALL)0, 0 },
-#endif
-
-#define osGetVersionExW ((BOOL(WINAPI*)( \
- LPOSVERSIONINFOW))aSyscall[35].pCurrent)
-
{ "HeapAlloc", (SYSCALL)HeapAlloc, 0 },
#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \
- SIZE_T))aSyscall[36].pCurrent)
+ SIZE_T))aSyscall[35].pCurrent)
#if !SQLITE_OS_WINRT
{ "HeapCreate", (SYSCALL)HeapCreate, 0 },
#else
{ "HeapCreate", (SYSCALL)0, 0 },
#endif
#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \
- SIZE_T))aSyscall[37].pCurrent)
+ SIZE_T))aSyscall[36].pCurrent)
#if !SQLITE_OS_WINRT
{ "HeapDestroy", (SYSCALL)HeapDestroy, 0 },
#else
{ "HeapDestroy", (SYSCALL)0, 0 },
#endif
-#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)
+#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[37].pCurrent)
{ "HeapFree", (SYSCALL)HeapFree, 0 },
-#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[39].pCurrent)
+#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[38].pCurrent)
{ "HeapReAlloc", (SYSCALL)HeapReAlloc, 0 },
#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \
- SIZE_T))aSyscall[40].pCurrent)
+ SIZE_T))aSyscall[39].pCurrent)
{ "HeapSize", (SYSCALL)HeapSize, 0 },
#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \
- LPCVOID))aSyscall[41].pCurrent)
+ LPCVOID))aSyscall[40].pCurrent)
#if !SQLITE_OS_WINRT
{ "HeapValidate", (SYSCALL)HeapValidate, 0 },
#else
{ "HeapValidate", (SYSCALL)0, 0 },
#endif
#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \
- LPCVOID))aSyscall[42].pCurrent)
+ LPCVOID))aSyscall[41].pCurrent)
#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
{ "LoadLibraryA", (SYSCALL)LoadLibraryA, 0 },
#else
{ "LoadLibraryA", (SYSCALL)0, 0 },
#endif
-#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[43].pCurrent)
+#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[42].pCurrent)
#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
!defined(SQLITE_OMIT_LOAD_EXTENSION)
{ "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 },
#else
{ "LoadLibraryW", (SYSCALL)0, 0 },
#endif
-#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[44].pCurrent)
+#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[43].pCurrent)
#if !SQLITE_OS_WINRT
{ "LocalFree", (SYSCALL)LocalFree, 0 },
#else
{ "LocalFree", (SYSCALL)0, 0 },
#endif
-#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[45].pCurrent)
+#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[44].pCurrent)
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
{ "LockFile", (SYSCALL)LockFile, 0 },
#else
{ "LockFile", (SYSCALL)0, 0 },
#endif
#ifndef osLockFile
#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \
- DWORD))aSyscall[46].pCurrent)
+ DWORD))aSyscall[45].pCurrent)
#endif
#if !SQLITE_OS_WINCE
{ "LockFileEx", (SYSCALL)LockFileEx, 0 },
#else
@@ -31599,218 +31471,218 @@
{ "LockFileEx", (SYSCALL)0, 0 },
#endif
#ifndef osLockFileEx
#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \
- LPOVERLAPPED))aSyscall[47].pCurrent)
+ LPOVERLAPPED))aSyscall[46].pCurrent)
#endif
#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL))
{ "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 },
#else
{ "MapViewOfFile", (SYSCALL)0, 0 },
#endif
#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \
- SIZE_T))aSyscall[48].pCurrent)
+ SIZE_T))aSyscall[47].pCurrent)
{ "MultiByteToWideChar", (SYSCALL)MultiByteToWideChar, 0 },
#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \
- int))aSyscall[49].pCurrent)
+ int))aSyscall[48].pCurrent)
{ "QueryPerformanceCounter", (SYSCALL)QueryPerformanceCounter, 0 },
#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \
- LARGE_INTEGER*))aSyscall[50].pCurrent)
+ LARGE_INTEGER*))aSyscall[49].pCurrent)
{ "ReadFile", (SYSCALL)ReadFile, 0 },
#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \
- LPOVERLAPPED))aSyscall[51].pCurrent)
+ LPOVERLAPPED))aSyscall[50].pCurrent)
{ "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 },
-#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[52].pCurrent)
+#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent)
#if !SQLITE_OS_WINRT
{ "SetFilePointer", (SYSCALL)SetFilePointer, 0 },
#else
{ "SetFilePointer", (SYSCALL)0, 0 },
#endif
#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
- DWORD))aSyscall[53].pCurrent)
+ DWORD))aSyscall[52].pCurrent)
#if !SQLITE_OS_WINRT
{ "Sleep", (SYSCALL)Sleep, 0 },
#else
{ "Sleep", (SYSCALL)0, 0 },
#endif
-#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[54].pCurrent)
+#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent)
{ "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 },
#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \
- LPFILETIME))aSyscall[55].pCurrent)
+ LPFILETIME))aSyscall[54].pCurrent)
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
{ "UnlockFile", (SYSCALL)UnlockFile, 0 },
#else
{ "UnlockFile", (SYSCALL)0, 0 },
#endif
#ifndef osUnlockFile
#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \
- DWORD))aSyscall[56].pCurrent)
+ DWORD))aSyscall[55].pCurrent)
#endif
#if !SQLITE_OS_WINCE
{ "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 },
#else
{ "UnlockFileEx", (SYSCALL)0, 0 },
#endif
#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \
- LPOVERLAPPED))aSyscall[57].pCurrent)
+ LPOVERLAPPED))aSyscall[56].pCurrent)
#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL)
{ "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 },
#else
{ "UnmapViewOfFile", (SYSCALL)0, 0 },
#endif
-#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[58].pCurrent)
+#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[57].pCurrent)
{ "WideCharToMultiByte", (SYSCALL)WideCharToMultiByte, 0 },
#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \
- LPCSTR,LPBOOL))aSyscall[59].pCurrent)
+ LPCSTR,LPBOOL))aSyscall[58].pCurrent)
{ "WriteFile", (SYSCALL)WriteFile, 0 },
#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \
- LPOVERLAPPED))aSyscall[60].pCurrent)
+ LPOVERLAPPED))aSyscall[59].pCurrent)
#if SQLITE_OS_WINRT
{ "CreateEventExW", (SYSCALL)CreateEventExW, 0 },
#else
{ "CreateEventExW", (SYSCALL)0, 0 },
#endif
#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \
- DWORD,DWORD))aSyscall[61].pCurrent)
+ DWORD,DWORD))aSyscall[60].pCurrent)
#if !SQLITE_OS_WINRT
{ "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 },
#else
{ "WaitForSingleObject", (SYSCALL)0, 0 },
#endif
#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \
- DWORD))aSyscall[62].pCurrent)
+ DWORD))aSyscall[61].pCurrent)
#if SQLITE_OS_WINRT
{ "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 },
#else
{ "WaitForSingleObjectEx", (SYSCALL)0, 0 },
#endif
#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \
- BOOL))aSyscall[63].pCurrent)
+ BOOL))aSyscall[62].pCurrent)
#if SQLITE_OS_WINRT
{ "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 },
#else
{ "SetFilePointerEx", (SYSCALL)0, 0 },
#endif
#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
- PLARGE_INTEGER,DWORD))aSyscall[64].pCurrent)
+ PLARGE_INTEGER,DWORD))aSyscall[63].pCurrent)
#if SQLITE_OS_WINRT
{ "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
#else
{ "GetFileInformationByHandleEx", (SYSCALL)0, 0 },
#endif
#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
- FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[65].pCurrent)
+ FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[64].pCurrent)
#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)
{ "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
#else
{ "MapViewOfFileFromApp", (SYSCALL)0, 0 },
#endif
#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \
- SIZE_T))aSyscall[66].pCurrent)
+ SIZE_T))aSyscall[65].pCurrent)
#if SQLITE_OS_WINRT
{ "CreateFile2", (SYSCALL)CreateFile2, 0 },
#else
{ "CreateFile2", (SYSCALL)0, 0 },
#endif
#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \
- LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[67].pCurrent)
+ LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent)
#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)
{ "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 },
#else
{ "LoadPackagedLibrary", (SYSCALL)0, 0 },
#endif
#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \
- DWORD))aSyscall[68].pCurrent)
+ DWORD))aSyscall[67].pCurrent)
#if SQLITE_OS_WINRT
{ "GetTickCount64", (SYSCALL)GetTickCount64, 0 },
#else
{ "GetTickCount64", (SYSCALL)0, 0 },
#endif
-#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[69].pCurrent)
+#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[68].pCurrent)
#if SQLITE_OS_WINRT
{ "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 },
#else
{ "GetNativeSystemInfo", (SYSCALL)0, 0 },
#endif
#define osGetNativeSystemInfo ((VOID(WINAPI*)( \
- LPSYSTEM_INFO))aSyscall[70].pCurrent)
+ LPSYSTEM_INFO))aSyscall[69].pCurrent)
#if defined(SQLITE_WIN32_HAS_ANSI)
{ "OutputDebugStringA", (SYSCALL)OutputDebugStringA, 0 },
#else
{ "OutputDebugStringA", (SYSCALL)0, 0 },
#endif
-#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[71].pCurrent)
+#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[70].pCurrent)
#if defined(SQLITE_WIN32_HAS_WIDE)
{ "OutputDebugStringW", (SYSCALL)OutputDebugStringW, 0 },
#else
{ "OutputDebugStringW", (SYSCALL)0, 0 },
#endif
-#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[72].pCurrent)
+#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[71].pCurrent)
{ "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 },
-#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[73].pCurrent)
+#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[72].pCurrent)
#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)
{ "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 },
#else
{ "CreateFileMappingFromApp", (SYSCALL)0, 0 },
#endif
#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \
- LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[74].pCurrent)
+ LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[73].pCurrent)
}; /* End of the overrideable system calls */
/*
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
@@ -31962,30 +31834,20 @@
** API as long as we don't call it when running Win95/98/ME. A call to
** this routine is used to determine if the host is Win95/98/ME or
** WinNT/2K/XP so that we will know whether or not we can safely call
** the LockFileEx() API.
*/
-#ifndef NTDDI_WIN8
-# define NTDDI_WIN8 0x06020000
-#endif
-
#if SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
# define osIsNT() (1)
#elif !defined(SQLITE_WIN32_HAS_WIDE)
# define osIsNT() (0)
#else
static int osIsNT(void){
if( sqlite3_os_type==0 ){
-#if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8
- OSVERSIONINFOW sInfo;
- sInfo.dwOSVersionInfoSize = sizeof(sInfo);
- osGetVersionExW(&sInfo);
-#else
OSVERSIONINFOA sInfo;
sInfo.dwOSVersionInfoSize = sizeof(sInfo);
osGetVersionExA(&sInfo);
-#endif
sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;
}
return sqlite3_os_type==2;
}
#endif
@@ -33015,11 +32877,12 @@
#endif
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
OSTRACE(("CLOSE file=%p\n", pFile->h));
#if SQLITE_MAX_MMAP_SIZE>0
- winUnmapfile(pFile);
+ rc = winUnmapfile(pFile);
+ if( rc!=SQLITE_OK ) return rc;
#endif
do{
rc = osCloseHandle(pFile->h);
/* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
@@ -33821,11 +33684,11 @@
}
*(i64*)pArg = pFile->mmapSizeMax;
if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
pFile->mmapSizeMax = newLimit;
if( pFile->mmapSize>0 ){
- winUnmapfile(pFile);
+ (void)winUnmapfile(pFile);
rc = winMapfile(pFile, -1);
}
}
OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
return rc;
@@ -34038,11 +33901,11 @@
osGetCurrentProcessId(), deleteFlag));
pp = &winShmNodeList;
while( (p = *pp)!=0 ){
if( p->nRef==0 ){
int i;
- if( p->mutex ){ sqlite3_mutex_free(p->mutex); }
+ if( p->mutex ) sqlite3_mutex_free(p->mutex);
for(i=0; inRegion; i++){
BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n",
osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
UNUSED_VARIABLE_VALUE(bRc);
@@ -34891,11 +34754,10 @@
** API prior to using it.
*/
if( winIsDriveLetterAndColon(zDir) ){
zConverted = winConvertFromUtf8Filename(zDir);
if( !zConverted ){
- sqlite3_free(zBuf);
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
return SQLITE_IOERR_NOMEM;
}
if( winIsDir(zConverted) ){
sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
@@ -34904,19 +34766,17 @@
}
sqlite3_free(zConverted);
}else{
zConverted = sqlite3MallocZero( nBuf+1 );
if( !zConverted ){
- sqlite3_free(zBuf);
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
return SQLITE_IOERR_NOMEM;
}
if( cygwin_conv_path(
osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
zConverted, nBuf+1)<0 ){
sqlite3_free(zConverted);
- sqlite3_free(zBuf);
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
"winGetTempname1", zDir);
}
if( winIsDir(zConverted) ){
@@ -34926,11 +34786,10 @@
*/
if( osIsNT() ){
char *zUtf8 = winUnicodeToUtf8(zConverted);
if( !zUtf8 ){
sqlite3_free(zConverted);
- sqlite3_free(zBuf);
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
return SQLITE_IOERR_NOMEM;
}
sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
sqlite3_free(zUtf8);
@@ -34942,10 +34801,11 @@
break;
}
}
sqlite3_free(zConverted);
}
+ break;
}
}
#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
else if( osIsNT() ){
char *zMulti;
@@ -35311,13 +35171,13 @@
pFile->zDeleteOnClose = zConverted;
}else
#endif
{
sqlite3_free(zConverted);
+ sqlite3_free(zTmpname);
}
- sqlite3_free(zTmpname);
pFile->pMethod = &winIoMethod;
pFile->pVfs = pVfs;
pFile->h = h;
if( isReadonly ){
pFile->ctrlFlags |= WINFILE_RDONLY;
@@ -36006,11 +35866,11 @@
};
#endif
/* Double-check that the aSyscall[] array has been constructed
** correctly. See ticket [bb3a86e890c8e96ab] */
- assert( ArraySize(aSyscall)==75 );
+ assert( ArraySize(aSyscall)==74 );
/* get memory map allocation granularity */
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
#if SQLITE_OS_WINRT
osGetNativeSystemInfo(&winSysInfo);
@@ -49107,17 +48967,17 @@
** page contain a special header (the "file header") that describes the file.
** The format of the file header is as follows:
**
** OFFSET SIZE DESCRIPTION
** 0 16 Header string: "SQLite format 3\000"
-** 16 2 Page size in bytes. (1 means 65536)
+** 16 2 Page size in bytes.
** 18 1 File format write version
** 19 1 File format read version
** 20 1 Bytes of unused space at the end of each page
-** 21 1 Max embedded payload fraction (must be 64)
-** 22 1 Min embedded payload fraction (must be 32)
-** 23 1 Min leaf payload fraction (must be 32)
+** 21 1 Max embedded payload fraction
+** 22 1 Min embedded payload fraction
+** 23 1 Min leaf payload fraction
** 24 4 File change counter
** 28 4 Reserved for future use
** 32 4 First freelist page
** 36 4 Number of freelist pages in the file
** 40 60 15 4-byte meta values passed to higher layers
@@ -49127,14 +48987,13 @@
** 48 4 Size of page cache
** 52 4 Largest root-page (auto/incr_vacuum)
** 56 4 1=UTF-8 2=UTF16le 3=UTF16be
** 60 4 User version
** 64 4 Incremental vacuum mode
-** 68 4 Application-ID
-** 72 20 unused
-** 92 4 The version-valid-for number
-** 96 4 SQLITE_VERSION_NUMBER
+** 68 4 unused
+** 72 4 unused
+** 76 4 unused
**
** All of the integer values are big-endian (most significant byte first).
**
** The file change counter is incremented when the database is changed
** This counter allows other processes to know when the file has changed
@@ -52044,22 +51903,10 @@
** MX_CELL_SIZE(pBt) bytes.
*/
static void allocateTempSpace(BtShared *pBt){
if( !pBt->pTmpSpace ){
pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
-
- /* One of the uses of pBt->pTmpSpace is to format cells before
- ** inserting them into a leaf page (function fillInCell()). If
- ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
- ** by the various routines that manipulate binary cells. Which
- ** can mean that fillInCell() only initializes the first 2 or 3
- ** bytes of pTmpSpace, but that the first 4 bytes are copied from
- ** it into a database page. This is not actually a problem, but it
- ** does cause a valgrind error when the 1 or 2 bytes of unitialized
- ** data is passed to system call write(). So to avoid this error,
- ** zero the first 4 bytes of temp space here. */
- if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4);
}
}
/*
** Free the pBt->pTmpSpace allocation
@@ -52512,10 +52359,11 @@
pBt->max1bytePayload = (u8)pBt->maxLocal;
}
assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );
pBt->pPage1 = pPage1;
pBt->nPage = nPage;
+assert( pPage1->leaf==0 || pPage1->leaf==1 );
return SQLITE_OK;
page1_init_failed:
releasePage(pPage1);
pBt->pPage1 = 0;
@@ -52671,11 +52519,11 @@
** is requested, this is a no-op.
*/
if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
goto trans_begun;
}
- assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );
+ assert( IfNotOmitAV(pBt->bDoTruncate)==0 );
/* Write transactions are not possible on a read-only database */
if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
rc = SQLITE_READONLY;
goto trans_begun;
@@ -60322,13 +60170,11 @@
}
pRec->nField = p->iVal+1;
return &pRec->aMem[p->iVal];
}
-#else
- UNUSED_PARAMETER(p);
-#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
+#endif
return sqlite3ValueNew(db);
}
/*
** Extract a value from the supplied expression in the manner described
@@ -60338,11 +60184,11 @@
** If pCtx is NULL and an error occurs after the sqlite3_value object
** has been allocated, it is freed before returning. Or, if pCtx is not
** NULL, it is assumed that the caller will free any allocated object
** in all cases.
*/
-static int valueFromExpr(
+int valueFromExpr(
sqlite3 *db, /* The database connection */
Expr *pExpr, /* The expression to evaluate */
u8 enc, /* Encoding to use */
u8 affinity, /* Affinity to use */
sqlite3_value **ppVal, /* Write the new value here */
@@ -60495,11 +60341,10 @@
int nVal; /* Bytes of space required for argv[0] */
int nRet;
sqlite3 *db;
u8 *aRet;
- UNUSED_PARAMETER( argc );
iSerial = sqlite3VdbeSerialType(argv[0], file_format);
nSerial = sqlite3VarintLen(iSerial);
nVal = sqlite3VdbeSerialTypeLen(iSerial);
db = sqlite3_context_db_handle(context);
@@ -63113,11 +62958,10 @@
}
fclose(out);
}
}
#endif
- p->iCurrentTime = 0;
p->magic = VDBE_MAGIC_INIT;
return p->rc & db->errMask;
}
/*
@@ -64510,11 +64354,10 @@
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
}
-
/*
** Extract the user data from a sqlite3_context structure and return a
** pointer to it.
*/
SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
@@ -64535,23 +64378,10 @@
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
assert( p && p->pFunc );
return p->s.db;
}
-/*
-** Return the current time for a statement
-*/
-SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
- Vdbe *v = p->pVdbe;
- int rc;
- if( v->iCurrentTime==0 ){
- rc = sqlite3OsCurrentTimeInt64(p->s.db->pVfs, &v->iCurrentTime);
- if( rc ) v->iCurrentTime = 0;
- }
- return v->iCurrentTime;
-}
-
/*
** The following is the implementation of an SQL function that always
** fails with an error message stating that the function is used in the
** wrong context. The sqlite3_overload_function() API might construct
** SQL function that use this routine so that the functions will exist
@@ -66700,11 +66530,10 @@
goto no_mem;
}
assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );
assert( p->bIsReader || p->readOnly!=0 );
p->rc = SQLITE_OK;
- p->iCurrentTime = 0;
assert( p->explain==0 );
p->pResultSet = 0;
db->busyHandler.nBusy = 0;
CHECK_FOR_INTERRUPT;
sqlite3VdbeIOTraceSql(p);
@@ -74617,11 +74446,11 @@
if( pExpr==0 ) return WRC_Continue;
testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
testcase( ExprHasProperty(pExpr, EP_Reduced) );
rc = pWalker->xExprCallback(pWalker, pExpr);
if( rc==WRC_Continue
- && !ExprHasProperty(pExpr,EP_TokenOnly) ){
+ && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
}else{
@@ -74836,11 +74665,10 @@
if( pDup==0 ) return;
if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){
incrAggFunctionDepth(pDup, nSubquery);
pDup = sqlite3PExpr(pParse, TK_AS, pDup, 0, 0);
if( pDup==0 ) return;
- ExprSetProperty(pDup, EP_Skip);
if( pEList->a[iCol].iAlias==0 ){
pEList->a[iCol].iAlias = (u16)(++pParse->nAlias);
}
pDup->iTable = pEList->a[iCol].iAlias;
}
@@ -74859,11 +74687,11 @@
sqlite3ExprDelete(db, pExpr);
memcpy(pExpr, pDup, sizeof(*pExpr));
if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
- pExpr->flags |= EP_MemToken;
+ pExpr->flags2 |= EP2_MallocedToken;
}
sqlite3DbFree(db, pDup);
}
@@ -74959,16 +74787,16 @@
Schema *pSchema = 0; /* Schema of the expression */
int isTrigger = 0;
assert( pNC ); /* the name context cannot be NULL. */
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
- assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
+ assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
/* Initialize the node to no-match */
pExpr->iTable = -1;
pExpr->pTab = 0;
- ExprSetVVAProperty(pExpr, EP_NoReduce);
+ ExprSetIrreducible(pExpr);
/* Translate the schema name in zDb into a pointer to the corresponding
** schema. If not found, pSchema will remain NULL and nothing will match
** resulting in an appropriate error message toward the end of this routine
*/
@@ -75300,23 +75128,10 @@
}
#else
# define notValidCheckConstraint(P,N,M)
#endif
-/*
-** Expression p should encode a floating point value between 1.0 and 0.0.
-** Return 1024 times this value. Or return -1 if p is not a floating point
-** value between 1.0 and 0.0.
-*/
-static int exprProbability(Expr *p){
- double r = -1.0;
- if( p->op!=TK_FLOAT ) return -1;
- sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);
- assert( r>=0.0 );
- if( r>1.0 ) return -1;
- return (int)(r*1000.0);
-}
/*
** This routine is callback for sqlite3WalkExpr().
**
** Resolve symbolic names into TK_COLUMN operators for the current
@@ -75334,11 +75149,11 @@
pNC = pWalker->u.pNC;
assert( pNC!=0 );
pParse = pNC->pParse;
assert( pParse==pWalker->pParse );
- if( ExprHasProperty(pExpr, EP_Resolved) ) return WRC_Prune;
+ if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;
ExprSetProperty(pExpr, EP_Resolved);
#ifndef NDEBUG
if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){
SrcList *pSrcList = pNC->pSrcList;
int i;
@@ -75426,27 +75241,10 @@
}else{
wrong_num_args = 1;
}
}else{
is_agg = pDef->xFunc==0;
- if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){
- ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);
- if( n==2 ){
- pExpr->iTable = exprProbability(pList->a[1].pExpr);
- if( pExpr->iTable<0 ){
- sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
- "constant between 0.0 and 1.0");
- pNC->nErr++;
- }
- }else{
- /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
- ** likelihood(X, 0.0625).
- ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
- ** likelihood(X,0.0625). */
- pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
- }
- }
}
#ifndef SQLITE_OMIT_AUTHORIZATION
if( pDef ){
auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
if( auth!=SQLITE_OK ){
@@ -76223,11 +76021,11 @@
return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
}
#ifndef SQLITE_OMIT_CAST
if( op==TK_CAST ){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- return sqlite3AffinityType(pExpr->u.zToken, 0);
+ return sqlite3AffinityType(pExpr->u.zToken);
}
#endif
if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER)
&& pExpr->pTab!=0
){
@@ -76252,11 +76050,11 @@
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr *pExpr, Token *pCollName){
if( pCollName->n>0 ){
Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1);
if( pNew ){
pNew->pLeft = pExpr;
- pNew->flags |= EP_Collate|EP_Skip;
+ pNew->flags |= EP_Collate;
pExpr = pNew;
}
}
return pExpr;
}
@@ -76267,25 +76065,17 @@
s.n = sqlite3Strlen30(s.z);
return sqlite3ExprAddCollateToken(pParse, pExpr, &s);
}
/*
-** Skip over any TK_COLLATE or TK_AS operators and any unlikely()
-** or likelihood() function at the root of an expression.
+** Skip over any TK_COLLATE and/or TK_AS operators at the root of
+** an expression.
*/
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
- while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){
- if( ExprHasProperty(pExpr, EP_Unlikely) ){
- assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
- assert( pExpr->x.pList->nExpr>0 );
- assert( pExpr->op==TK_FUNCTION );
- pExpr = pExpr->x.pList->a[0].pExpr;
- }else{
- assert( pExpr->op==TK_COLLATE || pExpr->op==TK_AS );
- pExpr = pExpr->pLeft;
- }
- }
+ while( pExpr && (pExpr->op==TK_COLLATE || pExpr->op==TK_AS) ){
+ pExpr = pExpr->pLeft;
+ }
return pExpr;
}
/*
** Return the collation sequence for the expression pExpr. If
@@ -76786,11 +76576,11 @@
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
sqlite3 *db = pParse->db;
const char *z;
if( pExpr==0 ) return;
- assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
+ assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
z = pExpr->u.zToken;
assert( z!=0 );
assert( z[0]!=0 );
if( z[1]==0 ){
/* Wildcard of the form "?". Assign the next variable number */
@@ -76856,16 +76646,16 @@
*/
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){
if( p==0 ) return;
/* Sanity check: Assert that the IntValue is non-negative if it exists */
assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
- if( !ExprHasProperty(p, EP_TokenOnly) ){
- /* The Expr.x union is never used at the same time as Expr.pRight */
- assert( p->x.pList==0 || p->pRight==0 );
+ if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
sqlite3ExprDelete(db, p->pLeft);
sqlite3ExprDelete(db, p->pRight);
- if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
+ if( !ExprHasProperty(p, EP_Reduced) && (p->flags2 & EP2_MallocedToken)!=0 ){
+ sqlite3DbFree(db, p->u.zToken);
+ }
if( ExprHasProperty(p, EP_xIsSelect) ){
sqlite3SelectDelete(db, p->x.pSelect);
}else{
sqlite3ExprListDelete(db, p->x.pList);
}
@@ -76921,23 +76711,20 @@
** to enforce this constraint.
*/
static int dupedExprStructSize(Expr *p, int flags){
int nSize;
assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
- assert( EXPR_FULLSIZE<=0xfff );
- assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
if( 0==(flags&EXPRDUP_REDUCE) ){
nSize = EXPR_FULLSIZE;
}else{
- assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
+ assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );
assert( !ExprHasProperty(p, EP_FromJoin) );
- assert( !ExprHasProperty(p, EP_MemToken) );
- assert( !ExprHasProperty(p, EP_NoReduce) );
- if( p->pLeft || p->x.pList ){
+ assert( (p->flags2 & EP2_MallocedToken)==0 );
+ assert( (p->flags2 & EP2_Irreducible)==0 );
+ if( p->pLeft || p->pRight || p->x.pList ){
nSize = EXPR_REDUCEDSIZE | EP_Reduced;
}else{
- assert( p->pRight==0 );
nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly;
}
}
return nSize;
}
@@ -77027,11 +76814,11 @@
memcpy(zAlloc, p, nSize);
memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
}
/* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
- pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);
+ pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static);
pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);
pNew->flags |= staticFlag;
/* Copy the p->u.zToken string, if any. */
if( nToken ){
@@ -77047,21 +76834,22 @@
pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);
}
}
/* Fill in pNew->pLeft and pNew->pRight. */
- if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
+ if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly) ){
zAlloc += dupedExprNodeSize(p, flags);
if( ExprHasProperty(pNew, EP_Reduced) ){
pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);
}
if( pzBuffer ){
*pzBuffer = zAlloc;
}
}else{
- if( !ExprHasProperty(p, EP_TokenOnly) ){
+ pNew->flags2 = 0;
+ if( !ExprHasAnyProperty(p, EP_TokenOnly) ){
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
}
}
@@ -77367,11 +77155,11 @@
static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
/* If pWalker->u.i is 3 then any term of the expression that comes from
** the ON or USING clauses of a join disqualifies the expression
** from being considered constant. */
- if( pWalker->u.i==3 && ExprHasProperty(pExpr, EP_FromJoin) ){
+ if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){
pWalker->u.i = 0;
return WRC_Abort;
}
switch( pExpr->op ){
@@ -77798,11 +77586,11 @@
*prNotFound = rMayHaveNull = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound);
}else{
testcase( pParse->nQueryLoop>0 );
pParse->nQueryLoop = 0;
- if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){
+ if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
eType = IN_INDEX_ROWID;
}
}
sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
pParse->nQueryLoop = savedNQueryLoop;
@@ -77867,11 +77655,11 @@
** * We are inside a trigger
**
** If all of the above are false, then we can run this code just once
** save the results, and reuse the same result on subsequent invocations.
*/
- if( !ExprHasProperty(pExpr, EP_VarSelect) ){
+ if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){
testAddr = sqlite3CodeOnce(pParse);
}
#ifndef SQLITE_OMIT_EXPLAIN
if( pParse->explain==2 ){
@@ -78036,11 +77824,11 @@
pSel->iLimit = 0;
if( sqlite3Select(pParse, pSel, &dest) ){
return 0;
}
rReg = dest.iSDParm;
- ExprSetVVAProperty(pExpr, EP_NoReduce);
+ ExprSetIrreducible(pExpr);
break;
}
}
if( testAddr>=0 ){
@@ -78508,20 +78296,10 @@
}
return 0;
}
#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
-/*
-** Convert an expression node to a TK_REGISTER
-*/
-static void exprToRegister(Expr *p, int iReg){
- p->op2 = p->op;
- p->op = TK_REGISTER;
- p->iTable = iReg;
- ExprClearProperty(p, EP_Skip);
-}
-
/*
** Generate code into the current Vdbe to evaluate the given
** expression. Attempt to store the results in register "target".
** Return the register where results are stored.
**
@@ -78643,11 +78421,11 @@
case TK_CAST: {
/* Expressions of the form: CAST(pLeft AS token) */
int aff, to_op;
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- aff = sqlite3AffinityType(pExpr->u.zToken, 0);
+ aff = sqlite3AffinityType(pExpr->u.zToken);
to_op = aff - SQLITE_AFF_TEXT + OP_ToText;
assert( to_op==OP_ToText || aff!=SQLITE_AFF_TEXT );
assert( to_op==OP_ToBlob || aff!=SQLITE_AFF_NONE );
assert( to_op==OP_ToNumeric || aff!=SQLITE_AFF_NUMERIC );
assert( to_op==OP_ToInt || aff!=SQLITE_AFF_INTEGER );
@@ -78817,11 +78595,11 @@
CollSeq *pColl = 0; /* A collating sequence */
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
testcase( op==TK_CONST_FUNC );
testcase( op==TK_FUNCTION );
- if( ExprHasProperty(pExpr, EP_TokenOnly) ){
+ if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
pFarg = 0;
}else{
pFarg = pExpr->x.pList;
}
nFarg = pFarg ? pFarg->nExpr : 0;
@@ -78851,18 +78629,10 @@
}
sqlite3VdbeResolveLabel(v, endCoalesce);
break;
}
- /* The UNLIKELY() function is a no-op. The result is the value
- ** of the first argument.
- */
- if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){
- assert( nFarg>=1 );
- sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
- break;
- }
if( pFarg ){
r1 = sqlite3GetTempRange(pParse, nFarg);
/* For length() and typeof() functions with a column argument,
@@ -79056,13 +78826,13 @@
** Form A is can be transformed into the equivalent form B as follows:
** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...
** WHEN x=eN THEN rN ELSE y END
**
** X (if it exists) is in pExpr->pLeft.
- ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is
- ** odd. The Y is also optional. If the number of elements in x.pList
- ** is even, then Y is omitted and the "otherwise" result is NULL.
+ ** Y is in pExpr->pRight. The Y is also optional. If there is no
+ ** ELSE clause and no other term matches, then the result of the
+ ** exprssion is NULL.
** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
**
** The result of the expression is the Ri for the first matching Ei,
** or if there is no matching Ei, the ELSE term Y, or if there is
** no ELSE term, NULL.
@@ -79079,31 +78849,33 @@
Expr *pX; /* The X expression */
Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
+ assert((pExpr->x.pList->nExpr % 2) == 0);
assert(pExpr->x.pList->nExpr > 0);
pEList = pExpr->x.pList;
aListelem = pEList->a;
nExpr = pEList->nExpr;
endLabel = sqlite3VdbeMakeLabel(v);
if( (pX = pExpr->pLeft)!=0 ){
cacheX = *pX;
testcase( pX->op==TK_COLUMN );
testcase( pX->op==TK_REGISTER );
- exprToRegister(&cacheX, sqlite3ExprCodeTemp(pParse, pX, ®Free1));
+ cacheX.iTable = sqlite3ExprCodeTemp(pParse, pX, ®Free1);
testcase( regFree1==0 );
+ cacheX.op = TK_REGISTER;
opCompare.op = TK_EQ;
opCompare.pLeft = &cacheX;
pTest = &opCompare;
/* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
** The value in regFree1 might get SCopy-ed into the file result.
** So make sure that the regFree1 register is not reused for other
** purposes and possibly overwritten. */
regFree1 = 0;
}
- for(i=0; ipRight ){
sqlite3ExprCachePush(pParse);
- sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
+ sqlite3ExprCode(pParse, pExpr->pRight, target);
sqlite3ExprCachePop(pParse, 1);
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
assert( db->mallocFailed || pParse->nErr>0
@@ -79231,11 +79003,13 @@
** modifications or enhancements. */
if( ALWAYS(pExpr->op!=TK_REGISTER) ){
int iMem;
iMem = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Copy, inReg, iMem);
- exprToRegister(pExpr, iMem);
+ pExpr->iTable = iMem;
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_REGISTER;
}
return inReg;
}
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
@@ -79310,11 +79084,11 @@
}
#ifndef SQLITE_OMIT_CAST
case TK_CAST: {
/* Expressions of the form: CAST(pLeft AS token) */
const char *zAff = "unk";
- switch( sqlite3AffinityType(pExpr->u.zToken, 0) ){
+ switch( sqlite3AffinityType(pExpr->u.zToken) ){
case SQLITE_AFF_TEXT: zAff = "TEXT"; break;
case SQLITE_AFF_NONE: zAff = "NONE"; break;
case SQLITE_AFF_NUMERIC: zAff = "NUMERIC"; break;
case SQLITE_AFF_INTEGER: zAff = "INTEGER"; break;
case SQLITE_AFF_REAL: zAff = "REAL"; break;
@@ -79361,11 +79135,11 @@
case TK_AGG_FUNCTION:
case TK_CONST_FUNC:
case TK_FUNCTION: {
ExprList *pFarg; /* List of function arguments */
- if( ExprHasProperty(pExpr, EP_TokenOnly) ){
+ if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){
pFarg = 0;
}else{
pFarg = pExpr->x.pList;
}
if( op==TK_AGG_FUNCTION ){
@@ -79610,11 +79384,13 @@
int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);
/* If r2!=r1, it means that register r1 is never used. That is harmless
** but suboptimal, so we want to know about the situation to fix it.
** Hence the following assert: */
assert( r2==r1 );
- exprToRegister(pExpr, r2);
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_REGISTER;
+ pExpr->iTable = r2;
return WRC_Prune;
}
return WRC_Continue;
}
@@ -79708,11 +79484,13 @@
compLeft.pLeft = &exprX;
compLeft.pRight = pExpr->x.pList->a[0].pExpr;
compRight.op = TK_LE;
compRight.pLeft = &exprX;
compRight.pRight = pExpr->x.pList->a[1].pExpr;
- exprToRegister(&exprX, sqlite3ExprCodeTemp(pParse, &exprX, ®Free1));
+ exprX.iTable = sqlite3ExprCodeTemp(pParse, &exprX, ®Free1);
+ exprX.op2 = exprX.op;
+ exprX.op = TK_REGISTER;
if( jumpIfTrue ){
sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);
}else{
sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);
}
@@ -80023,12 +79801,12 @@
*/
SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
if( pA==0||pB==0 ){
return pB==pA ? 0 : 2;
}
- assert( !ExprHasProperty(pA, EP_TokenOnly|EP_Reduced) );
- assert( !ExprHasProperty(pB, EP_TokenOnly|EP_Reduced) );
+ assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
+ assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
return 2;
}
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
@@ -80238,11 +80016,11 @@
** clause of the aggregate query */
if( ALWAYS(pSrcList!=0) ){
struct SrcList_item *pItem = pSrcList->a;
for(i=0; inSrc; i++, pItem++){
struct AggInfo_col *pCol;
- assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
+ assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
if( pExpr->iTable==pItem->iCursor ){
/* If we reach this point, it means that pExpr refers to a table
** that is in the FROM clause of the aggregate query.
**
** Make an entry for the column in pAggInfo->aCol[] if there
@@ -80287,11 +80065,11 @@
/* There is now an entry for pExpr in pAggInfo->aCol[] (either
** because it was there before or because we just created it).
** Convert the pExpr to be a TK_AGG_COLUMN referring to that
** pAggInfo->aCol[] entry.
*/
- ExprSetVVAProperty(pExpr, EP_NoReduce);
+ ExprSetIrreducible(pExpr);
pExpr->pAggInfo = pAggInfo;
pExpr->op = TK_AGG_COLUMN;
pExpr->iAgg = (i16)k;
break;
} /* endif pExpr->iTable==pItem->iCursor */
@@ -80333,12 +80111,12 @@
}
}
}
/* Make pExpr point to the appropriate pAggInfo->aFunc[] entry
*/
- assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
- ExprSetVVAProperty(pExpr, EP_NoReduce);
+ assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
+ ExprSetIrreducible(pExpr);
pExpr->iAgg = (i16)i;
pExpr->pAggInfo = pAggInfo;
return WRC_Prune;
}else{
return WRC_Continue;
@@ -81314,11 +81092,11 @@
** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
** created and used by SQLite versions 3.7.9 and later and with
** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
** version of sqlite_stat3 and is only available when compiled with
-** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
+** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
** not possible to enable both STAT3 and STAT4 at the same time. If they
** are both enabled, then STAT4 takes precedence.
**
** For most applications, sqlite_stat1 provides all the statisics required
** for the query planner to make good choices.
@@ -81390,16 +81168,16 @@
**
** The sqlite_stat4 table contains multiple entries for each index.
** The idx column names the index and the tbl column is the table of the
** index. If the idx and tbl columns are the same, then the sample is
** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
-** binary encoding of a key from the index. The nEq column is a
-** list of integers. The first integer is the approximate number
-** of entries in the index whose left-most column exactly matches
-** the left-most column of the sample. The second integer in nEq
-** is the approximate number of entries in the index where the
-** first two columns match the first two columns of the sample.
+** binary encoding of a key from the index, with the trailing rowid
+** omitted. The nEq column is a list of integers. The first integer
+** is the approximate number of entries in the index whose left-most
+** column exactly matches the left-most column of the sample. The second
+** integer in nEq is the approximate number of entries in the index where
+** the first two columns match the first two columns of the sample.
** And so forth. nLt is another list of integers that show the approximate
** number of entries that are strictly less than the sample. The first
** integer in nLt contains the number of entries in the index where the
** left-most column is less than the left-most column of the sample.
** The K-th integer in the nLt entry is the number of index entries
@@ -81726,11 +81504,11 @@
}
/*
** Copy the contents of object (*pFrom) into (*pTo).
*/
-static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
+void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
pTo->iRowid = pFrom->iRowid;
pTo->isPSample = pFrom->isPSample;
pTo->iCol = pFrom->iCol;
pTo->iHash = pFrom->iHash;
memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81871,15 +81649,10 @@
){
sampleInsert(p, &p->current, 0);
}
}
#endif
-
-#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
- UNUSED_PARAMETER( p );
- UNUSED_PARAMETER( iChng );
-#endif
}
/*
** Implementation of the stat_push SQL function: stat_push(P,R,C)
** Arguments:
@@ -81901,12 +81674,10 @@
/* The three function arguments */
Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
int iChng = sqlite3_value_int(argv[1]);
- UNUSED_PARAMETER( argc );
- UNUSED_PARAMETER( context );
assert( p->nCol>1 ); /* Includes rowid field */
assert( iChngnCol );
if( p->nRow==0 ){
/* This is the first call to this function. Do initialization. */
@@ -82032,16 +81803,16 @@
if( zRet==0 ){
sqlite3_result_error_nomem(context);
return;
}
- sqlite3_snprintf(24, zRet, "%llu", (u64)p->nRow);
+ sqlite3_snprintf(24, zRet, "%lld", p->nRow);
z = zRet + sqlite3Strlen30(zRet);
for(i=0; i<(p->nCol-1); i++){
- u64 nDistinct = p->current.anDLt[i] + 1;
- u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
- sqlite3_snprintf(24, z, " %llu", iVal);
+ i64 nDistinct = p->current.anDLt[i] + 1;
+ i64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
+ sqlite3_snprintf(24, z, " %lld", iVal);
z += sqlite3Strlen30(z);
assert( p->current.anEq[i] );
}
assert( z[0]=='\0' && z>zRet );
@@ -82078,23 +81849,20 @@
sqlite3_result_error_nomem(context);
}else{
int i;
char *z = zRet;
for(i=0; inCol; i++){
- sqlite3_snprintf(24, z, "%llu ", (u64)aCnt[i]);
+ sqlite3_snprintf(24, z, "%lld ", aCnt[i]);
z += sqlite3Strlen30(z);
}
assert( z[0]=='\0' && z>zRet );
z[-1] = '\0';
sqlite3_result_text(context, zRet, -1, sqlite3_free);
}
}
}
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
-#ifndef SQLITE_DEBUG
- UNUSED_PARAMETER( argc );
-#endif
}
static const FuncDef statGetFuncdef = {
1+IsStat34, /* nArg */
SQLITE_UTF8, /* funcFlags */
0, /* pUserData */
@@ -82109,14 +81877,12 @@
static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
assert( regOut!=regStat4 && regOut!=regStat4+1 );
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
-#elif SQLITE_DEBUG
+#else
assert( iParam==STAT_GET_STAT1 );
-#else
- UNUSED_PARAMETER( iParam );
#endif
sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
sqlite3VdbeChangeP5(v, 1 + IsStat34);
}
@@ -82544,19 +82310,21 @@
** The first argument points to a nul-terminated string containing a
** list of space separated integers. Read the first nOut of these into
** the array aOut[].
*/
static void decodeIntArray(
- char *zIntArray, /* String containing int array to decode */
- int nOut, /* Number of slots in aOut[] */
- tRowcnt *aOut, /* Store integers here */
- Index *pIndex /* Handle extra flags for this index, if not NULL */
+ char *zIntArray,
+ int nOut,
+ tRowcnt *aOut,
+ int *pbUnordered
){
char *z = zIntArray;
int c;
int i;
tRowcnt v;
+
+ assert( pbUnordered==0 || *pbUnordered==0 );
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( z==0 ) z = "";
#else
if( NEVER(z==0) ) z = "";
@@ -82568,23 +82336,12 @@
z++;
}
aOut[i] = v;
if( *z==' ' ) z++;
}
-#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
- assert( pIndex!=0 );
-#else
- if( pIndex )
-#endif
- {
- if( strcmp(z, "unordered")==0 ){
- pIndex->bUnordered = 1;
- }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
- int v32 = 0;
- sqlite3GetInt32(z+3, &v32);
- pIndex->szIdxRow = sqlite3LogEst(v32);
- }
+ if( pbUnordered && strcmp(z, "unordered")==0 ){
+ *pbUnordered = 1;
}
}
/*
** This callback is invoked once for each index when reading the
@@ -82619,17 +82376,16 @@
pIndex = 0;
}
z = argv[2];
if( pIndex ){
- decodeIntArray((char*)z, pIndex->nColumn+1, pIndex->aiRowEst, pIndex);
+ int bUnordered = 0;
+ decodeIntArray((char*)z, pIndex->nColumn+1, pIndex->aiRowEst,&bUnordered);
if( pIndex->pPartIdxWhere==0 ) pTable->nRowEst = pIndex->aiRowEst[0];
+ pIndex->bUnordered = bUnordered;
}else{
- Index fakeIdx;
- fakeIdx.szIdxRow = pTable->szTabRow;
- decodeIntArray((char*)z, 1, &pTable->nRowEst, &fakeIdx);
- pTable->szTabRow = fakeIdx.szIdxRow;
+ decodeIntArray((char*)z, 1, &pTable->nRowEst, 0);
}
return 0;
}
@@ -83348,28 +83104,32 @@
#endif /* SQLITE_OMIT_ATTACH */
/*
** Initialize a DbFixer structure. This routine must be called prior
** to passing the structure to one of the sqliteFixAAAA() routines below.
+**
+** The return value indicates whether or not fixation is required. TRUE
+** means we do need to fix the database references, FALSE means we do not.
*/
-SQLITE_PRIVATE void sqlite3FixInit(
+SQLITE_PRIVATE int sqlite3FixInit(
DbFixer *pFix, /* The fixer to be initialized */
Parse *pParse, /* Error messages will be written here */
int iDb, /* This is the database that must be used */
const char *zType, /* "view", "trigger", or "index" */
const Token *pName /* Name of the view, trigger, or index */
){
sqlite3 *db;
+ if( NEVER(iDb<0) || iDb==1 ) return 0;
db = pParse->db;
assert( db->nDb>iDb );
pFix->pParse = pParse;
pFix->zDb = db->aDb[iDb].zName;
pFix->pSchema = db->aDb[iDb].pSchema;
pFix->zType = zType;
pFix->pName = pName;
- pFix->bVarOnly = (iDb==1);
+ return 1;
}
/*
** The following set of routines walk through the parse tree and assign
** a specific database to all table references where the database name
@@ -83393,21 +83153,19 @@
struct SrcList_item *pItem;
if( NEVER(pList==0) ) return 0;
zDb = pFix->zDb;
for(i=0, pItem=pList->a; inSrc; i++, pItem++){
- if( pFix->bVarOnly==0 ){
- if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){
- sqlite3ErrorMsg(pFix->pParse,
- "%s %T cannot reference objects in database %s",
- pFix->zType, pFix->pName, pItem->zDatabase);
- return 1;
- }
- sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);
- pItem->zDatabase = 0;
- pItem->pSchema = pFix->pSchema;
- }
+ if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){
+ sqlite3ErrorMsg(pFix->pParse,
+ "%s %T cannot reference objects in database %s",
+ pFix->zType, pFix->pName, pItem->zDatabase);
+ return 1;
+ }
+ sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);
+ pItem->zDatabase = 0;
+ pItem->pSchema = pFix->pSchema;
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
#endif
}
@@ -83426,43 +83184,23 @@
return 1;
}
if( sqlite3FixExpr(pFix, pSelect->pWhere) ){
return 1;
}
- if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){
- return 1;
- }
if( sqlite3FixExpr(pFix, pSelect->pHaving) ){
return 1;
}
- if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){
- return 1;
- }
- if( sqlite3FixExpr(pFix, pSelect->pLimit) ){
- return 1;
- }
- if( sqlite3FixExpr(pFix, pSelect->pOffset) ){
- return 1;
- }
pSelect = pSelect->pPrior;
}
return 0;
}
SQLITE_PRIVATE int sqlite3FixExpr(
DbFixer *pFix, /* Context of the fixation */
Expr *pExpr /* The expression to be fixed to one database */
){
while( pExpr ){
- if( pExpr->op==TK_VARIABLE ){
- if( pFix->pParse->db->init.busy ){
- pExpr->op = TK_NULL;
- }else{
- sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType);
- return 1;
- }
- }
- if( ExprHasProperty(pExpr, EP_TokenOnly) ) break;
+ if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break;
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
}else{
if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
}
@@ -84641,11 +84379,11 @@
}
pTable->zName = zName;
pTable->iPKey = -1;
pTable->pSchema = db->aDb[iDb].pSchema;
pTable->nRef = 1;
- pTable->nRowEst = 1048576;
+ pTable->nRowEst = 1000000;
assert( pParse->pNewTable==0 );
pParse->pNewTable = pTable;
/* If this is the magic sqlite_sequence table used by autoincrement,
** then record a pointer to this table in the main database structure
@@ -84788,11 +84526,10 @@
/* If there is no type specified, columns have the default affinity
** 'NONE'. If there is a type specified, then sqlite3AddColumnType() will
** be called next to set pCol->affinity correctly.
*/
pCol->affinity = SQLITE_AFF_NONE;
- pCol->szEst = 1;
p->nCol++;
}
/*
** This routine is called by the parser while in the middle of
@@ -84830,30 +84567,26 @@
** 'DOUB' | SQLITE_AFF_REAL
**
** If none of the substrings in the above table are found,
** SQLITE_AFF_NUMERIC is returned.
*/
-SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
+SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn){
u32 h = 0;
char aff = SQLITE_AFF_NUMERIC;
- const char *zChar = 0;
- if( zIn==0 ) return aff;
- while( zIn[0] ){
+ if( zIn ) while( zIn[0] ){
h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];
zIn++;
if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */
- aff = SQLITE_AFF_TEXT;
- zChar = zIn;
+ aff = SQLITE_AFF_TEXT;
}else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){ /* CLOB */
aff = SQLITE_AFF_TEXT;
}else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){ /* TEXT */
aff = SQLITE_AFF_TEXT;
}else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b') /* BLOB */
&& (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){
aff = SQLITE_AFF_NONE;
- if( zIn[0]=='(' ) zChar = zIn;
#ifndef SQLITE_OMIT_FLOATING_POINT
}else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l') /* REAL */
&& aff==SQLITE_AFF_NUMERIC ){
aff = SQLITE_AFF_REAL;
}else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a') /* FLOA */
@@ -84867,32 +84600,10 @@
aff = SQLITE_AFF_INTEGER;
break;
}
}
- /* If pszEst is not NULL, store an estimate of the field size. The
- ** estimate is scaled so that the size of an integer is 1. */
- if( pszEst ){
- *pszEst = 1; /* default size is approx 4 bytes */
- if( aff<=SQLITE_AFF_NONE ){
- if( zChar ){
- while( zChar[0] ){
- if( sqlite3Isdigit(zChar[0]) ){
- int v = 0;
- sqlite3GetInt32(zChar, &v);
- v = v/4 + 1;
- if( v>255 ) v = 255;
- *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
- break;
- }
- zChar++;
- }
- }else{
- *pszEst = 5; /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/
- }
- }
- }
return aff;
}
/*
** This routine is called by the parser while in the middle of
@@ -84910,11 +84621,11 @@
p = pParse->pNewTable;
if( p==0 || NEVER(p->nCol<1) ) return;
pCol = &p->aCol[p->nCol-1];
assert( pCol->zType==0 );
pCol->zType = sqlite3NameFromToken(pParse->db, pType);
- pCol->affinity = sqlite3AffinityType(pCol->zType, &pCol->szEst);
+ pCol->affinity = sqlite3AffinityType(pCol->zType);
}
/*
** The expression is the default value for the most recently added column
** of the table currently under construction.
@@ -85258,47 +84969,19 @@
testcase( pCol->affinity==SQLITE_AFF_REAL );
zType = azType[pCol->affinity - SQLITE_AFF_TEXT];
len = sqlite3Strlen30(zType);
assert( pCol->affinity==SQLITE_AFF_NONE
- || pCol->affinity==sqlite3AffinityType(zType, 0) );
+ || pCol->affinity==sqlite3AffinityType(zType) );
memcpy(&zStmt[k], zType, len);
k += len;
assert( k<=n );
}
sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
return zStmt;
}
-/*
-** Estimate the total row width for a table.
-*/
-static void estimateTableWidth(Table *pTab){
- unsigned wTable = 0;
- const Column *pTabCol;
- int i;
- for(i=pTab->nCol, pTabCol=pTab->aCol; i>0; i--, pTabCol++){
- wTable += pTabCol->szEst;
- }
- if( pTab->iPKey<0 ) wTable++;
- pTab->szTabRow = sqlite3LogEst(wTable*4);
-}
-
-/*
-** Estimate the average size of a row for an index.
-*/
-static void estimateIndexWidth(Index *pIdx){
- unsigned wIndex = 1;
- int i;
- const Column *aCol = pIdx->pTable->aCol;
- for(i=0; inColumn; i++){
- assert( pIdx->aiColumn[i]>=0 && pIdx->aiColumn[i]pTable->nCol );
- wIndex += aCol[pIdx->aiColumn[i]].szEst;
- }
- pIdx->szIdxRow = sqlite3LogEst(wIndex*4);
-}
-
/*
** This routine is called to report the final ")" that terminates
** a CREATE TABLE statement.
**
** The table structure that other action routines have been building
@@ -85321,14 +85004,13 @@
Parse *pParse, /* Parse context */
Token *pCons, /* The ',' token after the last column defn. */
Token *pEnd, /* The final ')' token in the CREATE TABLE */
Select *pSelect /* Select from a "CREATE ... AS SELECT" */
){
- Table *p; /* The new table */
- sqlite3 *db = pParse->db; /* The database connection */
- int iDb; /* Database in which the table lives */
- Index *pIdx; /* An implied index of the table */
+ Table *p;
+ sqlite3 *db = pParse->db;
+ int iDb;
if( (pEnd==0 && pSelect==0) || db->mallocFailed ){
return;
}
p = pParse->pNewTable;
@@ -85344,16 +85026,10 @@
if( p->pCheck ){
sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
}
#endif /* !defined(SQLITE_OMIT_CHECK) */
- /* Estimate the average row size for the table and for all implied indices */
- estimateTableWidth(p);
- for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
- estimateIndexWidth(pIdx);
- }
-
/* If the db->init.busy is 1 it means we are reading the SQL off the
** "sqlite_master" or "sqlite_temp_master" table on the disk.
** So do not write to the disk again. Extract the root page number
** for the table from the db->init.newTnum field. (The page number
** should have been put there by the sqliteOpenCb routine.)
@@ -85546,12 +85222,13 @@
sqlite3SelectDelete(db, pSelect);
return;
}
sqlite3TwoPartName(pParse, pName1, pName2, &pName);
iDb = sqlite3SchemaToIndex(db, p->pSchema);
- sqlite3FixInit(&sFix, pParse, iDb, "view", pName);
- if( sqlite3FixSelect(&sFix, pSelect) ){
+ if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName)
+ && sqlite3FixSelect(&sFix, pSelect)
+ ){
sqlite3SelectDelete(db, pSelect);
return;
}
/* Make a copy of the entire SELECT statement that defines the view.
@@ -86308,14 +85985,13 @@
sqlite3 *db = pParse->db;
Db *pDb; /* The specific table containing the indexed database */
int iDb; /* Index of the database that is being written */
Token *pName = 0; /* Unqualified name of the index to create */
struct ExprList_item *pListItem; /* For looping over pList */
- const Column *pTabCol; /* A column in the table */
- int nCol; /* Number of columns */
- int nExtra = 0; /* Space allocated for zExtra[] */
- char *zExtra; /* Extra space after the Index object */
+ int nCol;
+ int nExtra = 0;
+ char *zExtra;
assert( pParse->nErr==0 ); /* Never called with prior errors */
if( db->mallocFailed || IN_DECLARE_VTAB ){
goto exit_create_index;
}
@@ -86348,12 +86024,13 @@
iDb = 1;
}
}
#endif
- sqlite3FixInit(&sFix, pParse, iDb, "index", pName);
- if( sqlite3FixSrcList(&sFix, pTblName) ){
+ if( sqlite3FixInit(&sFix, pParse, iDb, "index", pName) &&
+ sqlite3FixSrcList(&sFix, pTblName)
+ ){
/* Because the parser constructs pTblName from a single identifier,
** sqlite3FixSrcList can never fail. */
assert(0);
}
pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
@@ -86538,10 +86215,11 @@
** same column more than once cannot be an error because that would
** break backwards compatibility - it needs to be a warning.
*/
for(i=0, pListItem=pList->a; inExpr; i++, pListItem++){
const char *zColName = pListItem->zName;
+ Column *pTabCol;
int requestedSortOrder;
char *zColl; /* Collation sequence name */
for(j=0, pTabCol=pTab->aCol; jnCol; j++, pTabCol++){
if( sqlite3StrICmp(zColName, pTabCol->zName)==0 ) break;
@@ -86574,11 +86252,10 @@
requestedSortOrder = pListItem->sortOrder & sortOrderMask;
pIndex->aSortOrder[i] = (u8)requestedSortOrder;
if( pTab->aCol[j].notNull==0 ) pIndex->uniqNotNull = 0;
}
sqlite3DefaultRowEst(pIndex);
- if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
if( pTab==pParse->pNewTable ){
/* This routine has been called to create an automatic index as a
** result of a PRIMARY KEY or UNIQUE clause on a column definition, or
** a PRIMARY KEY or UNIQUE clause following the column definitions.
@@ -88480,11 +88157,10 @@
** API function sqlite3_count_changes) to be set incorrectly. */
if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab)
&& 0==sqlite3FkRequired(pParse, pTab, 0, 0)
){
assert( !isView );
- sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
pTab->zName, P4_STATIC);
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
assert( pIdx->pSchema==pTab->pSchema );
sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
@@ -89223,18 +88899,18 @@
}
}
}
/*
-** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented
-** as VDBE code so that unused argument values do not have to be computed.
-** However, we still need some kind of function implementation for this
-** routines in the function table. The noopFunc macro provides this.
-** noopFunc will never be called so it doesn't matter what the implementation
-** is. We might as well use the "version()" function as a substitute.
+** The COALESCE() and IFNULL() functions are implemented as VDBE code so
+** that unused argument values do not have to be computed. However, we
+** still need some kind of function implementation for this routines in
+** the function table. That function implementation will never be called
+** so it doesn't matter what the implementation is. We might as well use
+** the "version()" function as a substitute.
*/
-#define noopFunc versionFunc /* Substitute function - never called */
+#define ifnullFunc versionFunc /* Substitute function - never called */
/*
** Implementation of random(). Return a random integer.
*/
static void randomFunc(
@@ -89349,13 +89025,13 @@
** able to participate in upper-case-to-lower-case mappings in EBCDIC
** whereas only characters less than 0x80 do in ASCII.
*/
#if defined(SQLITE_EBCDIC)
# define sqlite3Utf8Read(A) (*((*A)++))
-# define GlobUpperToLower(A) A = sqlite3UpperToLower[A]
+# define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
#else
-# define GlobUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; }
+# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; }
#endif
static const struct compareInfo globInfo = { '*', '?', '[', 0 };
/* The correct SQL-92 behavior is for the LIKE operator to ignore
** case. Thus 'a' LIKE 'A' would be true. */
@@ -89430,15 +89106,15 @@
}
return *zString!=0;
}
while( (c2 = sqlite3Utf8Read(&zString))!=0 ){
if( noCase ){
- GlobUpperToLower(c2);
- GlobUpperToLower(c);
+ GlogUpperToLower(c2);
+ GlogUpperToLower(c);
while( c2 != 0 && c2 != c ){
c2 = sqlite3Utf8Read(&zString);
- GlobUpperToLower(c2);
+ GlogUpperToLower(c2);
}
}else{
while( c2 != 0 && c2 != c ){
c2 = sqlite3Utf8Read(&zString);
}
@@ -89486,12 +89162,12 @@
}else if( esc==c && !prevEscape ){
prevEscape = 1;
}else{
c2 = sqlite3Utf8Read(&zString);
if( noCase ){
- GlobUpperToLower(c);
- GlobUpperToLower(c2);
+ GlogUpperToLower(c);
+ GlogUpperToLower(c2);
}
if( c!=c2 ){
return 0;
}
prevEscape = 0;
@@ -90464,15 +90140,13 @@
#endif
FUNCTION(upper, 1, 0, 0, upperFunc ),
FUNCTION(lower, 1, 0, 0, lowerFunc ),
FUNCTION(coalesce, 1, 0, 0, 0 ),
FUNCTION(coalesce, 0, 0, 0, 0 ),
- FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
+ FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
FUNCTION(hex, 1, 0, 0, hexFunc ),
- FUNCTION2(ifnull, 2, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
- FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY),
- FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY),
+ FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
FUNCTION(random, 0, 0, 0, randomFunc ),
FUNCTION(randomblob, 1, 0, 0, randomBlob ),
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -91186,11 +90860,11 @@
** generating any VDBE code. If one can be found, then jump over
** the entire DELETE if there are no outstanding deferred constraints
** when this statement is run. */
FKey *p;
for(p=pTab->pFKey; p; p=p->pNextFrom){
- if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
+ if( p->isDeferred ) break;
}
if( !p ) return;
iSkip = sqlite3VdbeMakeLabel(v);
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
}
@@ -91200,22 +90874,15 @@
pParse->disableTriggers = 0;
/* If the DELETE has generated immediate foreign key constraint
** violations, halt the VDBE and return an error at this point, before
** any modifications to the schema are made. This is because statement
- ** transactions are not able to rollback schema changes.
- **
- ** If the SQLITE_DeferFKs flag is set, then this is not required, as
- ** the statement transaction will not be rolled back even if FK
- ** constraints are violated.
- */
- if( (db->flags & SQLITE_DeferFKs)==0 ){
- sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
- sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
- OE_Abort, "foreign key constraint failed", P4_STATIC
- );
- }
+ ** transactions are not able to rollback schema changes. */
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
+ sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
+ OE_Abort, "foreign key constraint failed", P4_STATIC
+ );
if( iSkip ){
sqlite3VdbeResolveLabel(v, iSkip);
}
}
@@ -93737,11 +93404,10 @@
(char*)pKey, P4_KEYINFO_HANDOFF);
VdbeComment((v, "%s", pSrcIdx->zName));
pKey = sqlite3IndexKeyinfo(pParse, pDestIdx);
sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest,
(char*)pKey, P4_KEYINFO_HANDOFF);
- sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
VdbeComment((v, "%s", pDestIdx->zName));
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0);
sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);
sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1);
@@ -95170,428 +94836,10 @@
**
*************************************************************************
** This file contains code used to implement the PRAGMA command.
*/
-#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
-# if defined(__APPLE__)
-# define SQLITE_ENABLE_LOCKING_STYLE 1
-# else
-# define SQLITE_ENABLE_LOCKING_STYLE 0
-# endif
-#endif
-
-/***************************************************************************
-** The next block of code, including the PragTyp_XXXX macro definitions and
-** the aPragmaName[] object is composed of generated code. DO NOT EDIT.
-**
-** To add new pragmas, edit the code in ../tool/mkpragmatab.tcl and rerun
-** that script. Then copy/paste the output in place of the following:
-*/
-#define PragTyp_HEADER_VALUE 0
-#define PragTyp_AUTO_VACUUM 1
-#define PragTyp_FLAG 2
-#define PragTyp_BUSY_TIMEOUT 3
-#define PragTyp_CACHE_SIZE 4
-#define PragTyp_CASE_SENSITIVE_LIKE 5
-#define PragTyp_COLLATION_LIST 6
-#define PragTyp_COMPILE_OPTIONS 7
-#define PragTyp_DATA_STORE_DIRECTORY 8
-#define PragTyp_DATABASE_LIST 9
-#define PragTyp_DEFAULT_CACHE_SIZE 10
-#define PragTyp_ENCODING 11
-#define PragTyp_FOREIGN_KEY_CHECK 12
-#define PragTyp_FOREIGN_KEY_LIST 13
-#define PragTyp_INCREMENTAL_VACUUM 14
-#define PragTyp_INDEX_INFO 15
-#define PragTyp_INDEX_LIST 16
-#define PragTyp_INTEGRITY_CHECK 17
-#define PragTyp_JOURNAL_MODE 18
-#define PragTyp_JOURNAL_SIZE_LIMIT 19
-#define PragTyp_LOCK_PROXY_FILE 20
-#define PragTyp_LOCKING_MODE 21
-#define PragTyp_PAGE_COUNT 22
-#define PragTyp_MMAP_SIZE 23
-#define PragTyp_PAGE_SIZE 24
-#define PragTyp_SECURE_DELETE 25
-#define PragTyp_SHRINK_MEMORY 26
-#define PragTyp_SOFT_HEAP_LIMIT 27
-#define PragTyp_STATS 28
-#define PragTyp_SYNCHRONOUS 29
-#define PragTyp_TABLE_INFO 30
-#define PragTyp_TEMP_STORE 31
-#define PragTyp_TEMP_STORE_DIRECTORY 32
-#define PragTyp_WAL_AUTOCHECKPOINT 33
-#define PragTyp_WAL_CHECKPOINT 34
-#define PragTyp_ACTIVATE_EXTENSIONS 35
-#define PragTyp_HEXKEY 36
-#define PragTyp_KEY 37
-#define PragTyp_REKEY 38
-#define PragTyp_LOCK_STATUS 39
-#define PragTyp_PARSER_TRACE 40
-#define PragFlag_NeedSchema 0x01
-static const struct sPragmaNames {
- const char *const zName; /* Name of pragma */
- u8 ePragTyp; /* PragTyp_XXX value */
- u8 mPragFlag; /* Zero or more PragFlag_XXX values */
- u32 iArg; /* Extra argument */
-} aPragmaNames[] = {
-#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
- { /* zName: */ "activate_extensions",
- /* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
- { /* zName: */ "application_id",
- /* ePragTyp: */ PragTyp_HEADER_VALUE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_AUTOVACUUM)
- { /* zName: */ "auto_vacuum",
- /* ePragTyp: */ PragTyp_AUTO_VACUUM,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
- { /* zName: */ "automatic_index",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_AutoIndex },
-#endif
- { /* zName: */ "busy_timeout",
- /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "cache_size",
- /* ePragTyp: */ PragTyp_CACHE_SIZE,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "cache_spill",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_CacheSpill },
- { /* zName: */ "case_sensitive_like",
- /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "checkpoint_fullfsync",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_CkptFullFSync },
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
- { /* zName: */ "collation_list",
- /* ePragTyp: */ PragTyp_COLLATION_LIST,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
- { /* zName: */ "compile_options",
- /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "count_changes",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_CountRows },
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
- { /* zName: */ "data_store_directory",
- /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
- { /* zName: */ "database_list",
- /* ePragTyp: */ PragTyp_DATABASE_LIST,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
- { /* zName: */ "default_cache_size",
- /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
- { /* zName: */ "defer_foreign_keys",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_DeferFKs },
-#endif
- { /* zName: */ "empty_result_callbacks",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_NullCallback },
-#if !defined(SQLITE_OMIT_UTF16)
- { /* zName: */ "encoding",
- /* ePragTyp: */ PragTyp_ENCODING,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
- { /* zName: */ "foreign_key_check",
- /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_FOREIGN_KEY)
- { /* zName: */ "foreign_key_list",
- /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
- { /* zName: */ "foreign_keys",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_ForeignKeys },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
- { /* zName: */ "freelist_count",
- /* ePragTyp: */ PragTyp_HEADER_VALUE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "full_column_names",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_FullColNames },
- { /* zName: */ "fullfsync",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_FullFSync },
-#if defined(SQLITE_HAS_CODEC)
- { /* zName: */ "hexkey",
- /* ePragTyp: */ PragTyp_HEXKEY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "hexrekey",
- /* ePragTyp: */ PragTyp_HEXKEY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_CHECK)
- { /* zName: */ "ignore_check_constraints",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_IgnoreChecks },
-#endif
-#if !defined(SQLITE_OMIT_AUTOVACUUM)
- { /* zName: */ "incremental_vacuum",
- /* ePragTyp: */ PragTyp_INCREMENTAL_VACUUM,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
- { /* zName: */ "index_info",
- /* ePragTyp: */ PragTyp_INDEX_INFO,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
- { /* zName: */ "index_list",
- /* ePragTyp: */ PragTyp_INDEX_LIST,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
- { /* zName: */ "integrity_check",
- /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "journal_mode",
- /* ePragTyp: */ PragTyp_JOURNAL_MODE,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
- { /* zName: */ "journal_size_limit",
- /* ePragTyp: */ PragTyp_JOURNAL_SIZE_LIMIT,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if defined(SQLITE_HAS_CODEC)
- { /* zName: */ "key",
- /* ePragTyp: */ PragTyp_KEY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "legacy_file_format",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_LegacyFileFmt },
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
- { /* zName: */ "lock_proxy_file",
- /* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
- { /* zName: */ "lock_status",
- /* ePragTyp: */ PragTyp_LOCK_STATUS,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "locking_mode",
- /* ePragTyp: */ PragTyp_LOCKING_MODE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "max_page_count",
- /* ePragTyp: */ PragTyp_PAGE_COUNT,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
- { /* zName: */ "mmap_size",
- /* ePragTyp: */ PragTyp_MMAP_SIZE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "page_count",
- /* ePragTyp: */ PragTyp_PAGE_COUNT,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
- { /* zName: */ "page_size",
- /* ePragTyp: */ PragTyp_PAGE_SIZE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if defined(SQLITE_DEBUG)
- { /* zName: */ "parser_trace",
- /* ePragTyp: */ PragTyp_PARSER_TRACE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "query_only",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_QueryOnly },
-#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
- { /* zName: */ "quick_check",
- /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "read_uncommitted",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_ReadUncommitted },
- { /* zName: */ "recursive_triggers",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_RecTriggers },
-#if defined(SQLITE_HAS_CODEC)
- { /* zName: */ "rekey",
- /* ePragTyp: */ PragTyp_REKEY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "reverse_unordered_selects",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_ReverseOrder },
-#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
- { /* zName: */ "schema_version",
- /* ePragTyp: */ PragTyp_HEADER_VALUE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "secure_delete",
- /* ePragTyp: */ PragTyp_SECURE_DELETE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "short_column_names",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_ShortColNames },
- { /* zName: */ "shrink_memory",
- /* ePragTyp: */ PragTyp_SHRINK_MEMORY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "soft_heap_limit",
- /* ePragTyp: */ PragTyp_SOFT_HEAP_LIMIT,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#if defined(SQLITE_DEBUG)
- { /* zName: */ "sql_trace",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_SqlTrace },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
- { /* zName: */ "stats",
- /* ePragTyp: */ PragTyp_STATS,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "synchronous",
- /* ePragTyp: */ PragTyp_SYNCHRONOUS,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
- { /* zName: */ "table_info",
- /* ePragTyp: */ PragTyp_TABLE_INFO,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
- { /* zName: */ "temp_store",
- /* ePragTyp: */ PragTyp_TEMP_STORE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "temp_store_directory",
- /* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
- { /* zName: */ "user_version",
- /* ePragTyp: */ PragTyp_HEADER_VALUE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
-#endif
-#if defined(SQLITE_DEBUG)
- { /* zName: */ "vdbe_addoptrace",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_VdbeAddopTrace },
- { /* zName: */ "vdbe_debug",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
- { /* zName: */ "vdbe_listing",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_VdbeListing },
- { /* zName: */ "vdbe_trace",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_VdbeTrace },
-#endif
-#if !defined(SQLITE_OMIT_WAL)
- { /* zName: */ "wal_autocheckpoint",
- /* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
- { /* zName: */ "wal_checkpoint",
- /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
- /* ePragFlag: */ PragFlag_NeedSchema,
- /* iArg: */ 0 },
-#endif
- { /* zName: */ "writable_schema",
- /* ePragTyp: */ PragTyp_FLAG,
- /* ePragFlag: */ 0,
- /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
-};
-/* Number of pragmas: 56 on by default, 68 total. */
-/* End of the automatically generated pragma table.
-***************************************************************************/
-
/*
** Interpret the given string as a safety level. Return 0 for OFF,
** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
** unrecognized string argument. The FULL option is disallowed
** if the omitFull parameter it 1.
@@ -95763,10 +95011,101 @@
#else
# define setAllPagerFlags(X) /* no-op */
#endif
+#ifndef SQLITE_OMIT_FLAG_PRAGMAS
+/*
+** Check to see if zRight and zLeft refer to a pragma that queries
+** or changes one of the flags in db->flags. Return 1 if so and 0 if not.
+** Also, implement the pragma.
+*/
+static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
+ static const struct sPragmaType {
+ const char *zName; /* Name of the pragma */
+ int mask; /* Mask for the db->flags value */
+ } aPragma[] = {
+ { "full_column_names", SQLITE_FullColNames },
+ { "short_column_names", SQLITE_ShortColNames },
+ { "count_changes", SQLITE_CountRows },
+ { "empty_result_callbacks", SQLITE_NullCallback },
+ { "legacy_file_format", SQLITE_LegacyFileFmt },
+ { "fullfsync", SQLITE_FullFSync },
+ { "checkpoint_fullfsync", SQLITE_CkptFullFSync },
+ { "cache_spill", SQLITE_CacheSpill },
+ { "reverse_unordered_selects", SQLITE_ReverseOrder },
+ { "query_only", SQLITE_QueryOnly },
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+ { "automatic_index", SQLITE_AutoIndex },
+#endif
+#ifdef SQLITE_DEBUG
+ { "sql_trace", SQLITE_SqlTrace },
+ { "vdbe_listing", SQLITE_VdbeListing },
+ { "vdbe_trace", SQLITE_VdbeTrace },
+ { "vdbe_addoptrace", SQLITE_VdbeAddopTrace},
+ { "vdbe_debug", SQLITE_SqlTrace | SQLITE_VdbeListing
+ | SQLITE_VdbeTrace },
+#endif
+#ifndef SQLITE_OMIT_CHECK
+ { "ignore_check_constraints", SQLITE_IgnoreChecks },
+#endif
+ /* The following is VERY experimental */
+ { "writable_schema", SQLITE_WriteSchema|SQLITE_RecoveryMode },
+
+ /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
+ ** flag if there are any active statements. */
+ { "read_uncommitted", SQLITE_ReadUncommitted },
+ { "recursive_triggers", SQLITE_RecTriggers },
+
+ /* This flag may only be set if both foreign-key and trigger support
+ ** are present in the build. */
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
+ { "foreign_keys", SQLITE_ForeignKeys },
+ { "defer_foreign_keys", SQLITE_DeferFKs },
+#endif
+ };
+ int i;
+ const struct sPragmaType *p;
+ for(i=0, p=aPragma; izName)==0 ){
+ sqlite3 *db = pParse->db;
+ Vdbe *v;
+ v = sqlite3GetVdbe(pParse);
+ assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
+ if( ALWAYS(v) ){
+ if( zRight==0 ){
+ returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
+ }else{
+ int mask = p->mask; /* Mask of bits to set or clear. */
+ if( db->autoCommit==0 ){
+ /* Foreign key support may not be enabled or disabled while not
+ ** in auto-commit mode. */
+ mask &= ~(SQLITE_ForeignKeys);
+ }
+
+ if( sqlite3GetBoolean(zRight, 0) ){
+ db->flags |= mask;
+ }else{
+ db->flags &= ~mask;
+ if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;
+ }
+
+ /* Many of the flag-pragmas modify the code generated by the SQL
+ ** compiler (eg. count_changes). So add an opcode to expire all
+ ** compiled SQL statements after modifying a pragma value.
+ */
+ sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
+ }
+ }
+
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif /* SQLITE_OMIT_FLAG_PRAGMAS */
+
/*
** Return a human-readable name for a constraint resolution action.
*/
#ifndef SQLITE_OMIT_FOREIGN_KEY
static const char *actionName(u8 action){
@@ -95832,13 +95171,12 @@
){
char *zLeft = 0; /* Nul-terminated UTF-8 string */
char *zRight = 0; /* Nul-terminated UTF-8 string , or NULL */
const char *zDb = 0; /* The database name */
Token *pId; /* Pointer to token */
- char *aFcntl[4]; /* Argument to SQLITE_FCNTL_PRAGMA */
int iDb; /* Database index for */
- int lwr, upr, mid; /* Binary search bounds */
+ char *aFcntl[4]; /* Argument to SQLITE_FCNTL_PRAGMA */
int rc; /* return value form SQLITE_FCNTL_PRAGMA */
sqlite3 *db = pParse->db; /* The database connection */
Db *pDb; /* The specific database being pragmaed */
Vdbe *v = sqlite3GetVdbe(pParse); /* Prepared statement */
@@ -95890,45 +95228,20 @@
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
sqlite3_free(aFcntl[0]);
}
- goto pragma_out;
- }
- if( rc!=SQLITE_NOTFOUND ){
+ }else if( rc!=SQLITE_NOTFOUND ){
if( aFcntl[0] ){
sqlite3ErrorMsg(pParse, "%s", aFcntl[0]);
sqlite3_free(aFcntl[0]);
}
pParse->nErr++;
pParse->rc = rc;
- goto pragma_out;
- }
-
- /* Locate the pragma in the lookup table */
- lwr = 0;
- upr = ArraySize(aPragmaNames)-1;
- while( lwr<=upr ){
- mid = (lwr+upr)/2;
- rc = sqlite3_stricmp(zLeft, aPragmaNames[mid].zName);
- if( rc==0 ) break;
- if( rc<0 ){
- upr = mid - 1;
- }else{
- lwr = mid + 1;
- }
- }
- if( lwr>upr ) goto pragma_out;
-
- /* Make sure the database schema is loaded if the pragma requires that */
- if( (aPragmaNames[mid].mPragFlag & PragFlag_NeedSchema)!=0 ){
- if( sqlite3ReadSchema(pParse) ) goto pragma_out;
- }
-
- /* Jump to the appropriate pragma handler */
- switch( aPragmaNames[mid].ePragTyp ){
-
+ }else
+
+
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
/*
** PRAGMA [database.]default_cache_size
** PRAGMA [database.]default_cache_size=N
**
@@ -95942,11 +95255,11 @@
** negative number to indicate synchronous=OFF. These days, synchronous
** is always on by default regardless of the sign of the default cache
** size. But continue to take the absolute value of the default cache
** size of historical compatibility.
*/
- case PragTyp_DEFAULT_CACHE_SIZE: {
+ if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){
static const VdbeOpList getCacheSize[] = {
{ OP_Transaction, 0, 0, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */
{ OP_IfPos, 1, 8, 0},
{ OP_Integer, 0, 2, 0},
@@ -95955,10 +95268,11 @@
{ OP_Integer, 0, 1, 0}, /* 6 */
{ OP_Noop, 0, 0, 0},
{ OP_ResultRow, 1, 1, 0},
};
int addr;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeUsesBtree(v, iDb);
if( !zRight ){
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC);
pParse->nMem += 2;
@@ -95973,12 +95287,11 @@
sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
pDb->pSchema->cache_size = size;
sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
}
- break;
- }
+ }else
#endif /* !SQLITE_OMIT_PAGER_PRAGMAS && !SQLITE_OMIT_DEPRECATED */
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
/*
** PRAGMA [database.]page_size
@@ -95987,11 +95300,11 @@
** The first form reports the current setting for the
** database page size in bytes. The second form sets the
** database page size value. The value can only be set if
** the database has not yet been created.
*/
- case PragTyp_PAGE_SIZE: {
+ if( sqlite3StrICmp(zLeft,"page_size")==0 ){
Btree *pBt = pDb->pBt;
assert( pBt!=0 );
if( !zRight ){
int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
returnSingleInt(pParse, "page_size", size);
@@ -96002,22 +95315,21 @@
db->nextPagesize = sqlite3Atoi(zRight);
if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){
db->mallocFailed = 1;
}
}
- break;
- }
+ }else
/*
** PRAGMA [database.]secure_delete
** PRAGMA [database.]secure_delete=ON/OFF
**
** The first form reports the current setting for the
** secure_delete flag. The second form changes the secure_delete
** flag setting and reports thenew value.
*/
- case PragTyp_SECURE_DELETE: {
+ if( sqlite3StrICmp(zLeft,"secure_delete")==0 ){
Btree *pBt = pDb->pBt;
int b = -1;
assert( pBt!=0 );
if( zRight ){
b = sqlite3GetBoolean(zRight, 0);
@@ -96028,12 +95340,11 @@
sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
}
}
b = sqlite3BtreeSecureDelete(pBt, b);
returnSingleInt(pParse, "secure_delete", b);
- break;
- }
+ }else
/*
** PRAGMA [database.]max_page_count
** PRAGMA [database.]max_page_count=N
**
@@ -96048,12 +95359,15 @@
**
** PRAGMA [database.]page_count
**
** Return the number of pages in the specified database.
*/
- case PragTyp_PAGE_COUNT: {
+ if( sqlite3StrICmp(zLeft,"page_count")==0
+ || sqlite3StrICmp(zLeft,"max_page_count")==0
+ ){
int iReg;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3CodeVerifySchema(pParse, iDb);
iReg = ++pParse->nMem;
if( sqlite3Tolower(zLeft[0])=='p' ){
sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
}else{
@@ -96061,18 +95375,17 @@
sqlite3AbsInt32(sqlite3Atoi(zRight)));
}
sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
- break;
- }
+ }else
/*
** PRAGMA [database.]locking_mode
** PRAGMA [database.]locking_mode = (normal|exclusive)
*/
- case PragTyp_LOCKING_MODE: {
+ if( sqlite3StrICmp(zLeft,"locking_mode")==0 ){
const char *zRet = "normal";
int eMode = getLockingMode(zRight);
if( pId2->n==0 && eMode==PAGER_LOCKINGMODE_QUERY ){
/* Simple "PRAGMA locking_mode;" statement. This is a query for
@@ -96101,30 +95414,36 @@
}
pPager = sqlite3BtreePager(pDb->pBt);
eMode = sqlite3PagerLockingMode(pPager, eMode);
}
- assert( eMode==PAGER_LOCKINGMODE_NORMAL
- || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );
+ assert(eMode==PAGER_LOCKINGMODE_NORMAL||eMode==PAGER_LOCKINGMODE_EXCLUSIVE);
if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){
zRet = "exclusive";
}
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "locking_mode", SQLITE_STATIC);
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
- break;
- }
+ }else
/*
** PRAGMA [database.]journal_mode
** PRAGMA [database.]journal_mode =
** (delete|persist|off|truncate|memory|wal|off)
*/
- case PragTyp_JOURNAL_MODE: {
+ if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
int ii; /* Loop counter */
+
+ /* Force the schema to be loaded on all databases. This causes all
+ ** database files to be opened and the journal_modes set. This is
+ ** necessary because subsequent processing must know if the databases
+ ** are in WAL mode. */
+ if( sqlite3ReadSchema(pParse) ){
+ goto pragma_out;
+ }
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
if( zRight==0 ){
@@ -96153,30 +95472,28 @@
sqlite3VdbeUsesBtree(v, ii);
sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
}
}
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
- break;
- }
+ }else
/*
** PRAGMA [database.]journal_size_limit
** PRAGMA [database.]journal_size_limit=N
**
** Get or set the size limit on rollback journal files.
*/
- case PragTyp_JOURNAL_SIZE_LIMIT: {
+ if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){
Pager *pPager = sqlite3BtreePager(pDb->pBt);
i64 iLimit = -2;
if( zRight ){
sqlite3Atoi64(zRight, &iLimit, sqlite3Strlen30(zRight), SQLITE_UTF8);
if( iLimit<-1 ) iLimit = -1;
}
iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
returnSingleInt(pParse, "journal_size_limit", iLimit);
- break;
- }
+ }else
#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
/*
** PRAGMA [database.]auto_vacuum
@@ -96184,61 +95501,74 @@
**
** Get or set the value of the database 'auto-vacuum' parameter.
** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL
*/
#ifndef SQLITE_OMIT_AUTOVACUUM
- case PragTyp_AUTO_VACUUM: {
+ if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){
Btree *pBt = pDb->pBt;
assert( pBt!=0 );
+ if( sqlite3ReadSchema(pParse) ){
+ goto pragma_out;
+ }
if( !zRight ){
- returnSingleInt(pParse, "auto_vacuum", sqlite3BtreeGetAutoVacuum(pBt));
+ int auto_vacuum;
+ if( ALWAYS(pBt) ){
+ auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);
+ }else{
+ auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;
+ }
+ returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
}else{
int eAuto = getAutoVacuum(zRight);
assert( eAuto>=0 && eAuto<=2 );
db->nextAutovac = (u8)eAuto;
- /* Call SetAutoVacuum() to set initialize the internal auto and
- ** incr-vacuum flags. This is required in case this connection
- ** creates the database file. It is important that it is created
- ** as an auto-vacuum capable db.
- */
- rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
- if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
- /* When setting the auto_vacuum mode to either "full" or
- ** "incremental", write the value of meta[6] in the database
- ** file. Before writing to meta[6], check that meta[3] indicates
- ** that this really is an auto-vacuum capable database.
- */
- static const VdbeOpList setMeta6[] = {
- { OP_Transaction, 0, 1, 0}, /* 0 */
- { OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE},
- { OP_If, 1, 0, 0}, /* 2 */
- { OP_Halt, SQLITE_OK, OE_Abort, 0}, /* 3 */
- { OP_Integer, 0, 1, 0}, /* 4 */
- { OP_SetCookie, 0, BTREE_INCR_VACUUM, 1}, /* 5 */
- };
- int iAddr;
- iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6);
- sqlite3VdbeChangeP1(v, iAddr, iDb);
- sqlite3VdbeChangeP1(v, iAddr+1, iDb);
- sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4);
- sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1);
- sqlite3VdbeChangeP1(v, iAddr+5, iDb);
- sqlite3VdbeUsesBtree(v, iDb);
- }
- }
- break;
- }
+ if( ALWAYS(eAuto>=0) ){
+ /* Call SetAutoVacuum() to set initialize the internal auto and
+ ** incr-vacuum flags. This is required in case this connection
+ ** creates the database file. It is important that it is created
+ ** as an auto-vacuum capable db.
+ */
+ rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
+ if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
+ /* When setting the auto_vacuum mode to either "full" or
+ ** "incremental", write the value of meta[6] in the database
+ ** file. Before writing to meta[6], check that meta[3] indicates
+ ** that this really is an auto-vacuum capable database.
+ */
+ static const VdbeOpList setMeta6[] = {
+ { OP_Transaction, 0, 1, 0}, /* 0 */
+ { OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE},
+ { OP_If, 1, 0, 0}, /* 2 */
+ { OP_Halt, SQLITE_OK, OE_Abort, 0}, /* 3 */
+ { OP_Integer, 0, 1, 0}, /* 4 */
+ { OP_SetCookie, 0, BTREE_INCR_VACUUM, 1}, /* 5 */
+ };
+ int iAddr;
+ iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6);
+ sqlite3VdbeChangeP1(v, iAddr, iDb);
+ sqlite3VdbeChangeP1(v, iAddr+1, iDb);
+ sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4);
+ sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1);
+ sqlite3VdbeChangeP1(v, iAddr+5, iDb);
+ sqlite3VdbeUsesBtree(v, iDb);
+ }
+ }
+ }
+ }else
#endif
/*
** PRAGMA [database.]incremental_vacuum(N)
**
** Do N steps of incremental vacuuming on a database.
*/
#ifndef SQLITE_OMIT_AUTOVACUUM
- case PragTyp_INCREMENTAL_VACUUM: {
+ if( sqlite3StrICmp(zLeft,"incremental_vacuum")==0 ){
int iLimit, addr;
+ if( sqlite3ReadSchema(pParse) ){
+ goto pragma_out;
+ }
if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){
iLimit = 0x7fffffff;
}
sqlite3BeginWriteOperation(pParse, 0, iDb);
sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);
@@ -96245,12 +95575,11 @@
addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb);
sqlite3VdbeAddOp1(v, OP_ResultRow, 1);
sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr);
sqlite3VdbeJumpHere(v, addr);
- break;
- }
+ }else
#endif
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
/*
** PRAGMA [database.]cache_size
@@ -96261,21 +95590,21 @@
** page cache size value. If N is positive then that is the
** number of pages in the cache. If N is negative, then the
** number of pages is adjusted so that the cache uses -N kibibytes
** of memory.
*/
- case PragTyp_CACHE_SIZE: {
+ if( sqlite3StrICmp(zLeft,"cache_size")==0 ){
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( !zRight ){
returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
}else{
int size = sqlite3Atoi(zRight);
pDb->pSchema->cache_size = size;
sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
}
- break;
- }
+ }else
/*
** PRAGMA [database.]mmap_size(N)
**
** Used to set mapping size limit. The mapping size limit is
@@ -96287,11 +95616,11 @@
**
** This value is advisory. The underlying VFS is free to memory map
** as little or as much as it wants. Except, if N is set to 0 then the
** upper layers will never invoke the xFetch interfaces to the VFS.
*/
- case PragTyp_MMAP_SIZE: {
+ if( sqlite3StrICmp(zLeft,"mmap_size")==0 ){
sqlite3_int64 sz;
#if SQLITE_MAX_MMAP_SIZE>0
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( zRight ){
int ii;
@@ -96314,12 +95643,11 @@
returnSingleInt(pParse, "mmap_size", sz);
}else if( rc!=SQLITE_NOTFOUND ){
pParse->nErr++;
pParse->rc = rc;
}
- break;
- }
+ }else
/*
** PRAGMA temp_store
** PRAGMA temp_store = "default"|"memory"|"file"
**
@@ -96328,18 +95656,17 @@
** value will be restored the next time the database is opened.
**
** Note that it is possible for the library compile-time options to
** override this setting
*/
- case PragTyp_TEMP_STORE: {
+ if( sqlite3StrICmp(zLeft, "temp_store")==0 ){
if( !zRight ){
returnSingleInt(pParse, "temp_store", db->temp_store);
}else{
changeTempStorage(pParse, zRight);
}
- break;
- }
+ }else
/*
** PRAGMA temp_store_directory
** PRAGMA temp_store_directory = ""|"directory_name"
**
@@ -96347,11 +95674,11 @@
** the value sets a specific directory to be used for temporary files.
** Setting to a null string reverts to the default temporary directory search.
** If temporary directory is changed, then invalidateTempStorage.
**
*/
- case PragTyp_TEMP_STORE_DIRECTORY: {
+ if( sqlite3StrICmp(zLeft, "temp_store_directory")==0 ){
if( !zRight ){
if( sqlite3_temp_directory ){
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME,
"temp_store_directory", SQLITE_STATIC);
@@ -96380,12 +95707,11 @@
}else{
sqlite3_temp_directory = 0;
}
#endif /* SQLITE_OMIT_WSD */
}
- break;
- }
+ }else
#if SQLITE_OS_WIN
/*
** PRAGMA data_store_directory
** PRAGMA data_store_directory = ""|"directory_name"
@@ -96397,11 +95723,11 @@
** a relative path will probably be based on the current directory for the
** process. Database file specified with an absolute path are not impacted
** by this setting, regardless of its value.
**
*/
- case PragTyp_DATA_STORE_DIRECTORY: {
+ if( sqlite3StrICmp(zLeft, "data_store_directory")==0 ){
if( !zRight ){
if( sqlite3_data_directory ){
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME,
"data_store_directory", SQLITE_STATIC);
@@ -96424,24 +95750,30 @@
}else{
sqlite3_data_directory = 0;
}
#endif /* SQLITE_OMIT_WSD */
}
- break;
- }
+ }else
#endif
+#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
+# if defined(__APPLE__)
+# define SQLITE_ENABLE_LOCKING_STYLE 1
+# else
+# define SQLITE_ENABLE_LOCKING_STYLE 0
+# endif
+#endif
#if SQLITE_ENABLE_LOCKING_STYLE
/*
- ** PRAGMA [database.]lock_proxy_file
- ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
- **
- ** Return or set the value of the lock_proxy_file flag. Changing
- ** the value sets a specific file to be used for database access locks.
- **
- */
- case PragTyp_LOCK_PROXY_FILE: {
+ ** PRAGMA [database.]lock_proxy_file
+ ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
+ **
+ ** Return or set the value of the lock_proxy_file flag. Changing
+ ** the value sets a specific file to be used for database access locks.
+ **
+ */
+ if( sqlite3StrICmp(zLeft, "lock_proxy_file")==0 ){
if( !zRight ){
Pager *pPager = sqlite3BtreePager(pDb->pBt);
char *proxy_file_path = NULL;
sqlite3_file *pFile = sqlite3PagerFile(pPager);
sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE,
@@ -96468,12 +95800,11 @@
if( res!=SQLITE_OK ){
sqlite3ErrorMsg(pParse, "failed to set lock proxy file");
goto pragma_out;
}
}
- break;
- }
+ }else
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
/*
** PRAGMA [database.]synchronous
** PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL
@@ -96481,11 +95812,12 @@
** Return or set the local value of the synchronous flag. Changing
** the local value does not make changes to the disk file and the
** default value will be restored the next time the database is
** opened.
*/
- case PragTyp_SYNCHRONOUS: {
+ if( sqlite3StrICmp(zLeft,"synchronous")==0 ){
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
if( !zRight ){
returnSingleInt(pParse, "synchronous", pDb->safety_level-1);
}else{
if( !db->autoCommit ){
sqlite3ErrorMsg(pParse,
@@ -96493,43 +95825,17 @@
}else{
pDb->safety_level = getSafetyLevel(zRight,0,1)+1;
setAllPagerFlags(db);
}
}
- break;
- }
+ }else
#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
#ifndef SQLITE_OMIT_FLAG_PRAGMAS
- case PragTyp_FLAG: {
- if( zRight==0 ){
- returnSingleInt(pParse, aPragmaNames[mid].zName,
- (db->flags & aPragmaNames[mid].iArg)!=0 );
- }else{
- int mask = aPragmaNames[mid].iArg; /* Mask of bits to set or clear. */
- if( db->autoCommit==0 ){
- /* Foreign key support may not be enabled or disabled while not
- ** in auto-commit mode. */
- mask &= ~(SQLITE_ForeignKeys);
- }
-
- if( sqlite3GetBoolean(zRight, 0) ){
- db->flags |= mask;
- }else{
- db->flags &= ~mask;
- if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;
- }
-
- /* Many of the flag-pragmas modify the code generated by the SQL
- ** compiler (eg. count_changes). So add an opcode to expire all
- ** compiled SQL statements after modifying a pragma value.
- */
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
- setAllPagerFlags(db);
- }
- break;
- }
+ if( flagPragma(pParse, zLeft, zRight) ){
+ setAllPagerFlags(db);
+ }else
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */
#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS
/*
** PRAGMA table_info()
@@ -96541,12 +95847,13 @@
** name: Column name
** type: Column declaration type.
** notnull: True if 'NOT NULL' is part of column declaration
** dflt_value: The default value for the column, if any.
*/
- case PragTyp_TABLE_INFO: if( zRight ){
+ if( sqlite3StrICmp(zLeft, "table_info")==0 && zRight ){
Table *pTab;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
int i, k;
int nHidden = 0;
Column *pCol;
@@ -96586,46 +95893,16 @@
}
sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
}
}
- }
- break;
-
- case PragTyp_STATS: {
- Index *pIdx;
- HashElem *i;
- v = sqlite3GetVdbe(pParse);
- sqlite3VdbeSetNumCols(v, 4);
- pParse->nMem = 4;
- sqlite3CodeVerifySchema(pParse, iDb);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC);
- sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC);
- sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC);
- sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC);
- for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
- Table *pTab = sqliteHashData(i);
- sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
- sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
- sqlite3VdbeAddOp2(v, OP_Integer,
- (int)sqlite3LogEstToInt(pTab->szTabRow), 3);
- sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4);
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
- for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
- sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
- sqlite3VdbeAddOp2(v, OP_Integer,
- (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
- sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4);
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
- }
- }
- }
- break;
-
- case PragTyp_INDEX_INFO: if( zRight ){
+ }else
+
+ if( sqlite3StrICmp(zLeft, "index_info")==0 && zRight ){
Index *pIdx;
Table *pTab;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pIdx = sqlite3FindIndex(db, zRight, zDb);
if( pIdx ){
int i;
pTab = pIdx->pTable;
sqlite3VdbeSetNumCols(v, 3);
@@ -96641,38 +95918,43 @@
assert( pTab->nCol>cnum );
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
}
}
- }
- break;
+ }else
- case PragTyp_INDEX_LIST: if( zRight ){
+ if( sqlite3StrICmp(zLeft, "index_list")==0 && zRight ){
Index *pIdx;
Table *pTab;
- int i;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
v = sqlite3GetVdbe(pParse);
- sqlite3VdbeSetNumCols(v, 3);
- pParse->nMem = 3;
- sqlite3CodeVerifySchema(pParse, iDb);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
- sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
- sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
- for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
- sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
- sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
- sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
- }
- }
- }
- break;
-
- case PragTyp_DATABASE_LIST: {
+ pIdx = pTab->pIndex;
+ if( pIdx ){
+ int i = 0;
+ sqlite3VdbeSetNumCols(v, 3);
+ pParse->nMem = 3;
+ sqlite3CodeVerifySchema(pParse, iDb);
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
+ while(pIdx){
+ sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
+ sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
+ ++i;
+ pIdx = pIdx->pNext;
+ }
+ }
+ }
+ }else
+
+ if( sqlite3StrICmp(zLeft, "database_list")==0 ){
int i;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeSetNumCols(v, 3);
pParse->nMem = 3;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "file", SQLITE_STATIC);
@@ -96683,14 +95965,13 @@
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, db->aDb[i].zName, 0);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
}
- }
- break;
+ }else
- case PragTyp_COLLATION_LIST: {
+ if( sqlite3StrICmp(zLeft, "collation_list")==0 ){
int i = 0;
HashElem *p;
sqlite3VdbeSetNumCols(v, 2);
pParse->nMem = 2;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
@@ -96699,18 +95980,18 @@
CollSeq *pColl = (CollSeq *)sqliteHashData(p);
sqlite3VdbeAddOp2(v, OP_Integer, i++, 1);
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl->zName, 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
}
- }
- break;
+ }else
#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
#ifndef SQLITE_OMIT_FOREIGN_KEY
- case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
+ if( sqlite3StrICmp(zLeft, "foreign_key_list")==0 && zRight ){
FKey *pFK;
Table *pTab;
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
v = sqlite3GetVdbe(pParse);
pFK = pTab->pFKey;
if( pFK ){
@@ -96746,17 +96027,16 @@
++i;
pFK = pFK->pNextFrom;
}
}
}
- }
- break;
+ }else
#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
#ifndef SQLITE_OMIT_FOREIGN_KEY
#ifndef SQLITE_OMIT_TRIGGER
- case PragTyp_FOREIGN_KEY_CHECK: {
+ if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){
FKey *pFK; /* A foreign key constraint */
Table *pTab; /* Child table contain "REFERENCES" keyword */
Table *pParent; /* Parent table that child points to */
Index *pIdx; /* Index in the parent table */
int i; /* Loop counter: Foreign key number for pTab */
@@ -96768,10 +96048,11 @@
int regRow; /* Registers to hold a row from pTab */
int addrTop; /* Top of a loop checking foreign keys */
int addrOk; /* Jump here if the key is OK */
int *aiCols; /* child to parent column mapping */
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
regResult = pParse->nMem+1;
pParse->nMem += 4;
regKey = ++pParse->nMem;
regRow = ++pParse->nMem;
v = sqlite3GetVdbe(pParse);
@@ -96795,12 +96076,12 @@
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
P4_TRANSIENT);
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
- pParent = sqlite3FindTable(db, pFK->zTo, zDb);
- if( pParent==0 ) continue;
+ pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
+ if( pParent==0 ) break;
pIdx = 0;
sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
if( x==0 ){
if( pIdx==0 ){
@@ -96813,24 +96094,22 @@
}else{
k = 0;
break;
}
}
- assert( pParse->nErr>0 || pFK==0 );
if( pFK ) break;
if( pParse->nTabnTab = i;
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
- pParent = sqlite3FindTable(db, pFK->zTo, zDb);
+ pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
+ assert( pParent!=0 );
pIdx = 0;
aiCols = 0;
- if( pParent ){
- x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
- assert( x==0 );
- }
+ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
+ assert( x==0 );
addrOk = sqlite3VdbeMakeLabel(v);
- if( pParent && pIdx==0 ){
+ if( pIdx==0 ){
int iKey = pFK->aCol[0].iFrom;
assert( iKey>=0 && iKeynCol );
if( iKey!=pTab->iPKey ){
sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96844,19 +96123,17 @@
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
}else{
for(j=0; jnCol; j++){
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
- aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j);
+ aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);
sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
}
- if( pParent ){
- sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
- sqlite3VdbeChangeP4(v, -1,
- sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
- sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
- }
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
+ sqlite3VdbeChangeP4(v, -1,
+ sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
+ sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
}
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
pFK->zTo, P4_TRANSIENT);
sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -96865,37 +96142,34 @@
sqlite3DbFree(db, aiCols);
}
sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1);
sqlite3VdbeJumpHere(v, addrTop);
}
- }
- break;
+ }else
#endif /* !defined(SQLITE_OMIT_TRIGGER) */
#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
#ifndef NDEBUG
- case PragTyp_PARSER_TRACE: {
+ if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){
if( zRight ){
if( sqlite3GetBoolean(zRight, 0) ){
sqlite3ParserTrace(stderr, "parser: ");
}else{
sqlite3ParserTrace(0, 0);
}
}
- }
- break;
+ }else
#endif
/* Reinstall the LIKE and GLOB functions. The variant of LIKE
** used will be case sensitive or not depending on the RHS.
*/
- case PragTyp_CASE_SENSITIVE_LIKE: {
+ if( sqlite3StrICmp(zLeft, "case_sensitive_like")==0 ){
if( zRight ){
sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0));
}
- }
- break;
+ }else
#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
#endif
@@ -96902,11 +96176,13 @@
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/* Pragma "quick_check" is reduced version of
** integrity_check designed to detect most database corruption
** without most of the overhead of a full integrity-check.
*/
- case PragTyp_INTEGRITY_CHECK: {
+ if( sqlite3StrICmp(zLeft, "integrity_check")==0
+ || sqlite3StrICmp(zLeft, "quick_check")==0
+ ){
int i, j, addr, mxErr;
/* Code that appears at the end of the integrity check. If no error
** messages have been generated, output OK. Otherwise output the
** error message
@@ -96932,10 +96208,11 @@
assert( iDb>=0 );
assert( iDb==0 || pId2->z );
if( pId2->z==0 ) iDb = -1;
/* Initialize the VDBE program */
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pParse->nMem = 6;
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC);
/* Set the maximum error count */
@@ -97061,12 +96338,11 @@
}
addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
sqlite3VdbeChangeP2(v, addr, -mxErr);
sqlite3VdbeJumpHere(v, addr+1);
sqlite3VdbeChangeP4(v, addr+2, "ok", P4_STATIC);
- }
- break;
+ }else
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
#ifndef SQLITE_OMIT_UTF16
/*
** PRAGMA encoding
@@ -97088,11 +96364,11 @@
**
** In the second form this pragma sets the text encoding to be used in
** new database files created using this database handle. It is only
** useful if invoked immediately after the main database i
*/
- case PragTyp_ENCODING: {
+ if( sqlite3StrICmp(zLeft, "encoding")==0 ){
static const struct EncName {
char *zName;
u8 enc;
} encnames[] = {
{ "UTF8", SQLITE_UTF8 },
@@ -97135,12 +96411,11 @@
if( !pEnc->zName ){
sqlite3ErrorMsg(pParse, "unsupported encoding: %s", zRight);
}
}
}
- }
- break;
+ }else
#endif /* SQLITE_OMIT_UTF16 */
#ifndef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
/*
** PRAGMA [database.]schema_version
@@ -97170,11 +96445,15 @@
** crashes or database corruption. Use with caution!
**
** The user-version is not used internally by SQLite. It may be used by
** applications for any purpose.
*/
- case PragTyp_HEADER_VALUE: {
+ if( sqlite3StrICmp(zLeft, "schema_version")==0
+ || sqlite3StrICmp(zLeft, "user_version")==0
+ || sqlite3StrICmp(zLeft, "freelist_count")==0
+ || sqlite3StrICmp(zLeft, "application_id")==0
+ ){
int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */
sqlite3VdbeUsesBtree(v, iDb);
switch( zLeft[0] ){
case 'a': case 'A':
iCookie = BTREE_APPLICATION_ID;
@@ -97214,91 +96493,87 @@
sqlite3VdbeChangeP1(v, addr+1, iDb);
sqlite3VdbeChangeP3(v, addr+1, iCookie);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
}
- }
- break;
+ }else
#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
/*
** PRAGMA compile_options
**
** Return the names of all compile-time options used in this build,
** one option per row.
*/
- case PragTyp_COMPILE_OPTIONS: {
+ if( sqlite3StrICmp(zLeft, "compile_options")==0 ){
int i = 0;
const char *zOpt;
sqlite3VdbeSetNumCols(v, 1);
pParse->nMem = 1;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC);
while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
}
- }
- break;
+ }else
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
#ifndef SQLITE_OMIT_WAL
/*
** PRAGMA [database.]wal_checkpoint = passive|full|restart
**
** Checkpoint the database.
*/
- case PragTyp_WAL_CHECKPOINT: {
+ if( sqlite3StrICmp(zLeft, "wal_checkpoint")==0 ){
int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);
int eMode = SQLITE_CHECKPOINT_PASSIVE;
if( zRight ){
if( sqlite3StrICmp(zRight, "full")==0 ){
eMode = SQLITE_CHECKPOINT_FULL;
}else if( sqlite3StrICmp(zRight, "restart")==0 ){
eMode = SQLITE_CHECKPOINT_RESTART;
}
}
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeSetNumCols(v, 3);
pParse->nMem = 3;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "busy", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "log", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "checkpointed", SQLITE_STATIC);
sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
- }
- break;
+ }else
/*
** PRAGMA wal_autocheckpoint
** PRAGMA wal_autocheckpoint = N
**
** Configure a database connection to automatically checkpoint a database
** after accumulating N frames in the log. Or query for the current value
** of N.
*/
- case PragTyp_WAL_AUTOCHECKPOINT: {
+ if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
if( zRight ){
sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));
}
returnSingleInt(pParse, "wal_autocheckpoint",
db->xWalCallback==sqlite3WalDefaultHook ?
SQLITE_PTR_TO_INT(db->pWalArg) : 0);
- }
- break;
+ }else
#endif
/*
** PRAGMA shrink_memory
**
** This pragma attempts to free as much memory as possible from the
** current database connection.
*/
- case PragTyp_SHRINK_MEMORY: {
+ if( sqlite3StrICmp(zLeft, "shrink_memory")==0 ){
sqlite3_db_release_memory(db);
- break;
- }
+ }else
/*
** PRAGMA busy_timeout
** PRAGMA busy_timeout = N
**
@@ -97305,40 +96580,22 @@
** Call sqlite3_busy_timeout(db, N). Return the current timeout value
** if one is set. If no busy handler or a different busy handler is set
** then 0 is returned. Setting the busy_timeout to 0 or negative
** disables the timeout.
*/
- /*case PragTyp_BUSY_TIMEOUT*/ default: {
- assert( aPragmaNames[mid].ePragTyp==PragTyp_BUSY_TIMEOUT );
+ if( sqlite3StrICmp(zLeft, "busy_timeout")==0 ){
if( zRight ){
sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
}
returnSingleInt(pParse, "timeout", db->busyTimeout);
- break;
- }
-
- /*
- ** PRAGMA soft_heap_limit
- ** PRAGMA soft_heap_limit = N
- **
- ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted,
- ** use -1.
- */
- case PragTyp_SOFT_HEAP_LIMIT: {
- sqlite3_int64 N;
- if( zRight && sqlite3Atoi64(zRight, &N, 1000000, SQLITE_UTF8)==SQLITE_OK ){
- sqlite3_soft_heap_limit64(N);
- }
- returnSingleInt(pParse, "soft_heap_limit", sqlite3_soft_heap_limit64(-1));
- break;
- }
+ }else
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
/*
** Report the current state of file logs for all databases
*/
- case PragTyp_LOCK_STATUS: {
+ if( sqlite3StrICmp(zLeft, "lock_status")==0 ){
static const char *const azLockName[] = {
"unlocked", "shared", "reserved", "pending", "exclusive"
};
int i;
sqlite3VdbeSetNumCols(v, 2);
@@ -97359,43 +96616,39 @@
zState = azLockName[j];
}
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
}
- break;
- }
+
+ }else
#endif
#ifdef SQLITE_HAS_CODEC
- case PragTyp_KEY: {
- if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
- break;
- }
- case PragTyp_REKEY: {
- if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
- break;
- }
- case PragTyp_HEXKEY: {
- if( zRight ){
- u8 iByte;
- int i;
- char zKey[40];
- for(i=0, iByte=0; i>6));
+ h2 += 9*(1&(h2>>6));
+ zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);
+ }
+ if( (zLeft[3] & 0xf)==0xb ){
+ sqlite3_key_v2(db, zDb, zKey, i/2);
+ }else{
+ sqlite3_rekey_v2(db, zDb, zKey, i/2);
+ }
+ }else
#endif
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
- case PragTyp_ACTIVATE_EXTENSIONS: if( zRight ){
+ if( sqlite3StrICmp(zLeft, "activate_extensions")==0 && zRight ){
#ifdef SQLITE_HAS_CODEC
if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){
sqlite3_activate_see(&zRight[4]);
}
#endif
@@ -97402,15 +96655,15 @@
#ifdef SQLITE_ENABLE_CEROD
if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){
sqlite3_activate_cerod(&zRight[6]);
}
#endif
- }
- break;
+ }else
#endif
- } /* End of the PRAGMA switch */
+
+ {/* Empty ELSE clause */}
pragma_out:
sqlite3DbFree(db, zLeft);
sqlite3DbFree(db, zRight);
}
@@ -98557,12 +97810,12 @@
pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);
pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
if( pEq && isOuterJoin ){
ExprSetProperty(pEq, EP_FromJoin);
- assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );
- ExprSetVVAProperty(pEq, EP_NoReduce);
+ assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
+ ExprSetIrreducible(pEq);
pEq->iRightJoinTable = (i16)pE2->iTable;
}
*ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);
}
@@ -98593,12 +97846,12 @@
** the output, which is incorrect.
*/
static void setJoinExpr(Expr *p, int iTable){
while( p ){
ExprSetProperty(p, EP_FromJoin);
- assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
- ExprSetVVAProperty(p, EP_NoReduce);
+ assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );
+ ExprSetIrreducible(p);
p->iRightJoinTable = (i16)iTable;
setJoinExpr(p->pLeft, iTable);
p = p->pRight;
}
}
@@ -99354,13 +98607,10 @@
/*
** Return a pointer to a string containing the 'declaration type' of the
** expression pExpr. The string may be treated as static by the caller.
**
-** Also try to estimate the size of the returned value and return that
-** result in *pEstWidth.
-**
** The declaration type is the exact datatype definition extracted from the
** original CREATE TABLE statement if the expression is a column. The
** declaration type for a ROWID field is INTEGER. Exactly when an expression
** is considered a column can be complex in the presence of subqueries. The
** result-set expression in all of the following SELECT statements is
@@ -99370,40 +98620,25 @@
** SELECT (SELECT col FROM tbl;
** SELECT (SELECT col FROM tbl);
** SELECT abc FROM (SELECT col AS abc FROM tbl);
**
** The declaration type for any expression other than a column is NULL.
-**
-** This routine has either 3 or 6 parameters depending on whether or not
-** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.
-*/
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
-# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,C,D,E,F)
-static const char *columnTypeImpl(
- NameContext *pNC,
- Expr *pExpr,
- const char **pzOrigDb,
- const char **pzOrigTab,
- const char **pzOrigCol,
- u8 *pEstWidth
-){
- char const *zOrigDb = 0;
- char const *zOrigTab = 0;
- char const *zOrigCol = 0;
-#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */
-# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,F)
-static const char *columnTypeImpl(
- NameContext *pNC,
- Expr *pExpr,
- u8 *pEstWidth
-){
-#endif /* !defined(SQLITE_ENABLE_COLUMN_METADATA) */
- char const *zType = 0;
- int j;
- u8 estWidth = 1;
-
- if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
+*/
+static const char *columnType(
+ NameContext *pNC,
+ Expr *pExpr,
+ const char **pzOriginDb,
+ const char **pzOriginTab,
+ const char **pzOriginCol
+){
+ char const *zType = 0;
+ char const *zOriginDb = 0;
+ char const *zOriginTab = 0;
+ char const *zOriginCol = 0;
+ int j;
+ if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;
+
switch( pExpr->op ){
case TK_AGG_COLUMN:
case TK_COLUMN: {
/* The expression is a column. Locate the table the column is being
** extracted from in NameContext.pSrcList. This table may be real
@@ -99460,39 +98695,29 @@
NameContext sNC;
Expr *p = pS->pEList->a[iCol].pExpr;
sNC.pSrcList = pS->pSrc;
sNC.pNext = pNC;
sNC.pParse = pNC->pParse;
- zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol, &estWidth);
+ zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
}
}else if( ALWAYS(pTab->pSchema) ){
/* A real table */
assert( !pS );
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iColnCol) );
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
if( iCol<0 ){
zType = "INTEGER";
- zOrigCol = "rowid";
+ zOriginCol = "rowid";
}else{
zType = pTab->aCol[iCol].zType;
- zOrigCol = pTab->aCol[iCol].zName;
- estWidth = pTab->aCol[iCol].szEst;
+ zOriginCol = pTab->aCol[iCol].zName;
}
- zOrigTab = pTab->zName;
+ zOriginTab = pTab->zName;
if( pNC->pParse ){
int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);
- zOrigDb = pNC->pParse->db->aDb[iDb].zName;
- }
-#else
- if( iCol<0 ){
- zType = "INTEGER";
- }else{
- zType = pTab->aCol[iCol].zType;
- estWidth = pTab->aCol[iCol].szEst;
- }
-#endif
+ zOriginDb = pNC->pParse->db->aDb[iDb].zName;
+ }
}
break;
}
#ifndef SQLITE_OMIT_SUBQUERY
case TK_SELECT: {
@@ -99505,25 +98730,22 @@
Expr *p = pS->pEList->a[0].pExpr;
assert( ExprHasProperty(pExpr, EP_xIsSelect) );
sNC.pSrcList = pS->pSrc;
sNC.pNext = pNC;
sNC.pParse = pNC->pParse;
- zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, &estWidth);
+ zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
break;
}
#endif
}
-
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
- if( pzOrigDb ){
- assert( pzOrigTab && pzOrigCol );
- *pzOrigDb = zOrigDb;
- *pzOrigTab = zOrigTab;
- *pzOrigCol = zOrigCol;
- }
-#endif
- if( pEstWidth ) *pEstWidth = estWidth;
+
+ if( pzOriginDb ){
+ assert( pzOriginTab && pzOriginCol );
+ *pzOriginDb = zOriginDb;
+ *pzOriginTab = zOriginTab;
+ *pzOriginCol = zOriginCol;
+ }
return zType;
}
/*
** Generate code that will tell the VDBE the declaration types of columns
@@ -99545,25 +98767,25 @@
const char *zType;
#ifdef SQLITE_ENABLE_COLUMN_METADATA
const char *zOrigDb = 0;
const char *zOrigTab = 0;
const char *zOrigCol = 0;
- zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, 0);
+ zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);
/* The vdbe must make its own copy of the column-type and other
** column specific strings, in case the schema is reset before this
** virtual machine is deleted.
*/
sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT);
sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);
sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);
#else
- zType = columnType(&sNC, p, 0, 0, 0, 0);
+ zType = columnType(&sNC, p, 0, 0, 0);
#endif
sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);
}
-#endif /* !defined(SQLITE_OMIT_DECLTYPE) */
+#endif /* SQLITE_OMIT_DECLTYPE */
}
/*
** Generate code that will tell the VDBE the names of columns
** in the result set. This information is used to provide the
@@ -99748,41 +98970,39 @@
** This routine requires that all identifiers in the SELECT
** statement be resolved.
*/
static void selectAddColumnTypeAndCollation(
Parse *pParse, /* Parsing contexts */
- Table *pTab, /* Add column type information to this table */
+ int nCol, /* Number of columns */
+ Column *aCol, /* List of columns */
Select *pSelect /* SELECT used to determine types and collations */
){
sqlite3 *db = pParse->db;
NameContext sNC;
Column *pCol;
CollSeq *pColl;
int i;
Expr *p;
struct ExprList_item *a;
- u64 szAll = 0;
assert( pSelect!=0 );
assert( (pSelect->selFlags & SF_Resolved)!=0 );
- assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );
+ assert( nCol==pSelect->pEList->nExpr || db->mallocFailed );
if( db->mallocFailed ) return;
memset(&sNC, 0, sizeof(sNC));
sNC.pSrcList = pSelect->pSrc;
a = pSelect->pEList->a;
- for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){
+ for(i=0, pCol=aCol; izType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
- szAll += pCol->szEst;
+ pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p, 0, 0, 0));
pCol->affinity = sqlite3ExprAffinity(p);
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
pColl = sqlite3ExprCollSeq(pParse, p);
if( pColl ){
pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
}
}
- pTab->szTabRow = sqlite3LogEst(szAll*4);
}
/*
** Given a SELECT statement, generate a Table structure that describes
** the result set of that SELECT.
@@ -99806,13 +99026,13 @@
/* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside
** is disabled */
assert( db->lookaside.bEnabled==0 );
pTab->nRef = 1;
pTab->zName = 0;
- pTab->nRowEst = 1048576;
+ pTab->nRowEst = 1000000;
selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
- selectAddColumnTypeAndCollation(pParse, pTab, pSelect);
+ selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect);
pTab->iPKey = -1;
if( db->mallocFailed ){
sqlite3DeleteTable(db, pTab);
return 0;
}
@@ -101720,15 +100940,15 @@
assert( pFrom->pTab==0 );
sqlite3WalkSelect(pWalker, pSel);
pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
if( pTab==0 ) return WRC_Abort;
pTab->nRef = 1;
- pTab->zName = sqlite3MPrintf(db, "sqlite_sq_%p", (void*)pTab);
+ pTab->zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", (void*)pTab);
while( pSel->pPrior ){ pSel = pSel->pPrior; }
selectColumnsFromExprList(pParse, pSel->pEList, &pTab->nCol, &pTab->aCol);
pTab->iPKey = -1;
- pTab->nRowEst = 1048576;
+ pTab->nRowEst = 1000000;
pTab->tabFlags |= TF_Ephemeral;
#endif
}else{
/* An ordinary table or view name in the FROM clause */
assert( pFrom->pTab==0 );
@@ -102008,11 +101228,11 @@
if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){
/* A sub-query in the FROM clause of a SELECT */
Select *pSel = pFrom->pSelect;
assert( pSel );
while( pSel->pPrior ) pSel = pSel->pPrior;
- selectAddColumnTypeAndCollation(pParse, pTab, pSel);
+ selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel);
}
}
}
return WRC_Continue;
}
@@ -102923,29 +102143,29 @@
int iRoot = pTab->tnum; /* Root page of scanned b-tree */
sqlite3CodeVerifySchema(pParse, iDb);
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
- /* Search for the index that has the lowest scan cost.
+ /* Search for the index that has the least amount of columns. If
+ ** there is such an index, and it has less columns than the table
+ ** does, then we can assume that it consumes less space on disk and
+ ** will therefore be cheaper to scan to determine the query result.
+ ** In this case set iRoot to the root page number of the index b-tree
+ ** and pKeyInfo to the KeyInfo structure required to navigate the
+ ** index.
**
** (2011-04-15) Do not do a full scan of an unordered index.
**
- ** (2013-10-03) Do not count the entires in a partial index.
- **
** In practice the KeyInfo structure will not be used. It is only
** passed to keep OP_OpenRead happy.
*/
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
- if( pIdx->bUnordered==0
- && pIdx->szIdxRowszTabRow
- && pIdx->pPartIdxWhere==0
- && (!pBest || pIdx->szIdxRowszIdxRow)
- ){
+ if( pIdx->bUnordered==0 && (!pBest || pIdx->nColumnnColumn) ){
pBest = pIdx;
}
}
- if( pBest ){
+ if( pBest && pBest->nColumnnCol ){
iRoot = pBest->tnum;
pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest);
}
/* Open a read-only cursor, execute the OP_Count, close the cursor. */
@@ -103519,12 +102739,12 @@
}
/* Ensure the table name matches database name and that the table exists */
if( db->mallocFailed ) goto trigger_cleanup;
assert( pTableName->nSrc==1 );
- sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName);
- if( sqlite3FixSrcList(&sFix, pTableName) ){
+ if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) &&
+ sqlite3FixSrcList(&sFix, pTableName) ){
goto trigger_cleanup;
}
pTab = sqlite3SrcListLookup(pParse, pTableName);
if( !pTab ){
/* The table does not exist. */
@@ -103662,14 +102882,12 @@
pStepList->pTrig = pTrig;
pStepList = pStepList->pNext;
}
nameToken.z = pTrig->zName;
nameToken.n = sqlite3Strlen30(nameToken.z);
- sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken);
- if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
- || sqlite3FixExpr(&sFix, pTrig->pWhen)
- ){
+ if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken)
+ && sqlite3FixTriggerStep(&sFix, pTrig->step_list) ){
goto triggerfinish_cleanup;
}
/* if we are not initializing,
** build the sqlite_master entry
@@ -105256,38 +104474,18 @@
return vacuumFinalize(db, pStmt, pzErrMsg);
}
/*
-** The VACUUM command is used to clean up the database,
+** The non-standard VACUUM command is used to clean up the database,
** collapse free space, etc. It is modelled after the VACUUM command
-** in PostgreSQL. The VACUUM command works as follows:
-**
-** (1) Create a new transient database file
-** (2) Copy all content from the database being vacuumed into
-** the new transient database file
-** (3) Copy content from the transient database back into the
-** original database.
-**
-** The transient database requires temporary disk space approximately
-** equal to the size of the original database. The copy operation of
-** step (3) requires additional temporary disk space approximately equal
-** to the size of the original database for the rollback journal.
-** Hence, temporary disk space that is approximately 2x the size of the
-** orginal database is required. Every page of the database is written
-** approximately 3 times: Once for step (2) and twice for step (3).
-** Two writes per page are required in step (3) because the original
-** database content must be written into the rollback journal prior to
-** overwriting the database with the vacuumed content.
-**
-** Only 1x temporary space and only 1x writes would be required if
-** the copy of step (3) were replace by deleting the original database
-** and renaming the transient database as the original. But that will
-** not work if other processes are attached to the original database.
-** And a power loss in between deleting the original and renaming the
-** transient would cause the database file to appear to be deleted
-** following reboot.
+** in PostgreSQL.
+**
+** In version 1.0.x of SQLite, the VACUUM command would call
+** gdbm_reorganize() on all the database tables. But beginning
+** with 2.0.0, SQLite no longer uses GDBM so this command has
+** become a no-op.
*/
SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse){
Vdbe *v = sqlite3GetVdbe(pParse);
if( v ){
sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);
@@ -106701,10 +105899,29 @@
typedef struct WhereLoopBuilder WhereLoopBuilder;
typedef struct WhereScan WhereScan;
typedef struct WhereOrCost WhereOrCost;
typedef struct WhereOrSet WhereOrSet;
+/*
+** Cost X is tracked as 10*log2(X) stored in a 16-bit integer. The
+** maximum cost for ordinary tables is 64*(2**63) which becomes 6900.
+** (Virtual tables can return a larger cost, but let's assume they do not.)
+** So all costs can be stored in a 16-bit unsigned integer without risk
+** of overflow.
+**
+** Costs are estimates, so no effort is made to compute 10*log2(X) exactly.
+** Instead, a close estimate is used. Any value of X<=1 is stored as 0.
+** X=2 is 10. X=3 is 16. X=1000 is 99. etc.
+**
+** The tool/wherecosttest.c source file implements a command-line program
+** that will convert WhereCosts to integers, convert integers to WhereCosts
+** and do addition and multiplication on WhereCost values. The wherecosttest
+** command-line program is a useful utility to have around when working with
+** this module.
+*/
+typedef unsigned short int WhereCost;
+
/*
** This object contains information needed to implement a single nested
** loop in WHERE clause.
**
** Contrast this object with WhereLoop. This object describes the
@@ -106765,13 +105982,13 @@
#ifdef SQLITE_DEBUG
char cId; /* Symbolic ID of this loop for debugging use */
#endif
u8 iTab; /* Position in FROM clause of table for this loop */
u8 iSortIdx; /* Sorting index number. 0==None */
- LogEst rSetup; /* One-time setup cost (ex: create transient index) */
- LogEst rRun; /* Cost of running each loop */
- LogEst nOut; /* Estimated number of output rows */
+ WhereCost rSetup; /* One-time setup cost (ex: create transient index) */
+ WhereCost rRun; /* Cost of running each loop */
+ WhereCost nOut; /* Estimated number of output rows */
union {
struct { /* Information for internal btree tables */
int nEq; /* Number of equality constraints */
Index *pIndex; /* Index used, or NULL */
} btree;
@@ -106797,12 +106014,12 @@
** subquery on one operand of an OR operator in the WHERE clause.
** See WhereOrSet for additional information
*/
struct WhereOrCost {
Bitmask prereq; /* Prerequisites */
- LogEst rRun; /* Cost of running this subquery */
- LogEst nOut; /* Number of outputs for this subquery */
+ WhereCost rRun; /* Cost of running this subquery */
+ WhereCost nOut; /* Number of outputs for this subquery */
};
/* The WhereOrSet object holds a set of possible WhereOrCosts that
** correspond to the subquery(s) of OR-clause processing. Only the
** best N_OR_COST elements are retained.
@@ -106836,12 +106053,12 @@
** at the end is the choosen query plan.
*/
struct WherePath {
Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
- LogEst nRow; /* Estimated number of rows generated by this path */
- LogEst rCost; /* Total cost of this path */
+ WhereCost nRow; /* Estimated number of rows generated by this path */
+ WhereCost rCost; /* Total cost of this path */
u8 isOrdered; /* True if this path satisfies ORDER BY */
u8 isOrderedValid; /* True if the isOrdered field is valid */
WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
};
@@ -106903,11 +106120,10 @@
union {
int leftColumn; /* Column number of X in "X " */
WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
} u;
- LogEst truthProb; /* Probability of truth for this expression */
u16 eOperator; /* A WO_xx value describing */
u8 wtFlags; /* TERM_xxx bit flags. See below */
u8 nChild; /* Number of children that must disable us */
WhereClause *pWC; /* The clause this term is part of */
Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
@@ -107051,11 +106267,11 @@
SrcList *pTabList; /* List of tables in the join */
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
ExprList *pResultSet; /* Result set. DISTINCT operates on these */
WhereLoop *pLoops; /* List of all WhereLoop objects */
Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
- LogEst nRowOut; /* Estimated number of output rows */
+ WhereCost nRowOut; /* Estimated number of output rows */
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
u8 bOBSat; /* ORDER BY satisfied by indices */
u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE/DELETE */
u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */
@@ -107111,15 +106327,30 @@
#define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
#define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
#define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
+
+/* Convert a WhereCost value (10 times log2(X)) into its integer value X.
+** A rough approximation is used. The value returned is not exact.
+*/
+static u64 whereCostToInt(WhereCost x){
+ u64 n;
+ if( x<10 ) return 1;
+ n = x%10;
+ x /= 10;
+ if( n>=5 ) n -= 2;
+ else if( n>=1 ) n -= 1;
+ if( x>=3 ) return (n+8)<<(x-3);
+ return (n+8)>>(3-x);
+}
+
/*
** Return the estimated number of output rows from a WHERE clause
*/
SQLITE_PRIVATE u64 sqlite3WhereOutputRowCount(WhereInfo *pWInfo){
- return sqlite3LogEstToInt(pWInfo->nRowOut);
+ return whereCostToInt(pWInfo->nRowOut);
}
/*
** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this
** WHERE clause returns outputs for DISTINCT processing.
@@ -107177,12 +106408,12 @@
** so that pSet keeps the N_OR_COST best entries seen so far.
*/
static int whereOrInsert(
WhereOrSet *pSet, /* The WhereOrSet to be updated */
Bitmask prereq, /* Prerequisites of the new entry */
- LogEst rRun, /* Run-cost of the new entry */
- LogEst nOut /* Number of outputs for the new entry */
+ WhereCost rRun, /* Run-cost of the new entry */
+ WhereCost nOut /* Number of outputs for the new entry */
){
u16 i;
WhereOrCost *p;
for(i=pSet->n, p=pSet->a; i>0; i--, p++){
if( rRun<=p->rRun && (prereq & p->prereq)==prereq ){
@@ -107304,15 +106535,10 @@
sqlite3DbFree(db, pOld);
}
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
- if( p && ExprHasProperty(p, EP_Unlikely) ){
- pTerm->truthProb = sqlite3LogEst(p->iTable) - 99;
- }else{
- pTerm->truthProb = -1;
- }
pTerm->pExpr = sqlite3ExprSkipCollate(p);
pTerm->wtFlags = wtFlags;
pTerm->pWC = pWC;
pTerm->iParent = -1;
return idx;
@@ -108569,16 +107795,79 @@
}
return 0;
}
+/*
+** Find (an approximate) sum of two WhereCosts. This computation is
+** not a simple "+" operator because WhereCost is stored as a logarithmic
+** value.
+**
+*/
+static WhereCost whereCostAdd(WhereCost a, WhereCost b){
+ static const unsigned char x[] = {
+ 10, 10, /* 0,1 */
+ 9, 9, /* 2,3 */
+ 8, 8, /* 4,5 */
+ 7, 7, 7, /* 6,7,8 */
+ 6, 6, 6, /* 9,10,11 */
+ 5, 5, 5, /* 12-14 */
+ 4, 4, 4, 4, /* 15-18 */
+ 3, 3, 3, 3, 3, 3, /* 19-24 */
+ 2, 2, 2, 2, 2, 2, 2, /* 25-31 */
+ };
+ if( a>=b ){
+ if( a>b+49 ) return a;
+ if( a>b+31 ) return a+1;
+ return a+x[a-b];
+ }else{
+ if( b>a+49 ) return b;
+ if( b>a+31 ) return b+1;
+ return b+x[b-a];
+ }
+}
+
+/*
+** Convert an integer into a WhereCost. In other words, compute a
+** good approximatation for 10*log2(x).
+*/
+static WhereCost whereCost(tRowcnt x){
+ static WhereCost a[] = { 0, 2, 3, 5, 6, 7, 8, 9 };
+ WhereCost y = 40;
+ if( x<8 ){
+ if( x<2 ) return 0;
+ while( x<8 ){ y -= 10; x <<= 1; }
+ }else{
+ while( x>255 ){ y += 40; x >>= 4; }
+ while( x>15 ){ y += 10; x >>= 1; }
+ }
+ return a[x&7] + y - 10;
+}
+
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+/*
+** Convert a double (as received from xBestIndex of a virtual table)
+** into a WhereCost. In other words, compute an approximation for
+** 10*log2(x).
+*/
+static WhereCost whereCostFromDouble(double x){
+ u64 a;
+ WhereCost e;
+ assert( sizeof(x)==8 && sizeof(a)==8 );
+ if( x<=1 ) return 0;
+ if( x<=2000000000 ) return whereCost((tRowcnt)x);
+ memcpy(&a, &x, 8);
+ e = (a>>52) - 1022;
+ return e*10;
+}
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
/*
** Estimate the logarithm of the input value to base 2.
*/
-static LogEst estLog(LogEst N){
- LogEst x = sqlite3LogEst(N);
+static WhereCost estLog(WhereCost N){
+ WhereCost x = whereCost(N);
return x>33 ? x - 33 : 0;
}
/*
** Two routines for printing the content of an sqlite3_index_info
@@ -108990,13 +108279,10 @@
int iMin = 0; /* Smallest sample not yet tested */
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
int iTest; /* Next sample to test */
int res; /* Result of comparison operation */
-#ifndef SQLITE_DEBUG
- UNUSED_PARAMETER( pParse );
-#endif
assert( pRec!=0 || pParse->db->mallocFailed );
if( pRec==0 ) return;
iCol = pRec->nField - 1;
assert( pIdx->nSample>0 );
assert( pRec->nField>0 && iColnSampleCol );
@@ -109090,11 +108376,11 @@
**
** ... FROM t1 WHERE a > ? AND a < ? ...
**
** then nEq is set to 0.
**
-** When this function is called, *pnOut is set to the sqlite3LogEst() of the
+** When this function is called, *pnOut is set to the whereCost() of the
** number of rows that the index scan is expected to visit without
** considering the range constraints. If nEq is 0, this is the number of
** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)
** to account for the range contraints pLower and pUpper.
**
@@ -109106,19 +108392,18 @@
static int whereRangeScanEst(
Parse *pParse, /* Parsing & code generating context */
WhereLoopBuilder *pBuilder,
WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */
WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
- WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
+ WhereCost *pnOut /* IN/OUT: Number of rows visited */
){
int rc = SQLITE_OK;
- int nOut = pLoop->nOut;
- LogEst nNew;
+ int nOut = (int)*pnOut;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
- Index *p = pLoop->u.btree.pIndex;
- int nEq = pLoop->u.btree.nEq;
+ Index *p = pBuilder->pNew->u.btree.pIndex;
+ int nEq = pBuilder->pNew->u.btree.nEq;
if( p->nSample>0
&& nEq==pBuilder->nRecValid
&& nEqnSampleCol
&& OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -109173,11 +108458,10 @@
if( rc==SQLITE_OK && bOk ){
tRowcnt iNew;
whereKeyStats(pParse, p, pRec, 0, a);
iNew = a[0] + ((pLower->eOperator & WO_GT) ? a[1] : 0);
if( iNew>iLower ) iLower = iNew;
- nOut--;
}
}
/* If possible, improve on the iUpper estimate using ($P:$U). */
if( pUpper ){
@@ -109188,25 +108472,25 @@
if( rc==SQLITE_OK && bOk ){
tRowcnt iNew;
whereKeyStats(pParse, p, pRec, 1, a);
iNew = a[0] + ((pUpper->eOperator & WO_LE) ? a[1] : 0);
if( iNewpRec = pRec;
if( rc==SQLITE_OK ){
+ WhereCost nNew;
if( iUpper>iLower ){
- nNew = sqlite3LogEst(iUpper - iLower);
+ nNew = whereCost(iUpper - iLower);
}else{
- nNew = 10; assert( 10==sqlite3LogEst(2) );
+ nNew = 10; assert( 10==whereCost(2) );
}
if( nNewnOut = (LogEst)nOut;
+ *pnOut = (WhereCost)nOut;
WHERETRACE(0x100, ("range scan regions: %u..%u est=%d\n",
(u32)iLower, (u32)iUpper, nOut));
return SQLITE_OK;
}
}
@@ -109215,22 +108499,18 @@
UNUSED_PARAMETER(pBuilder);
#endif
assert( pLower || pUpper );
/* TUNING: Each inequality constraint reduces the search space 4-fold.
** A BETWEEN operator, therefore, reduces the search space 16-fold */
- nNew = nOut;
if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ){
- nNew -= 20; assert( 20==sqlite3LogEst(4) );
- nOut--;
+ nOut -= 20; assert( 20==whereCost(4) );
}
if( pUpper ){
- nNew -= 20; assert( 20==sqlite3LogEst(4) );
- nOut--;
+ nOut -= 20; assert( 20==whereCost(4) );
}
- if( nNew<10 ) nNew = 10;
- if( nNewnOut = (LogEst)nOut;
+ if( nOut<10 ) nOut = 10;
+ *pnOut = (WhereCost)nOut;
return rc;
}
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
/*
@@ -110760,13 +110040,13 @@
** all of (1) dependencies (2) setup-cost, (3) run-cost, and
** (4) number of output rows. */
assert( p->rSetup==pTemplate->rSetup );
if( p->prereq==pTemplate->prereq
&& p->nLTermnLTerm
- && (p->wsFlags & pTemplate->wsFlags & WHERE_INDEXED)!=0
- && (p->u.btree.pIndex==pTemplate->u.btree.pIndex
- || pTemplate->rRun+p->nLTerm<=p->rRun+pTemplate->nLTerm)
+ && (p->wsFlags & WHERE_INDEXED)!=0
+ && (pTemplate->wsFlags & WHERE_INDEXED)!=0
+ && p->u.btree.pIndex==pTemplate->u.btree.pIndex
){
/* Overwrite an existing WhereLoop with an similar one that uses
** more terms of the index */
pNext = p->pNextLoop;
break;
@@ -110777,16 +110057,16 @@
}
}
if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
&& p->rRun>=pTemplate->rRun
&& p->nOut>=pTemplate->nOut
+ && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */
){
/* Overwrite an existing WhereLoop with a better one: one that is
** better at one of (1) dependencies, (2) setup-cost, (3) run-cost
** or (4) number of output rows, and is no worse in any of those
** categories. */
- assert( p->rSetup>=pTemplate->rSetup ); /* SETUP-INVARIANT above */
pNext = p->pNextLoop;
break;
}
}
@@ -110829,40 +110109,10 @@
}
#endif
return SQLITE_OK;
}
-/*
-** Adjust the WhereLoop.nOut value downward to account for terms of the
-** WHERE clause that reference the loop but which are not used by an
-** index.
-**
-** In the current implementation, the first extra WHERE clause term reduces
-** the number of output rows by a factor of 10 and each additional term
-** reduces the number of output rows by sqrt(2).
-*/
-static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
- WhereTerm *pTerm, *pX;
- Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
- int i, j;
-
- if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
- return;
- }
- for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
- if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
- if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
- if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
- for(j=pLoop->nLTerm-1; j>=0; j--){
- pX = pLoop->aLTerm[j];
- if( pX==pTerm ) break;
- if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
- }
- if( j<0 ) pLoop->nOut += pTerm->truthProb;
- }
-}
-
/*
** We have so far matched pBuilder->pNew->u.btree.nEq terms of the index pIndex.
** Try to match one more.
**
** If pProbe->tnum==0, that means pIndex is a fake index used for the
@@ -110870,11 +110120,11 @@
*/
static int whereLoopAddBtreeIndex(
WhereLoopBuilder *pBuilder, /* The WhereLoop factory */
struct SrcList_item *pSrc, /* FROM clause term being analyzed */
Index *pProbe, /* An index on pSrc */
- LogEst nInMul /* log(Number of iterations due to IN) */
+ WhereCost nInMul /* log(Number of iterations due to IN) */
){
WhereInfo *pWInfo = pBuilder->pWInfo; /* WHERE analyse context */
Parse *pParse = pWInfo->pParse; /* Parsing context */
sqlite3 *db = pParse->db; /* Database connection malloc context */
WhereLoop *pNew; /* Template WhereLoop under construction */
@@ -110883,15 +110133,15 @@
WhereScan scan; /* Iterator for WHERE terms */
Bitmask saved_prereq; /* Original value of pNew->prereq */
u16 saved_nLTerm; /* Original value of pNew->nLTerm */
int saved_nEq; /* Original value of pNew->u.btree.nEq */
u32 saved_wsFlags; /* Original value of pNew->wsFlags */
- LogEst saved_nOut; /* Original value of pNew->nOut */
+ WhereCost saved_nOut; /* Original value of pNew->nOut */
int iCol; /* Index of the column in the table */
int rc = SQLITE_OK; /* Return code */
- LogEst nRowEst; /* Estimated index selectivity */
- LogEst rLogSize; /* Logarithm of table size */
+ WhereCost nRowEst; /* Estimated index selectivity */
+ WhereCost rLogSize; /* Logarithm of table size */
WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */
pNew = pBuilder->pNew;
if( db->mallocFailed ) return SQLITE_NOMEM;
@@ -110907,11 +110157,11 @@
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
assert( pNew->u.btree.nEq<=pProbe->nColumn );
if( pNew->u.btree.nEq < pProbe->nColumn ){
iCol = pProbe->aiColumn[pNew->u.btree.nEq];
- nRowEst = sqlite3LogEst(pProbe->aiRowEst[pNew->u.btree.nEq+1]);
+ nRowEst = whereCost(pProbe->aiRowEst[pNew->u.btree.nEq+1]);
if( nRowEst==0 && pProbe->onError==OE_None ) nRowEst = 1;
}else{
iCol = -1;
nRowEst = 0;
}
@@ -110921,11 +110171,11 @@
saved_nLTerm = pNew->nLTerm;
saved_wsFlags = pNew->wsFlags;
saved_prereq = pNew->prereq;
saved_nOut = pNew->nOut;
pNew->rSetup = 0;
- rLogSize = estLog(sqlite3LogEst(pProbe->aiRowEst[0]));
+ rLogSize = estLog(whereCost(pProbe->aiRowEst[0]));
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
int nIn = 0;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
int nRecValid = pBuilder->nRecValid;
#endif
@@ -110948,14 +110198,14 @@
if( pTerm->eOperator & WO_IN ){
Expr *pExpr = pTerm->pExpr;
pNew->wsFlags |= WHERE_COLUMN_IN;
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
/* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
- nIn = 46; assert( 46==sqlite3LogEst(25) );
+ nIn = 46; assert( 46==whereCost(25) );
}else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
/* "x IN (value, value, ...)" */
- nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
+ nIn = whereCost(pExpr->x.pList->nExpr);
}
pNew->rRun += nIn;
pNew->u.btree.nEq++;
pNew->nOut = nRowEst + nInMul + nIn;
}else if( pTerm->eOperator & (WO_EQ) ){
@@ -110973,11 +110223,11 @@
pNew->nOut = nRowEst + nInMul;
}else if( pTerm->eOperator & (WO_ISNULL) ){
pNew->wsFlags |= WHERE_COLUMN_NULL;
pNew->u.btree.nEq++;
/* TUNING: IS NULL selects 2 rows */
- nIn = 10; assert( 10==sqlite3LogEst(2) );
+ nIn = 10; assert( 10==whereCost(2) );
pNew->nOut = nRowEst + nInMul + nIn;
}else if( pTerm->eOperator & (WO_GT|WO_GE) ){
testcase( pTerm->eOperator & WO_GT );
testcase( pTerm->eOperator & WO_GE );
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
@@ -110993,11 +110243,11 @@
pNew->aLTerm[pNew->nLTerm-2] : 0;
}
if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
/* Adjust nOut and rRun for STAT3 range values */
assert( pNew->nOut==saved_nOut );
- whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);
+ whereRangeScanEst(pParse, pBuilder, pBtm, pTop, &pNew->nOut);
}
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( nInMul==0
&& pProbe->nSample
&& pNew->u.btree.nEq<=pProbe->nSampleCol
@@ -111013,23 +110263,23 @@
&& !ExprHasProperty(pExpr, EP_xIsSelect) ){
rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
}
assert( nOut==0 || rc==SQLITE_OK );
if( nOut ){
- pNew->nOut = sqlite3LogEst(nOut);
- if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
+ nOut = whereCost(nOut);
+ pNew->nOut = MIN(nOut, saved_nOut);
}
}
#endif
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
/* Each row involves a step of the index, then a binary search of
** the main table */
- pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
+ pNew->rRun = whereCostAdd(pNew->rRun, rLogSize>27 ? rLogSize-17 : 10);
}
/* Step cost for each output row */
- pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
- whereLoopOutputAdjust(pBuilder->pWC, pNew);
+ pNew->rRun = whereCostAdd(pNew->rRun, pNew->nOut);
+ /* TBD: Adjust nOut for additional constraints */
rc = whereLoopInsert(pBuilder, pNew);
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
&& pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
){
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111124,20 +110374,18 @@
struct SrcList_item *pSrc; /* The FROM clause btree term to add */
WhereLoop *pNew; /* Template WhereLoop object */
int rc = SQLITE_OK; /* Return code */
int iSortIdx = 1; /* Index number */
int b; /* A boolean value */
- LogEst rSize; /* number of rows in the table */
- LogEst rLogSize; /* Logarithm of the number of rows in the table */
+ WhereCost rSize; /* number of rows in the table */
+ WhereCost rLogSize; /* Logarithm of the number of rows in the table */
WhereClause *pWC; /* The parsed WHERE clause */
- Table *pTab; /* Table being queried */
pNew = pBuilder->pNew;
pWInfo = pBuilder->pWInfo;
pTabList = pWInfo->pTabList;
pSrc = pTabList->a + pNew->iTab;
- pTab = pSrc->pTab;
pWC = pBuilder->pWC;
assert( !IsVirtual(pSrc->pTab) );
if( pSrc->pIndex ){
/* An INDEXED BY clause specifies a particular index to use */
@@ -111151,22 +110399,22 @@
memset(&sPk, 0, sizeof(Index));
sPk.nColumn = 1;
sPk.aiColumn = &aiColumnPk;
sPk.aiRowEst = aiRowEstPk;
sPk.onError = OE_Replace;
- sPk.pTable = pTab;
- aiRowEstPk[0] = pTab->nRowEst;
+ sPk.pTable = pSrc->pTab;
+ aiRowEstPk[0] = pSrc->pTab->nRowEst;
aiRowEstPk[1] = 1;
pFirst = pSrc->pTab->pIndex;
if( pSrc->notIndexed==0 ){
/* The real indices of the table are only considered if the
** NOT INDEXED qualifier is omitted from the FROM clause */
sPk.pNext = pFirst;
}
pProbe = &sPk;
}
- rSize = sqlite3LogEst(pTab->nRowEst);
+ rSize = whereCost(pSrc->pTab->nRowEst);
rLogSize = estLog(rSize);
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
/* Automatic indexes */
if( !pBuilder->pOrSet
@@ -111187,17 +110435,17 @@
pNew->nLTerm = 1;
pNew->aLTerm[0] = pTerm;
/* TUNING: One-time cost for computing the automatic index is
** approximately 7*N*log2(N) where N is the number of rows in
** the table being indexed. */
- pNew->rSetup = rLogSize + rSize + 28; assert( 28==sqlite3LogEst(7) );
+ pNew->rSetup = rLogSize + rSize + 28; assert( 28==whereCost(7) );
/* TUNING: Each index lookup yields 20 rows in the table. This
** is more than the usual guess of 10 rows, since we have no way
** of knowning how selective the index will ultimately be. It would
** not be unreasonable to make this value much larger. */
- pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
- pNew->rRun = sqlite3LogEstAdd(rLogSize,pNew->nOut);
+ pNew->nOut = 43; assert( 43==whereCost(20) );
+ pNew->rRun = whereCostAdd(rLogSize,pNew->nOut);
pNew->wsFlags = WHERE_AUTO_INDEX;
pNew->prereq = mExtra | pTerm->prereqRight;
rc = whereLoopInsert(pBuilder, pNew);
}
}
@@ -111227,48 +110475,47 @@
/* Full table scan */
pNew->iSortIdx = b ? iSortIdx : 0;
/* TUNING: Cost of full table scan is 3*(N + log2(N)).
** + The extra 3 factor is to encourage the use of indexed lookups
- ** over full scans. FIXME */
- pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
- whereLoopOutputAdjust(pWC, pNew);
+ ** over full scans. A smaller constant 2 is used for covering
+ ** index scans so that a covering index scan will be favored over
+ ** a table scan. */
+ pNew->rRun = whereCostAdd(rSize,rLogSize) + 16;
rc = whereLoopInsert(pBuilder, pNew);
- pNew->nOut = rSize;
if( rc ) break;
}else{
Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;
/* Full scan via index */
if( b
|| ( m==0
&& pProbe->bUnordered==0
- && pProbe->szIdxRowszTabRow
&& (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
&& sqlite3GlobalConfig.bUseCis
&& OptimizationEnabled(pWInfo->pParse->db, SQLITE_CoverIdxScan)
)
){
pNew->iSortIdx = b ? iSortIdx : 0;
if( m==0 ){
- /* TUNING: Cost of a covering index scan is K*(N + log2(N)).
- ** + The extra factor K of between 1.1 and 3.0 that depends
- ** on the relative sizes of the table and the index. K
- ** is smaller for smaller indices, thus favoring them.
- */
- pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 1 +
- (15*pProbe->szIdxRow)/pTab->szTabRow;
+ /* TUNING: Cost of a covering index scan is 2*(N + log2(N)).
+ ** + The extra 2 factor is to encourage the use of indexed lookups
+ ** over index scans. A table scan uses a factor of 3 so that
+ ** index scans are favored over table scans.
+ ** + If this covering index might also help satisfy the ORDER BY
+ ** clause, then the cost is fudged down slightly so that this
+ ** index is favored above other indices that have no hope of
+ ** helping with the ORDER BY. */
+ pNew->rRun = 10 + whereCostAdd(rSize,rLogSize) - b;
}else{
assert( b!=0 );
/* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
** which we will simplify to just N*log2(N) */
pNew->rRun = rSize + rLogSize;
}
- whereLoopOutputAdjust(pWC, pNew);
rc = whereLoopInsert(pBuilder, pNew);
- pNew->nOut = rSize;
if( rc ) break;
}
}
rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
@@ -111433,13 +110680,13 @@
pIdxInfo->needToFreeIdxStr = 0;
pNew->u.vtab.idxStr = pIdxInfo->idxStr;
pNew->u.vtab.isOrdered = (u8)((pIdxInfo->nOrderBy!=0)
&& pIdxInfo->orderByConsumed);
pNew->rSetup = 0;
- pNew->rRun = sqlite3LogEstFromDouble(pIdxInfo->estimatedCost);
+ pNew->rRun = whereCostFromDouble(pIdxInfo->estimatedCost);
/* TUNING: Every virtual table query returns 25 rows */
- pNew->nOut = 46; assert( 46==sqlite3LogEst(25) );
+ pNew->nOut = 46; assert( 46==whereCost(25) );
whereLoopInsert(pBuilder, pNew);
if( pNew->u.vtab.needFree ){
sqlite3_free(pNew->u.vtab.idxStr);
pNew->u.vtab.needFree = 0;
}
@@ -111472,12 +110719,10 @@
pWC = pBuilder->pWC;
if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
pWCEnd = pWC->a + pWC->nTerm;
pNew = pBuilder->pNew;
memset(&sSum, 0, sizeof(sSum));
- pItem = pWInfo->pTabList->a + pNew->iTab;
- iCur = pItem->iCursor;
for(pTerm=pWC->a; pTermeOperator & WO_OR)!=0
&& (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0
){
@@ -111485,10 +110730,12 @@
WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];
WhereTerm *pOrTerm;
int once = 1;
int i, j;
+ pItem = pWInfo->pTabList->a + pNew->iTab;
+ iCur = pItem->iCursor;
sSubBuild = *pBuilder;
sSubBuild.pOrderBy = 0;
sSubBuild.pOrSet = &sCur;
for(pOrTerm=pOrWC->a; pOrTermnLTerm = 1;
@@ -111864,23 +111111,20 @@
** costs if nRowEst==0.
**
** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation
** error occurs.
*/
-static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
+static int wherePathSolver(WhereInfo *pWInfo, WhereCost nRowEst){
int mxChoice; /* Maximum number of simultaneous paths tracked */
int nLoop; /* Number of terms in the join */
Parse *pParse; /* Parsing context */
sqlite3 *db; /* The database connection */
int iLoop; /* Loop counter over the terms of the join */
int ii, jj; /* Loop counters */
- int mxI = 0; /* Index of next entry to replace */
- LogEst rCost; /* Cost of a path */
- LogEst nOut; /* Number of outputs */
- LogEst mxCost = 0; /* Maximum cost of a set of paths */
- LogEst mxOut = 0; /* Maximum nOut value on the set of paths */
- LogEst rSortCost; /* Cost to do a sort */
+ WhereCost rCost; /* Cost of a path */
+ WhereCost mxCost = 0; /* Maximum cost of a set of paths */
+ WhereCost rSortCost; /* Cost to do a sort */
int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */
WherePath *aFrom; /* All nFrom paths at the previous level */
WherePath *aTo; /* The nTo best paths at the current level */
WherePath *pFrom; /* An element of aFrom[] that we are working on */
WherePath *pTo; /* An element of aTo[] that we are working on */
@@ -111913,23 +111157,21 @@
/* Seed the search with a single WherePath containing zero WhereLoops.
**
** TUNING: Do not let the number of iterations go above 25. If the cost
** of computing an automatic index is not paid back within the first 25
** rows, then do not use the automatic index. */
- aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
+ aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==whereCost(25) );
nFrom = 1;
/* Precompute the cost of sorting the final result set, if the caller
** to sqlite3WhereBegin() was concerned about sorting */
rSortCost = 0;
if( pWInfo->pOrderBy==0 || nRowEst==0 ){
aFrom[0].isOrderedValid = 1;
}else{
- /* TUNING: Estimated cost of sorting is 48*N*log2(N) where N is the
- ** number of output rows. The 48 is the expected size of a row to sort.
- ** FIXME: compute a better estimate of the 48 multiplier based on the
- ** result set expressions. */
+ /* TUNING: Estimated cost of sorting is N*log2(N) where N is the
+ ** number of output rows. */
rSortCost = nRowEst + estLog(nRowEst);
WHERETRACE(0x002,("---- sort cost=%-3d\n", rSortCost));
}
/* Compute successively longer WherePaths using the previous generation
@@ -111945,13 +111187,12 @@
u8 isOrdered = pFrom->isOrdered;
if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;
/* At this point, pWLoop is a candidate to be the next loop.
** Compute its cost */
- rCost = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
- rCost = sqlite3LogEstAdd(rCost, pFrom->rCost);
- nOut = pFrom->nRow + pWLoop->nOut;
+ rCost = whereCostAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
+ rCost = whereCostAdd(rCost, pFrom->rCost);
maskNew = pFrom->maskLoop | pWLoop->maskSelf;
if( !isOrderedValid ){
switch( wherePathSatisfiesOrderBy(pWInfo,
pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,
iLoop, pWLoop, &revMask) ){
@@ -111960,35 +111201,31 @@
isOrderedValid = 1;
break;
case 0: /* No. pFrom+pWLoop will require a separate sort */
isOrdered = 0;
isOrderedValid = 1;
- rCost = sqlite3LogEstAdd(rCost, rSortCost);
+ rCost = whereCostAdd(rCost, rSortCost);
break;
default: /* Cannot tell yet. Try again on the next iteration */
break;
}
}else{
revMask = pFrom->revLoop;
}
/* Check to see if pWLoop should be added to the mxChoice best so far */
for(jj=0, pTo=aTo; jjmaskLoop==maskNew
- && pTo->isOrderedValid==isOrderedValid
- && ((pTo->rCost<=rCost && pTo->nRow<=nOut) ||
- (pTo->rCost>=rCost && pTo->nRow>=nOut))
- ){
+ if( pTo->maskLoop==maskNew && pTo->isOrderedValid==isOrderedValid ){
testcase( jj==nTo-1 );
break;
}
}
if( jj>=nTo ){
if( nTo>=mxChoice && rCost>=mxCost ){
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace&0x4 ){
- sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n",
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
+ sqlite3DebugPrintf("Skip %s cost=%3d order=%c\n",
+ wherePathName(pFrom, iLoop, pWLoop), rCost,
isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
}
#endif
continue;
}
@@ -111996,30 +111233,30 @@
if( nTo0); }
}
pTo = &aTo[jj];
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace&0x4 ){
- sqlite3DebugPrintf("New %s cost=%-3d,%3d order=%c\n",
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
+ sqlite3DebugPrintf("New %s cost=%-3d order=%c\n",
+ wherePathName(pFrom, iLoop, pWLoop), rCost,
isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
}
#endif
}else{
- if( pTo->rCost<=rCost && pTo->nRow<=nOut ){
+ if( pTo->rCost<=rCost ){
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace&0x4 ){
sqlite3DebugPrintf(
- "Skip %s cost=%-3d,%3d order=%c",
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
+ "Skip %s cost=%-3d order=%c",
+ wherePathName(pFrom, iLoop, pWLoop), rCost,
isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
- sqlite3DebugPrintf(" vs %s cost=%-3d,%d order=%c\n",
- wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
+ sqlite3DebugPrintf(" vs %s cost=%-3d order=%c\n",
+ wherePathName(pTo, iLoop+1, 0), pTo->rCost,
pTo->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
}
#endif
testcase( pTo->rCost==rCost );
continue;
@@ -112027,38 +111264,32 @@
testcase( pTo->rCost==rCost+1 );
/* A new and better score for a previously created equivalent path */
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace&0x4 ){
sqlite3DebugPrintf(
- "Update %s cost=%-3d,%3d order=%c",
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
+ "Update %s cost=%-3d order=%c",
+ wherePathName(pFrom, iLoop, pWLoop), rCost,
isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?');
- sqlite3DebugPrintf(" was %s cost=%-3d,%3d order=%c\n",
- wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
+ sqlite3DebugPrintf(" was %s cost=%-3d order=%c\n",
+ wherePathName(pTo, iLoop+1, 0), pTo->rCost,
pTo->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
}
#endif
}
/* pWLoop is a winner. Add it to the set of best so far */
pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
pTo->revLoop = revMask;
- pTo->nRow = nOut;
+ pTo->nRow = pFrom->nRow + pWLoop->nOut;
pTo->rCost = rCost;
pTo->isOrderedValid = isOrderedValid;
pTo->isOrdered = isOrdered;
memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
pTo->aLoop[iLoop] = pWLoop;
if( nTo>=mxChoice ){
- mxI = 0;
mxCost = aTo[0].rCost;
- mxOut = aTo[0].nRow;
for(jj=1, pTo=&aTo[1]; jjrCost>mxCost || (pTo->rCost==mxCost && pTo->nRow>mxOut) ){
- mxCost = pTo->rCost;
- mxOut = pTo->nRow;
- mxI = jj;
- }
+ if( pTo->rCost>mxCost ) mxCost = pTo->rCost;
}
}
}
}
@@ -112091,13 +111322,16 @@
return SQLITE_ERROR;
}
/* Find the lowest cost path. pFrom will be left pointing to that path */
pFrom = aFrom;
+ assert( nFrom==1 );
+#if 0 /* The following is needed if nFrom is ever more than 1 */
for(ii=1; iirCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];
}
+#endif
assert( pWInfo->nLevel==nLoop );
/* Load the lowest cost path into pWInfo */
for(iLoop=0; iLoopa + iLoop;
pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];
@@ -112167,11 +111401,11 @@
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
pLoop->aLTerm[0] = pTerm;
pLoop->nLTerm = 1;
pLoop->u.btree.nEq = 1;
/* TUNING: Cost of a rowid lookup is 10 */
- pLoop->rRun = 33; /* 33==sqlite3LogEst(10) */
+ pLoop->rRun = 33; /* 33==whereCost(10) */
}else{
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
assert( pLoop->aLTermSpace==pLoop->aLTerm );
assert( ArraySize(pLoop->aLTermSpace)==4 );
if( pIdx->onError==OE_None
@@ -112190,16 +111424,16 @@
}
pLoop->nLTerm = j;
pLoop->u.btree.nEq = j;
pLoop->u.btree.pIndex = pIdx;
/* TUNING: Cost of a unique index lookup is 15 */
- pLoop->rRun = 39; /* 39==sqlite3LogEst(15) */
+ pLoop->rRun = 39; /* 39==whereCost(15) */
break;
}
}
if( pLoop->wsFlags ){
- pLoop->nOut = (LogEst)1;
+ pLoop->nOut = (WhereCost)1;
pWInfo->a[0].pWLoop = pLoop;
pLoop->maskSelf = getMask(&pWInfo->sMaskSet, iCur);
pWInfo->a[0].iTabCur = iCur;
pWInfo->nRowOut = 1;
if( pWInfo->pOrderBy ) pWInfo->bOBSat = 1;
@@ -112563,11 +111797,11 @@
WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));
pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;
/* If the caller is an UPDATE or DELETE statement that is requesting
** to use a one-pass algorithm, determine if this is appropriate.
- ** The one-pass algorithm only works if the WHERE clause constrains
+ ** The one-pass algorithm only works if the WHERE clause constraints
** the statement to update a single row.
*/
assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 );
if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
&& (pWInfo->a[0].pWLoop->wsFlags & WHERE_ONEROW)!=0 ){
@@ -115723,17 +114957,16 @@
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0);
+ yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
if( yygotominor.yy342.pExpr ){
- yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442;
+ yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122);
}
yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
@@ -121981,16 +121214,10 @@
** verifying the operation of the SQLite core.
*/
int inTransaction; /* True after xBegin but before xCommit/xRollback */
int mxSavepoint; /* Largest valid xSavepoint integer */
#endif
-
-#ifdef SQLITE_TEST
- /* True to disable the incremental doclist optimization. This is controled
- ** by special insert command 'test-no-incr-doclist'. */
- int bNoIncrDoclist;
-#endif
};
/*
** When the core wants to read from the virtual table, it creates a
** virtual table cursor (an instance of the following structure) using
@@ -122012,12 +121239,11 @@
int nDoclist; /* Size of buffer at aDoclist */
u8 bDesc; /* True to sort in descending order */
int eEvalmode; /* An FTS3_EVAL_XX constant */
int nRowAvg; /* Average size of database rows, in pages */
sqlite3_int64 nDoc; /* Documents in table */
- i64 iMinDocid; /* Minimum docid to return */
- i64 iMaxDocid; /* Maximum docid to return */
+
int isMatchinfoNeeded; /* True when aMatchinfo[] needs filling in */
u32 *aMatchinfo; /* Information about most recent match */
int nMatchinfo; /* Number of elements in aMatchinfo[] */
char *zMatchinfo; /* Matchinfo specification */
};
@@ -122043,19 +121269,10 @@
*/
#define FTS3_FULLSCAN_SEARCH 0 /* Linear scan of %_content table */
#define FTS3_DOCID_SEARCH 1 /* Lookup by rowid on %_content table */
#define FTS3_FULLTEXT_SEARCH 2 /* Full-text index search */
-/*
-** The lower 16-bits of the sqlite3_index_info.idxNum value set by
-** the xBestIndex() method contains the Fts3Cursor.eSearch value described
-** above. The upper 16-bits contain a combination of the following
-** bits, used to describe extra constraints on full-text searches.
-*/
-#define FTS3_HAVE_LANGID 0x00010000 /* languageid=? */
-#define FTS3_HAVE_DOCID_GE 0x00020000 /* docid>=? */
-#define FTS3_HAVE_DOCID_LE 0x00040000 /* docid<=? */
struct Fts3Doclist {
char *aAll; /* Array containing doclist (or NULL) */
int nAll; /* Size of a[] in bytes */
char *pNextDocid; /* Pointer to next docid */
@@ -123472,31 +122689,27 @@
*/
static int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
Fts3Table *p = (Fts3Table *)pVTab;
int i; /* Iterator variable */
int iCons = -1; /* Index of constraint to use */
-
int iLangidCons = -1; /* Index of langid=x constraint, if present */
- int iDocidGe = -1; /* Index of docid>=x constraint, if present */
- int iDocidLe = -1; /* Index of docid<=x constraint, if present */
- int iIdx;
/* By default use a full table scan. This is an expensive option,
** so search through the constraints to see if a more efficient
** strategy is possible.
*/
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
pInfo->estimatedCost = 5000000;
for(i=0; inConstraint; i++){
- int bDocid; /* True if this constraint is on docid */
struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
if( pCons->usable==0 ) continue;
- bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);
-
/* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
- if( iCons<0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && bDocid ){
+ if( iCons<0
+ && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
+ && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
+ ){
pInfo->idxNum = FTS3_DOCID_SEARCH;
pInfo->estimatedCost = 1.0;
iCons = i;
}
@@ -123521,42 +122734,18 @@
if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
&& pCons->iColumn==p->nColumn + 2
){
iLangidCons = i;
}
-
- if( bDocid ){
- switch( pCons->op ){
- case SQLITE_INDEX_CONSTRAINT_GE:
- case SQLITE_INDEX_CONSTRAINT_GT:
- iDocidGe = i;
- break;
-
- case SQLITE_INDEX_CONSTRAINT_LE:
- case SQLITE_INDEX_CONSTRAINT_LT:
- iDocidLe = i;
- break;
- }
- }
- }
-
- iIdx = 1;
+ }
+
if( iCons>=0 ){
- pInfo->aConstraintUsage[iCons].argvIndex = iIdx++;
+ pInfo->aConstraintUsage[iCons].argvIndex = 1;
pInfo->aConstraintUsage[iCons].omit = 1;
}
if( iLangidCons>=0 ){
- pInfo->idxNum |= FTS3_HAVE_LANGID;
- pInfo->aConstraintUsage[iLangidCons].argvIndex = iIdx++;
- }
- if( iDocidGe>=0 ){
- pInfo->idxNum |= FTS3_HAVE_DOCID_GE;
- pInfo->aConstraintUsage[iDocidGe].argvIndex = iIdx++;
- }
- if( iDocidLe>=0 ){
- pInfo->idxNum |= FTS3_HAVE_DOCID_LE;
- pInfo->aConstraintUsage[iDocidLe].argvIndex = iIdx++;
+ pInfo->aConstraintUsage[iLangidCons].argvIndex = 2;
}
/* Regardless of the strategy selected, FTS can deliver rows in rowid (or
** docid) order. Both ascending and descending are possible.
*/
@@ -124999,37 +124188,10 @@
}
assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
return rc;
}
-/*
-** The following are copied from sqliteInt.h.
-**
-** Constants for the largest and smallest possible 64-bit signed integers.
-** These macros are designed to work correctly on both 32-bit and 64-bit
-** compilers.
-*/
-#ifndef SQLITE_AMALGAMATION
-# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
-# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
-#endif
-
-/*
-** If the numeric type of argument pVal is "integer", then return it
-** converted to a 64-bit signed integer. Otherwise, return a copy of
-** the second parameter, iDefault.
-*/
-static sqlite3_int64 fts3DocidRange(sqlite3_value *pVal, i64 iDefault){
- if( pVal ){
- int eType = sqlite3_value_numeric_type(pVal);
- if( eType==SQLITE_INTEGER ){
- return sqlite3_value_int64(pVal);
- }
- }
- return iDefault;
-}
-
/*
** This is the xFilter interface for the virtual table. See
** the virtual table xFilter method documentation for additional
** information.
**
@@ -125051,62 +124213,44 @@
int nVal, /* Number of elements in apVal */
sqlite3_value **apVal /* Arguments for the indexing scheme */
){
int rc;
char *zSql; /* SQL statement used to access %_content */
- int eSearch;
Fts3Table *p = (Fts3Table *)pCursor->pVtab;
Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
- sqlite3_value *pCons = 0; /* The MATCH or rowid constraint, if any */
- sqlite3_value *pLangid = 0; /* The "langid = ?" constraint, if any */
- sqlite3_value *pDocidGe = 0; /* The "docid >= ?" constraint, if any */
- sqlite3_value *pDocidLe = 0; /* The "docid <= ?" constraint, if any */
- int iIdx;
-
UNUSED_PARAMETER(idxStr);
UNUSED_PARAMETER(nVal);
- eSearch = (idxNum & 0x0000FFFF);
- assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
+ assert( idxNum>=0 && idxNum<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
+ assert( nVal==0 || nVal==1 || nVal==2 );
+ assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );
assert( p->pSegments==0 );
- /* Collect arguments into local variables */
- iIdx = 0;
- if( eSearch!=FTS3_FULLSCAN_SEARCH ) pCons = apVal[iIdx++];
- if( idxNum & FTS3_HAVE_LANGID ) pLangid = apVal[iIdx++];
- if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];
- if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];
- assert( iIdx==nVal );
-
/* In case the cursor has been used before, clear it now. */
sqlite3_finalize(pCsr->pStmt);
sqlite3_free(pCsr->aDoclist);
sqlite3Fts3ExprFree(pCsr->pExpr);
memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
- /* Set the lower and upper bounds on docids to return */
- pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);
- pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);
-
if( idxStr ){
pCsr->bDesc = (idxStr[0]=='D');
}else{
pCsr->bDesc = p->bDescIdx;
}
- pCsr->eSearch = (i16)eSearch;
+ pCsr->eSearch = (i16)idxNum;
- if( eSearch!=FTS3_DOCID_SEARCH && eSearch!=FTS3_FULLSCAN_SEARCH ){
- int iCol = eSearch-FTS3_FULLTEXT_SEARCH;
- const char *zQuery = (const char *)sqlite3_value_text(pCons);
+ if( idxNum!=FTS3_DOCID_SEARCH && idxNum!=FTS3_FULLSCAN_SEARCH ){
+ int iCol = idxNum-FTS3_FULLTEXT_SEARCH;
+ const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);
- if( zQuery==0 && sqlite3_value_type(pCons)!=SQLITE_NULL ){
+ if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
return SQLITE_NOMEM;
}
pCsr->iLangid = 0;
- if( pLangid ) pCsr->iLangid = sqlite3_value_int(pLangid);
+ if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
assert( p->base.zErrMsg==0 );
rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr,
&p->base.zErrMsg
@@ -125125,11 +124269,11 @@
/* Compile a SELECT statement for this cursor. For a full-table-scan, the
** statement loops through all rows of the %_content table. For a
** full-text query or docid lookup, the statement retrieves a single
** row by docid.
*/
- if( eSearch==FTS3_FULLSCAN_SEARCH ){
+ if( idxNum==FTS3_FULLSCAN_SEARCH ){
zSql = sqlite3_mprintf(
"SELECT %s ORDER BY rowid %s",
p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
);
if( zSql ){
@@ -125136,14 +124280,14 @@
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
sqlite3_free(zSql);
}else{
rc = SQLITE_NOMEM;
}
- }else if( eSearch==FTS3_DOCID_SEARCH ){
+ }else if( idxNum==FTS3_DOCID_SEARCH ){
rc = fts3CursorSeekStmt(pCsr, &pCsr->pStmt);
if( rc==SQLITE_OK ){
- rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons);
+ rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);
}
}
if( rc!=SQLITE_OK ) return rc;
return fts3NextMethod(pCursor);
@@ -126030,16 +125174,10 @@
}
return SQLITE_OK;
}
-/*
-** Maximum number of tokens a phrase may have to be considered for the
-** incremental doclists strategy.
-*/
-#define MAX_INCR_PHRASE_TOKENS 4
-
/*
** This function is called for each Fts3Phrase in a full-text query
** expression to initialize the mechanism for returning rows. Once this
** function has been called successfully on an Fts3Phrase, it may be
** used with fts3EvalPhraseNext() to iterate through the matching docids.
@@ -126049,47 +125187,27 @@
** memory within this call.
**
** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
*/
static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){
+ int rc; /* Error code */
+ Fts3PhraseToken *pFirst = &p->aToken[0];
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
- int rc = SQLITE_OK; /* Error code */
- int i;
-
- /* Determine if doclists may be loaded from disk incrementally. This is
- ** possible if the bOptOk argument is true, the FTS doclists will be
- ** scanned in forward order, and the phrase consists of
- ** MAX_INCR_PHRASE_TOKENS or fewer tokens, none of which are are "^first"
- ** tokens or prefix tokens that cannot use a prefix-index. */
- int bHaveIncr = 0;
- int bIncrOk = (bOptOk
- && pCsr->bDesc==pTab->bDescIdx
- && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
- && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
-#ifdef SQLITE_TEST
- && pTab->bNoIncrDoclist==0
-#endif
- );
- for(i=0; bIncrOk==1 && inToken; i++){
- Fts3PhraseToken *pToken = &p->aToken[i];
- if( pToken->bFirst || (pToken->pSegcsr!=0 && !pToken->pSegcsr->bLookup) ){
- bIncrOk = 0;
- }
- if( pToken->pSegcsr ) bHaveIncr = 1;
- }
-
- if( bIncrOk && bHaveIncr ){
+
+ if( pCsr->bDesc==pTab->bDescIdx
+ && bOptOk==1
+ && p->nToken==1
+ && pFirst->pSegcsr
+ && pFirst->pSegcsr->bLookup
+ && pFirst->bFirst==0
+ ){
/* Use the incremental approach. */
int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);
- for(i=0; rc==SQLITE_OK && inToken; i++){
- Fts3PhraseToken *pToken = &p->aToken[i];
- Fts3MultiSegReader *pSegcsr = pToken->pSegcsr;
- if( pSegcsr ){
- rc = sqlite3Fts3MsrIncrStart(pTab, pSegcsr, iCol, pToken->z, pToken->n);
- }
- }
+ rc = sqlite3Fts3MsrIncrStart(
+ pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n);
p->bIncr = 1;
+
}else{
/* Load the full doclist for the phrase into memory. */
rc = fts3EvalPhraseLoad(pCsr, p);
p->bIncr = 0;
}
@@ -126194,220 +125312,10 @@
}
*ppIter = p;
}
-/*
-** Advance the iterator pDL to the next entry in pDL->aAll/nAll. Set *pbEof
-** to true if EOF is reached.
-*/
-static void fts3EvalDlPhraseNext(
- Fts3Table *pTab,
- Fts3Doclist *pDL,
- u8 *pbEof
-){
- char *pIter; /* Used to iterate through aAll */
- char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */
-
- if( pDL->pNextDocid ){
- pIter = pDL->pNextDocid;
- }else{
- pIter = pDL->aAll;
- }
-
- if( pIter>=pEnd ){
- /* We have already reached the end of this doclist. EOF. */
- *pbEof = 1;
- }else{
- sqlite3_int64 iDelta;
- pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
- if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){
- pDL->iDocid += iDelta;
- }else{
- pDL->iDocid -= iDelta;
- }
- pDL->pList = pIter;
- fts3PoslistCopy(0, &pIter);
- pDL->nList = (int)(pIter - pDL->pList);
-
- /* pIter now points just past the 0x00 that terminates the position-
- ** list for document pDL->iDocid. However, if this position-list was
- ** edited in place by fts3EvalNearTrim(), then pIter may not actually
- ** point to the start of the next docid value. The following line deals
- ** with this case by advancing pIter past the zero-padding added by
- ** fts3EvalNearTrim(). */
- while( pIterpNextDocid = pIter;
- assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );
- *pbEof = 0;
- }
-}
-
-/*
-** Helper type used by fts3EvalIncrPhraseNext() and incrPhraseTokenNext().
-*/
-typedef struct TokenDoclist TokenDoclist;
-struct TokenDoclist {
- int bIgnore;
- sqlite3_int64 iDocid;
- char *pList;
- int nList;
-};
-
-/*
-** Token pToken is an incrementally loaded token that is part of a
-** multi-token phrase. Advance it to the next matching document in the
-** database and populate output variable *p with the details of the new
-** entry. Or, if the iterator has reached EOF, set *pbEof to true.
-**
-** If an error occurs, return an SQLite error code. Otherwise, return
-** SQLITE_OK.
-*/
-static int incrPhraseTokenNext(
- Fts3Table *pTab, /* Virtual table handle */
- Fts3Phrase *pPhrase, /* Phrase to advance token of */
- int iToken, /* Specific token to advance */
- TokenDoclist *p, /* OUT: Docid and doclist for new entry */
- u8 *pbEof /* OUT: True if iterator is at EOF */
-){
- int rc = SQLITE_OK;
-
- if( pPhrase->iDoclistToken==iToken ){
- assert( p->bIgnore==0 );
- assert( pPhrase->aToken[iToken].pSegcsr==0 );
- fts3EvalDlPhraseNext(pTab, &pPhrase->doclist, pbEof);
- p->pList = pPhrase->doclist.pList;
- p->nList = pPhrase->doclist.nList;
- p->iDocid = pPhrase->doclist.iDocid;
- }else{
- Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];
- assert( pToken->pDeferred==0 );
- assert( pToken->pSegcsr || pPhrase->iDoclistToken>=0 );
- if( pToken->pSegcsr ){
- assert( p->bIgnore==0 );
- rc = sqlite3Fts3MsrIncrNext(
- pTab, pToken->pSegcsr, &p->iDocid, &p->pList, &p->nList
- );
- if( p->pList==0 ) *pbEof = 1;
- }else{
- p->bIgnore = 1;
- }
- }
-
- return rc;
-}
-
-
-/*
-** The phrase iterator passed as the second argument:
-**
-** * features at least one token that uses an incremental doclist, and
-**
-** * does not contain any deferred tokens.
-**
-** Advance it to the next matching documnent in the database and populate
-** the Fts3Doclist.pList and nList fields.
-**
-** If there is no "next" entry and no error occurs, then *pbEof is set to
-** 1 before returning. Otherwise, if no error occurs and the iterator is
-** successfully advanced, *pbEof is set to 0.
-**
-** If an error occurs, return an SQLite error code. Otherwise, return
-** SQLITE_OK.
-*/
-static int fts3EvalIncrPhraseNext(
- Fts3Cursor *pCsr, /* FTS Cursor handle */
- Fts3Phrase *p, /* Phrase object to advance to next docid */
- u8 *pbEof /* OUT: Set to 1 if EOF */
-){
- int rc = SQLITE_OK;
- Fts3Doclist *pDL = &p->doclist;
- Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
- u8 bEof = 0;
-
- /* This is only called if it is guaranteed that the phrase has at least
- ** one incremental token. In which case the bIncr flag is set. */
- assert( p->bIncr==1 );
-
- if( p->nToken==1 && p->bIncr ){
- rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr,
- &pDL->iDocid, &pDL->pList, &pDL->nList
- );
- if( pDL->pList==0 ) bEof = 1;
- }else{
- int bDescDoclist = pCsr->bDesc;
- struct TokenDoclist a[MAX_INCR_PHRASE_TOKENS];
-
- memset(a, 0, sizeof(a));
- assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
- assert( p->iDoclistTokennToken && bEof==0; i++){
- rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
- if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
- iMax = a[i].iDocid;
- bMaxSet = 1;
- }
- }
- assert( rc!=SQLITE_OK || a[p->nToken-1].bIgnore==0 );
- assert( rc!=SQLITE_OK || bMaxSet );
-
- /* Keep advancing iterators until they all point to the same document */
- for(i=0; inToken; i++){
- while( rc==SQLITE_OK && bEof==0
- && a[i].bIgnore==0 && DOCID_CMP(a[i].iDocid, iMax)<0
- ){
- rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
- if( DOCID_CMP(a[i].iDocid, iMax)>0 ){
- iMax = a[i].iDocid;
- i = 0;
- }
- }
- }
-
- /* Check if the current entries really are a phrase match */
- if( bEof==0 ){
- int nList = 0;
- int nByte = a[p->nToken-1].nList;
- char *aDoclist = sqlite3_malloc(nByte+1);
- if( !aDoclist ) return SQLITE_NOMEM;
- memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);
-
- for(i=0; i<(p->nToken-1); i++){
- if( a[i].bIgnore==0 ){
- char *pL = a[i].pList;
- char *pR = aDoclist;
- char *pOut = aDoclist;
- int nDist = p->nToken-1-i;
- int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
- if( res==0 ) break;
- nList = (int)(pOut - aDoclist);
- }
- }
- if( i==(p->nToken-1) ){
- pDL->iDocid = iMax;
- pDL->pList = aDoclist;
- pDL->nList = nList;
- pDL->bFreeList = 1;
- break;
- }
- sqlite3_free(aDoclist);
- }
- }
- }
-
- *pbEof = bEof;
- return rc;
-}
-
/*
** Attempt to move the phrase iterator to point to the next matching docid.
** If an error occurs, return an SQLite error code. Otherwise, return
** SQLITE_OK.
**
@@ -126423,18 +125331,59 @@
int rc = SQLITE_OK;
Fts3Doclist *pDL = &p->doclist;
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
if( p->bIncr ){
- rc = fts3EvalIncrPhraseNext(pCsr, p, pbEof);
+ assert( p->nToken==1 );
+ assert( pDL->pNextDocid==0 );
+ rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr,
+ &pDL->iDocid, &pDL->pList, &pDL->nList
+ );
+ if( rc==SQLITE_OK && !pDL->pList ){
+ *pbEof = 1;
+ }
}else if( pCsr->bDesc!=pTab->bDescIdx && pDL->nAll ){
sqlite3Fts3DoclistPrev(pTab->bDescIdx, pDL->aAll, pDL->nAll,
&pDL->pNextDocid, &pDL->iDocid, &pDL->nList, pbEof
);
pDL->pList = pDL->pNextDocid;
}else{
- fts3EvalDlPhraseNext(pTab, pDL, pbEof);
+ char *pIter; /* Used to iterate through aAll */
+ char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */
+ if( pDL->pNextDocid ){
+ pIter = pDL->pNextDocid;
+ }else{
+ pIter = pDL->aAll;
+ }
+
+ if( pIter>=pEnd ){
+ /* We have already reached the end of this doclist. EOF. */
+ *pbEof = 1;
+ }else{
+ sqlite3_int64 iDelta;
+ pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
+ if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){
+ pDL->iDocid += iDelta;
+ }else{
+ pDL->iDocid -= iDelta;
+ }
+ pDL->pList = pIter;
+ fts3PoslistCopy(0, &pIter);
+ pDL->nList = (int)(pIter - pDL->pList);
+
+ /* pIter now points just past the 0x00 that terminates the position-
+ ** list for document pDL->iDocid. However, if this position-list was
+ ** edited in place by fts3EvalNearTrim(), then pIter may not actually
+ ** point to the start of the next docid value. The following line deals
+ ** with this case by advancing pIter past the zero-padding added by
+ ** fts3EvalNearTrim(). */
+ while( pIterpNextDocid = pIter;
+ assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );
+ *pbEof = 0;
+ }
}
return rc;
}
@@ -126455,10 +125404,11 @@
** code before returning.
*/
static void fts3EvalStartReaders(
Fts3Cursor *pCsr, /* FTS Cursor handle */
Fts3Expr *pExpr, /* Expression to initialize phrases in */
+ int bOptOk, /* True to enable incremental loading */
int *pRc /* IN/OUT: Error code */
){
if( pExpr && SQLITE_OK==*pRc ){
if( pExpr->eType==FTSQUERY_PHRASE ){
int i;
@@ -126465,14 +125415,14 @@
int nToken = pExpr->pPhrase->nToken;
for(i=0; ipPhrase->aToken[i].pDeferred==0 ) break;
}
pExpr->bDeferred = (i==nToken);
- *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);
+ *pRc = fts3EvalPhraseStart(pCsr, bOptOk, pExpr->pPhrase);
}else{
- fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);
- fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);
+ fts3EvalStartReaders(pCsr, pExpr->pLeft, bOptOk, pRc);
+ fts3EvalStartReaders(pCsr, pExpr->pRight, bOptOk, pRc);
pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
}
}
}
@@ -126710,11 +125660,11 @@
/* Set nLoad4 to the value of (4^nOther) for the next iteration of the
** for-loop. Except, limit the value to 2^24 to prevent it from
** overflowing the 32-bit integer it is stored in. */
if( ii<12 ) nLoad4 = nLoad4*4;
- if( ii==0 || (pTC->pPhrase->nToken>1 && ii!=nToken-1) ){
+ if( ii==0 || pTC->pPhrase->nToken>1 ){
/* Either this is the cheapest token in the entire query, or it is
** part of a multi-token phrase. Either way, the entire doclist will
** (eventually) be loaded into memory. It may as well be now. */
Fts3PhraseToken *pToken = pTC->pToken;
int nList = 0;
@@ -126790,11 +125740,11 @@
sqlite3_free(aTC);
}
}
#endif
- fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);
+ fts3EvalStartReaders(pCsr, pCsr->pExpr, 1, &rc);
return rc;
}
/*
** Invalidate the current position list for phrase pPhrase.
@@ -127273,20 +126223,10 @@
pCsr->isRequireSeek = 1;
pCsr->isMatchinfoNeeded = 1;
pCsr->iPrevId = pExpr->iDocid;
}while( pCsr->isEof==0 && fts3EvalTestDeferredAndNear(pCsr, &rc) );
}
-
- /* Check if the cursor is past the end of the docid range specified
- ** by Fts3Cursor.iMinDocid/iMaxDocid. If so, set the EOF flag. */
- if( rc==SQLITE_OK && (
- (pCsr->bDesc==0 && pCsr->iPrevId>pCsr->iMaxDocid)
- || (pCsr->bDesc!=0 && pCsr->iPrevIdiMinDocid)
- )){
- pCsr->isEof = 1;
- }
-
return rc;
}
/*
** Restart interation for expression pExpr so that the next call to
@@ -127306,20 +126246,16 @@
Fts3Phrase *pPhrase = pExpr->pPhrase;
if( pPhrase ){
fts3EvalInvalidatePoslist(pPhrase);
if( pPhrase->bIncr ){
- int i;
- for(i=0; inToken; i++){
- Fts3PhraseToken *pToken = &pPhrase->aToken[i];
- assert( pToken->pDeferred==0 );
- if( pToken->pSegcsr ){
- sqlite3Fts3MsrIncrRestart(pToken->pSegcsr);
- }
- }
+ assert( pPhrase->nToken==1 );
+ assert( pPhrase->aToken[0].pSegcsr );
+ sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr);
*pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);
}
+
pPhrase->doclist.pNextDocid = 0;
pPhrase->doclist.iDocid = 0;
}
pExpr->iDocid = 0;
@@ -127564,27 +126500,19 @@
iDocid = pExpr->iDocid;
pIter = pPhrase->doclist.pList;
if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
- int iMul; /* +1 if csr dir matches index dir, else -1 */
int bOr = 0;
u8 bEof = 0;
- u8 bTreeEof = 0;
- Fts3Expr *p; /* Used to iterate from pExpr to root */
- Fts3Expr *pNear; /* Most senior NEAR ancestor (or pExpr) */
+ Fts3Expr *p;
/* Check if this phrase descends from an OR expression node. If not,
** return NULL. Otherwise, the entry that corresponds to docid
- ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the
- ** tree that the node is part of has been marked as EOF, but the node
- ** itself is not EOF, then it may point to an earlier entry. */
- pNear = pExpr;
+ ** pCsr->iPrevId may lie earlier in the doclist buffer. */
for(p=pExpr->pParent; p; p=p->pParent){
if( p->eType==FTSQUERY_OR ) bOr = 1;
- if( p->eType==FTSQUERY_NEAR ) pNear = p;
- if( p->bEof ) bTreeEof = 1;
}
if( bOr==0 ) return SQLITE_OK;
/* This is the descendent of an OR node. In this case we cannot use
** an incremental phrase. Load the entire doclist for the phrase
@@ -127599,63 +126527,33 @@
}
pIter = pPhrase->doclist.pList;
assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
if( rc!=SQLITE_OK ) return rc;
}
-
- iMul = ((pCsr->bDesc==bDescDoclist) ? 1 : -1);
- while( bTreeEof==1
- && pNear->bEof==0
- && (DOCID_CMP(pNear->iDocid, pCsr->iPrevId) * iMul)<0
- ){
- int rc = SQLITE_OK;
- fts3EvalNextRow(pCsr, pExpr, &rc);
- if( rc!=SQLITE_OK ) return rc;
- iDocid = pExpr->iDocid;
- pIter = pPhrase->doclist.pList;
- }
-
+
+ if( pExpr->bEof ){
+ pIter = 0;
+ iDocid = 0;
+ }
bEof = (pPhrase->doclist.nAll==0);
assert( bDescDoclist==0 || bDescDoclist==1 );
assert( pCsr->bDesc==0 || pCsr->bDesc==1 );
- if( bEof==0 ){
- if( pCsr->bDesc==bDescDoclist ){
- int dummy;
- if( pNear->bEof ){
- /* This expression is already at EOF. So position it to point to the
- ** last entry in the doclist at pPhrase->doclist.aAll[]. Variable
- ** iDocid is already set for this entry, so all that is required is
- ** to set pIter to point to the first byte of the last position-list
- ** in the doclist.
- **
- ** It would also be correct to set pIter and iDocid to zero. In
- ** this case, the first call to sqltie3Fts4DoclistPrev() below
- ** would also move the iterator to point to the last entry in the
- ** doclist. However, this is expensive, as to do so it has to
- ** iterate through the entire doclist from start to finish (since
- ** it does not know the docid for the last entry). */
- pIter = &pPhrase->doclist.aAll[pPhrase->doclist.nAll-1];
- fts3ReversePoslist(pPhrase->doclist.aAll, &pIter);
- }
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
- sqlite3Fts3DoclistPrev(
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
- &pIter, &iDocid, &dummy, &bEof
- );
- }
- }else{
- if( pNear->bEof ){
- pIter = 0;
- iDocid = 0;
- }
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
- sqlite3Fts3DoclistNext(
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
- &pIter, &iDocid, &bEof
- );
- }
+ if( pCsr->bDesc==bDescDoclist ){
+ int dummy;
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
+ sqlite3Fts3DoclistPrev(
+ bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
+ &pIter, &iDocid, &dummy, &bEof
+ );
+ }
+ }else{
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
+ sqlite3Fts3DoclistNext(
+ bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
+ &pIter, &iDocid, &bEof
+ );
}
}
if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;
}
@@ -127759,11 +126657,10 @@
sqlite3_vtab_cursor base; /* Base class used by SQLite core */
Fts3MultiSegReader csr; /* Must be right after "base" */
Fts3SegFilter filter;
char *zStop;
int nStop; /* Byte-length of string zStop */
- int iLangid; /* Language id to query */
int isEof; /* True if cursor is at EOF */
sqlite3_int64 iRowid; /* Current rowid */
int iCol; /* Current value of 'col' column */
int nStat; /* Size of aStat[] array */
@@ -127774,12 +126671,11 @@
};
/*
** Schema of the terms table.
*/
-#define FTS3_AUX_SCHEMA \
- "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
+#define FTS3_TERMS_SCHEMA "CREATE TABLE x(term, col, documents, occurrences)"
/*
** This function does all the work for both the xConnect and xCreate methods.
** These tables have no persistent representation of their own, so xConnect
** and xCreate are identical operations.
@@ -127822,11 +126718,11 @@
}else{
zFts3 = argv[3];
}
nFts3 = (int)strlen(zFts3);
- rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);
+ rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
if( rc!=SQLITE_OK ) return rc;
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
p = (Fts3auxTable *)sqlite3_malloc(nByte);
if( !p ) return SQLITE_NOMEM;
@@ -127882,12 +126778,10 @@
){
int i;
int iEq = -1;
int iGe = -1;
int iLe = -1;
- int iLangid = -1;
- int iNext = 1; /* Next free argvIndex value */
UNUSED_PARAMETER(pVTab);
/* This vtab delivers always results in "ORDER BY term ASC" order. */
if( pInfo->nOrderBy==1
@@ -127895,52 +126789,40 @@
&& pInfo->aOrderBy[0].desc==0
){
pInfo->orderByConsumed = 1;
}
- /* Search for equality and range constraints on the "term" column.
- ** And equality constraints on the hidden "languageid" column. */
+ /* Search for equality and range constraints on the "term" column. */
for(i=0; inConstraint; i++){
- if( pInfo->aConstraint[i].usable ){
+ if( pInfo->aConstraint[i].usable && pInfo->aConstraint[i].iColumn==0 ){
int op = pInfo->aConstraint[i].op;
- int iCol = pInfo->aConstraint[i].iColumn;
-
- if( iCol==0 ){
- if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
- if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
- if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
- if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
- if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
- }
- if( iCol==4 ){
- if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;
- }
+ if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
+ if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
+ if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
+ if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
+ if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
}
}
if( iEq>=0 ){
pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;
- pInfo->aConstraintUsage[iEq].argvIndex = iNext++;
+ pInfo->aConstraintUsage[iEq].argvIndex = 1;
pInfo->estimatedCost = 5;
}else{
pInfo->idxNum = 0;
pInfo->estimatedCost = 20000;
if( iGe>=0 ){
pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;
- pInfo->aConstraintUsage[iGe].argvIndex = iNext++;
+ pInfo->aConstraintUsage[iGe].argvIndex = 1;
pInfo->estimatedCost /= 2;
}
if( iLe>=0 ){
pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;
- pInfo->aConstraintUsage[iLe].argvIndex = iNext++;
+ pInfo->aConstraintUsage[iLe].argvIndex = 1 + (iGe>=0);
pInfo->estimatedCost /= 2;
}
}
- if( iLangid>=0 ){
- pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;
- pInfo->estimatedCost--;
- }
return SQLITE_OK;
}
/*
@@ -128096,42 +126978,21 @@
sqlite3_value **apVal /* Arguments for the indexing scheme */
){
Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;
Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;
int rc;
- int isScan = 0;
- int iLangVal = 0; /* Language id to query */
-
- int iEq = -1; /* Index of term=? value in apVal */
- int iGe = -1; /* Index of term>=? value in apVal */
- int iLe = -1; /* Index of term<=? value in apVal */
- int iLangid = -1; /* Index of languageid=? value in apVal */
- int iNext = 0;
+ int isScan;
UNUSED_PARAMETER(nVal);
UNUSED_PARAMETER(idxStr);
assert( idxStr==0 );
assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0
|| idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT
|| idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)
);
-
- if( idxNum==FTS4AUX_EQ_CONSTRAINT ){
- iEq = iNext++;
- }else{
- isScan = 1;
- if( idxNum & FTS4AUX_GE_CONSTRAINT ){
- iGe = iNext++;
- }
- if( idxNum & FTS4AUX_LE_CONSTRAINT ){
- iLe = iNext++;
- }
- }
- if( iNextfilter.zTerm);
sqlite3Fts3SegReaderFinish(&pCsr->csr);
sqlite3_free((void *)pCsr->filter.zTerm);
@@ -128139,39 +127000,26 @@
memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
- if( iEq>=0 || iGe>=0 ){
+ if( idxNum&(FTS4AUX_EQ_CONSTRAINT|FTS4AUX_GE_CONSTRAINT) ){
const unsigned char *zStr = sqlite3_value_text(apVal[0]);
- assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
if( zStr ){
pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
}
}
-
- if( iLe>=0 ){
- pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
- pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
+ if( idxNum&FTS4AUX_LE_CONSTRAINT ){
+ int iIdx = (idxNum&FTS4AUX_GE_CONSTRAINT) ? 1 : 0;
+ pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iIdx]));
+ pCsr->nStop = sqlite3_value_bytes(apVal[iIdx]);
if( pCsr->zStop==0 ) return SQLITE_NOMEM;
}
-
- if( iLangid>=0 ){
- iLangVal = sqlite3_value_int(apVal[iLangid]);
-
- /* If the user specified a negative value for the languageid, use zero
- ** instead. This works, as the "languageid=?" constraint will also
- ** be tested by the VDBE layer. The test will always be false (since
- ** this module will not return a row with a negative languageid), and
- ** so the overall query will return zero rows. */
- if( iLangVal<0 ) iLangVal = 0;
- }
- pCsr->iLangid = iLangVal;
-
- rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,
+
+ rc = sqlite3Fts3SegReaderCursor(pFts3, 0, 0, FTS3_SEGCURSOR_ALL,
pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr
);
if( rc==SQLITE_OK ){
rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
}
@@ -128191,41 +127039,28 @@
/*
** xColumn - Return a column value.
*/
static int fts3auxColumnMethod(
sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */
- sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */
+ sqlite3_context *pContext, /* Context for sqlite3_result_xxx() calls */
int iCol /* Index of column to read value from */
){
Fts3auxCursor *p = (Fts3auxCursor *)pCursor;
assert( p->isEof==0 );
- switch( iCol ){
- case 0: /* term */
- sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
- break;
-
- case 1: /* col */
- if( p->iCol ){
- sqlite3_result_int(pCtx, p->iCol-1);
- }else{
- sqlite3_result_text(pCtx, "*", -1, SQLITE_STATIC);
- }
- break;
-
- case 2: /* documents */
- sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);
- break;
-
- case 3: /* occurrences */
- sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);
- break;
-
- default: /* languageid */
- assert( iCol==4 );
- sqlite3_result_int(pCtx, p->iLangid);
- break;
+ if( iCol==0 ){ /* Column "term" */
+ sqlite3_result_text(pContext, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
+ }else if( iCol==1 ){ /* Column "col" */
+ if( p->iCol ){
+ sqlite3_result_int(pContext, p->iCol-1);
+ }else{
+ sqlite3_result_text(pContext, "*", -1, SQLITE_STATIC);
+ }
+ }else if( iCol==2 ){ /* Column "documents" */
+ sqlite3_result_int64(pContext, p->aStat[p->iCol].nDoc);
+ }else{ /* Column "occurrences" */
+ sqlite3_result_int64(pContext, p->aStat[p->iCol].nOcc);
}
return SQLITE_OK;
}
@@ -136552,11 +135387,11 @@
assert( p->bFts4==0 );
sqlite3Fts3CreateStatTable(&rc, p);
if( rc ) return rc;
}
rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
- if( rc ) return rc;
+ if( rc ) return rc;;
sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);
sqlite3_step(pStmt);
rc = sqlite3_reset(pStmt);
return rc;
@@ -136822,13 +135657,10 @@
p->nNodeSize = atoi(&zVal[9]);
rc = SQLITE_OK;
}else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
p->nMaxPendingData = atoi(&zVal[11]);
rc = SQLITE_OK;
- }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, "test-no-incr-doclist=", 21) ){
- p->bNoIncrDoclist = atoi(&zVal[21]);
- rc = SQLITE_OK;
#endif
}else{
rc = SQLITE_ERROR;
}
Index: SQLite.Interop/src/core/sqlite3.h
==================================================================
--- SQLite.Interop/src/core/sqlite3.h
+++ SQLite.Interop/src/core/sqlite3.h
@@ -107,11 +107,11 @@
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.8.1"
#define SQLITE_VERSION_NUMBER 3008001
-#define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
+#define SQLITE_SOURCE_ID "2013-09-12 02:09:05 75a8a8c1b39725d36db627536d0c69401f8e0815"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version, sqlite3_sourceid
**
@@ -1615,31 +1615,31 @@
** supplied by the application must not invoke any SQLite interface.
** In a multi-threaded application, the application-defined logger
** function must be threadsafe.
**
** [[SQLITE_CONFIG_URI]] SQLITE_CONFIG_URI
-** ^(This option takes a single argument of type int. If non-zero, then
+** This option takes a single argument of type int. If non-zero, then
** URI handling is globally enabled. If the parameter is zero, then URI handling
-** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
+** is globally disabled. If URI handling is globally enabled, all filenames
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
-** connection is opened. ^If it is globally disabled, filenames are
+** connection is opened. If it is globally disabled, filenames are
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
-** database connection is opened. ^(By default, URI handling is globally
+** database connection is opened. By default, URI handling is globally
** disabled. The default value may be changed by compiling with the
-** [SQLITE_USE_URI] symbol defined.)^
+** [SQLITE_USE_URI] symbol defined.
**
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] SQLITE_CONFIG_COVERING_INDEX_SCAN
-** ^This option takes a single integer argument which is interpreted as
+** This option takes a single integer argument which is interpreted as
** a boolean in order to enable or disable the use of covering indices for
-** full table scans in the query optimizer. ^The default setting is determined
+** full table scans in the query optimizer. The default setting is determined
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
** if that compile-time option is omitted.
** The ability to disable the use of covering indices for full table scans
** is because some incorrectly coded legacy applications might malfunction
-** when the optimization is enabled. Providing the ability to
+** malfunction when the optimization is enabled. Providing the ability to
** disable the optimization allows the older, buggy application code to work
** without change even with newer versions of SQLite.
**
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
** SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
** configuration option can be seen in the "test_sqllog.c" source file in
** the canonical SQLite source tree.
**
** [[SQLITE_CONFIG_MMAP_SIZE]]
** SQLITE_CONFIG_MMAP_SIZE
-** ^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
+** SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
** that are the default mmap size limit (the default setting for
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
-** ^The default setting can be overridden by each database connection using
+** The default setting can be overridden by each database connection using
** either the [PRAGMA mmap_size] command, or by using the
-** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
+** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
** cannot be changed at run-time. Nor may the maximum allowed mmap size
** exceed the compile-time maximum mmap size set by the
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
-** ^If either argument to this option is negative, then that argument is
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.
+** If either argument to this option is negative, then that argument is
** changed to its compile-time default.
**
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
DELETED SQLite.Interop/src/ext/totype.c
Index: SQLite.Interop/src/ext/totype.c
==================================================================
--- SQLite.Interop/src/ext/totype.c
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
-** 2013-10-14
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-******************************************************************************
-**
-** This SQLite extension implements functions tointeger(X) and toreal(X).
-**
-** If X is an integer, real, or string value that can be
-** losslessly represented as an integer, then tointeger(X)
-** returns the corresponding integer value.
-** If X is an 8-byte BLOB then that blob is interpreted as
-** a signed two-compliment little-endian encoding of an integer
-** and tointeger(X) returns the corresponding integer value.
-** Otherwise tointeger(X) return NULL.
-**
-** If X is an integer, real, or string value that can be
-** convert into a real number, preserving at least 15 digits
-** of precision, then toreal(X) returns the corresponding real value.
-** If X is an 8-byte BLOB then that blob is interpreted as
-** a 64-bit IEEE754 big-endian floating point value
-** and toreal(X) returns the corresponding real value.
-** Otherwise toreal(X) return NULL.
-**
-** Note that tointeger(X) of an 8-byte BLOB assumes a little-endian
-** encoding whereas toreal(X) of an 8-byte BLOB assumes a big-endian
-** encoding.
-*/
-#include "sqlite3ext.h"
-SQLITE_EXTENSION_INIT1
-#include
-#include
-
-/*
-** Determine if this is running on a big-endian or little-endian
-** processor
-*/
-#if defined(i386) || defined(__i386__) || defined(_M_IX86)\
- || defined(__x86_64) || defined(__x86_64__)
-# define TOTYPE_BIGENDIAN 0
-# define TOTYPE_LITTLEENDIAN 1
-#else
- const int totype_one = 1;
-# define TOTYPE_BIGENDIAN (*(char *)(&totype_one)==0)
-# define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1)
-#endif
-
-/*
-** Constants for the largest and smallest possible 64-bit signed integers.
-** These macros are designed to work correctly on both 32-bit and 64-bit
-** compilers.
-*/
-#ifndef LARGEST_INT64
-# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
-#endif
-
-#ifndef SMALLEST_INT64
-# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
-#endif
-
-/*
-** Return TRUE if character c is a whitespace character
-*/
-static int totypeIsspace(unsigned char c){
- return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f' || c=='\r';
-}
-
-/*
-** Return TRUE if character c is a digit
-*/
-static int totypeIsdigit(unsigned char c){
- return c>='0' && c<='9';
-}
-
-/*
-** Compare the 19-character string zNum against the text representation
-** value 2^63: 9223372036854775808. Return negative, zero, or positive
-** if zNum is less than, equal to, or greater than the string.
-** Note that zNum must contain exactly 19 characters.
-**
-** Unlike memcmp() this routine is guaranteed to return the difference
-** in the values of the last digit if the only difference is in the
-** last digit. So, for example,
-**
-** totypeCompare2pow63("9223372036854775800")
-**
-** will return -8.
-*/
-static int totypeCompare2pow63(const char *zNum){
- int c = 0;
- int i;
- /* 012345678901234567 */
- const char *pow63 = "922337203685477580";
- for(i=0; c==0 && i<18; i++){
- c = (zNum[i]-pow63[i])*10;
- }
- if( c==0 ){
- c = zNum[18] - '8';
- }
- return c;
-}
-
-/*
-** Convert zNum to a 64-bit signed integer.
-**
-** If the zNum value is representable as a 64-bit twos-complement
-** integer, then write that value into *pNum and return 0.
-**
-** If zNum is exactly 9223372036854665808, return 2. This special
-** case is broken out because while 9223372036854665808 cannot be a
-** signed 64-bit integer, its negative -9223372036854665808 can be.
-**
-** If zNum is too big for a 64-bit integer and is not
-** 9223372036854665808 or if zNum contains any non-numeric text,
-** then return 1.
-**
-** The string is not necessarily zero-terminated.
-*/
-static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){
- sqlite3_uint64 u = 0;
- int neg = 0; /* assume positive */
- int i;
- int c = 0;
- int nonNum = 0;
- const char *zStart;
- const char *zEnd = zNum + length;
-
- while( zNum='0' && c<='9'; i++){
- u = u*10 + c - '0';
- }
- if( u>LARGEST_INT64 ){
- *pNum = SMALLEST_INT64;
- }else if( neg ){
- *pNum = -(sqlite3_int64)u;
- }else{
- *pNum = (sqlite3_int64)u;
- }
- if( (c!=0 && &zNum[i]19 || nonNum ){
- /* zNum is empty or contains non-numeric text or is longer
- ** than 19 digits (thus guaranteeing that it is too large) */
- return 1;
- }else if( i<19 ){
- /* Less than 19 digits, so we know that it fits in 64 bits */
- assert( u<=LARGEST_INT64 );
- return 0;
- }else{
- /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */
- c = totypeCompare2pow63(zNum);
- if( c<0 ){
- /* zNum is less than 9223372036854775808 so it fits */
- assert( u<=LARGEST_INT64 );
- return 0;
- }else if( c>0 ){
- /* zNum is greater than 9223372036854775808 so it overflows */
- return 1;
- }else{
- /* zNum is exactly 9223372036854775808. Fits if negative. The
- ** special case 2 overflow if positive */
- assert( u-1==LARGEST_INT64 );
- assert( (*pNum)==SMALLEST_INT64 );
- return neg ? 0 : 2;
- }
- }
-}
-
-/*
-** The string z[] is an text representation of a real number.
-** Convert this string to a double and write it into *pResult.
-**
-** The string is not necessarily zero-terminated.
-**
-** Return TRUE if the result is a valid real number (or integer) and FALSE
-** if the string is empty or contains extraneous text. Valid numbers
-** are in one of these formats:
-**
-** [+-]digits[E[+-]digits]
-** [+-]digits.[digits][E[+-]digits]
-** [+-].digits[E[+-]digits]
-**
-** Leading and trailing whitespace is ignored for the purpose of determining
-** validity.
-**
-** If some prefix of the input string is a valid number, this routine
-** returns FALSE but it still converts the prefix and writes the result
-** into *pResult.
-*/
-static int totypeAtoF(const char *z, double *pResult, int length){
- const char *zEnd = z + length;
- /* sign * significand * (10 ^ (esign * exponent)) */
- int sign = 1; /* sign of significand */
- sqlite3_int64 s = 0; /* significand */
- int d = 0; /* adjust exponent for shifting decimal point */
- int esign = 1; /* sign of exponent */
- int e = 0; /* exponent */
- int eValid = 1; /* True exponent is either not used or is well-formed */
- double result;
- int nDigits = 0;
- int nonNum = 0;
-
- *pResult = 0.0; /* Default return value, in case of an error */
-
- /* skip leading spaces */
- while( z=zEnd ) return 0;
-
- /* get sign of significand */
- if( *z=='-' ){
- sign = -1;
- z++;
- }else if( *z=='+' ){
- z++;
- }
-
- /* skip leading zeroes */
- while( z=zEnd ) goto totype_atof_calc;
-
- /* if decimal point is present */
- if( *z=='.' ){
- z++;
- /* copy digits from after decimal to significand
- ** (decrease exponent by d to shift decimal right) */
- while( z=zEnd ) goto totype_atof_calc;
-
- /* if exponent is present */
- if( *z=='e' || *z=='E' ){
- z++;
- eValid = 0;
- if( z>=zEnd ) goto totype_atof_calc;
- /* get sign of exponent */
- if( *z=='-' ){
- esign = -1;
- z++;
- }else if( *z=='+' ){
- z++;
- }
- /* copy digits to exponent */
- while( z0 ){
- while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;
- }else{
- while( !(s%10) && e>0 ) e--,s/=10;
- }
-
- /* adjust the sign of significand */
- s = sign<0 ? -s : s;
-
- /* if exponent, scale significand as appropriate
- ** and store in result. */
- if( e ){
- double scale = 1.0;
- /* attempt to handle extremely small/large numbers better */
- if( e>307 && e<342 ){
- while( e%308 ) { scale *= 1.0e+1; e -= 1; }
- if( esign<0 ){
- result = s / scale;
- result /= 1.0e+308;
- }else{
- result = s * scale;
- result *= 1.0e+308;
- }
- }else if( e>=342 ){
- if( esign<0 ){
- result = 0.0*s;
- }else{
- result = 1e308*1e308*s; /* Infinity */
- }
- }else{
- /* 1.0e+22 is the largest power of 10 than can be
- ** represented exactly. */
- while( e%22 ) { scale *= 1.0e+1; e -= 1; }
- while( e>0 ) { scale *= 1.0e+22; e -= 22; }
- if( esign<0 ){
- result = s / scale;
- }else{
- result = s * scale;
- }
- }
- } else {
- result = (double)s;
- }
- }
-
- /* store the result */
- *pResult = result;
-
- /* return true if number and no extra non-whitespace chracters after */
- return z>=zEnd && nDigits>0 && eValid && nonNum==0;
-}
-
-/*
-** tointeger(X): If X is any value (integer, double, blob, or string) that
-** can be losslessly converted into an integer, then make the conversion and
-** return the result. Otherwise, return NULL.
-*/
-static void tointegerFunc(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- assert( argc==1 );
- (void)argc;
- switch( sqlite3_value_type(argv[0]) ){
- case SQLITE_FLOAT: {
- double rVal = sqlite3_value_double(argv[0]);
- sqlite3_int64 iVal = (sqlite3_int64)rVal;
- if( rVal==(double)iVal ){
- sqlite3_result_int64(context, iVal);
- }
- break;
- }
- case SQLITE_INTEGER: {
- sqlite3_result_int64(context, sqlite3_value_int64(argv[0]));
- break;
- }
- case SQLITE_BLOB: {
- const unsigned char *zBlob = sqlite3_value_blob(argv[0]);
- if( zBlob ){
- int nBlob = sqlite3_value_bytes(argv[0]);
- if( nBlob==sizeof(sqlite3_int64) ){
- sqlite3_int64 iVal;
- if( TOTYPE_BIGENDIAN ){
- int i;
- unsigned char zBlobRev[sizeof(sqlite3_int64)];
- for(i=0; i= 3004001
#include "../ext/vtshim.c"
#endif
-#if defined(INTEROP_TOTYPE_EXTENSION)
-#include "../ext/totype.c"
-#endif
-
#if defined(INTEROP_EXTENSION_FUNCTIONS)
#include "../contrib/extension-functions.c"
extern int RegisterExtensionFunctions(sqlite3 *db);
#endif
@@ -25,12 +21,10 @@
#ifdef SQLITE_OS_WIN
#if defined(INTEROP_CODEC)
#include "crypt.c"
#endif
-#include "interop.h"
-
#define INTEROP_DEBUG_NONE (0x0000)
#define INTEROP_DEBUG_CLOSE (0x0001)
#define INTEROP_DEBUG_FINALIZE (0x0002)
#define INTEROP_DEBUG_BACKUP_FINISH (0x0004)
#define INTEROP_DEBUG_OPEN (0x0008)
@@ -221,20 +215,10 @@
}
return ret;
}
#endif
-SQLITE_API const char *sqlite3_libversion_interop(void)
-{
- return INTEROP_VERSION;
-}
-
-SQLITE_API const char *sqlite3_sourceid_interop(void)
-{
- return INTEROP_SOURCE_ID " " INTEROP_SOURCE_TIMESTAMP;
-}
-
SQLITE_API int WINAPI sqlite3_open_interop(const char *filename, int flags, sqlite3 **ppdb)
{
int ret;
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
Index: SQLite.Interop/src/win/interop.h
==================================================================
--- SQLite.Interop/src/win/interop.h
+++ SQLite.Interop/src/win/interop.h
@@ -4,15 +4,7 @@
* Written by Joe Mistachkin.
* Released to the public domain, use at your own risk!
*/
#ifndef INTEROP_VERSION
-#define INTEROP_VERSION "1.0.89.0"
-#endif
-
-#ifndef INTEROP_SOURCE_ID
-#define INTEROP_SOURCE_ID "0000000000000000000000000000000000000000"
-#endif
-
-#ifndef INTEROP_SOURCE_TIMESTAMP
-#define INTEROP_SOURCE_TIMESTAMP "0000-00-00 00:00:00 UTC"
+#define INTEROP_VERSION "1.0.89.0"
#endif
Index: Setup/build.bat
==================================================================
--- Setup/build.bat
+++ Setup/build.bat
@@ -246,32 +246,10 @@
SET LOGGING="/logger:FileLogger,Microsoft.Build.Engine;Logfile=%LOGDIR%\%LOGPREFIX%_%CONFIGURATION%_%PLATFORM%_%YEAR%_%LOGSUFFIX%.log;Verbosity=diagnostic"
:skip_setLogging
-IF NOT DEFINED NOTAG (
- IF EXIST Externals\Eagle\bin\EagleShell.exe (
- %__ECHO% Externals\Eagle\bin\EagleShell.exe -file Setup\sourceTag.eagle SourceIdMode SQLite.Interop\src\win\interop.h
-
- IF ERRORLEVEL 1 (
- ECHO Source tagging of "SQLite.Interop\src\win\interop.h" failed.
- GOTO errors
- )
-
- %__ECHO% Externals\Eagle\bin\EagleShell.exe -file Setup\sourceTag.eagle SourceIdMode System.Data.SQLite\SQLitePatchLevel.cs
-
- IF ERRORLEVEL 1 (
- ECHO Source tagging of "System.Data.SQLite\SQLitePatchLevel.cs" failed.
- GOTO errors
- )
- ) ELSE (
- ECHO WARNING: Source tagging skipped, Eagle binaries are not available.
- )
-) ELSE (
- ECHO WARNING: Source tagging skipped, disabled via NOTAG environment variable.
-)
-
%_VECHO% Logging = '%LOGGING%'
%_VECHO% MsBuildArgs = '%MSBUILD_ARGS%'
%__ECHO% MSBuild.exe "%SOLUTION%" "/target:%TARGET%" "/property:Configuration=%CONFIGURATION%" "/property:Platform=%PLATFORM%" %LOGGING% %MSBUILD_ARGS%
DELETED Setup/sourceTag.eagle
Index: Setup/sourceTag.eagle
==================================================================
--- Setup/sourceTag.eagle
+++ /dev/null
@@ -1,145 +0,0 @@
-###############################################################################
-#
-# sourceTag.eagle -- Source Version Tag Tool
-#
-# Written by Joe Mistachkin.
-# Released to the public domain, use at your own risk!
-#
-###############################################################################
-
-package require Eagle
-
-proc usage { error } {
- if {[string length $error] > 0} then {puts stdout $error}
-
- puts stdout "usage:\
-[file tail [info nameofexecutable]]\
-[file tail [info script]] "
-
- #
- # NOTE: Indicate to the caller, if any, that we have failed.
- #
- exit 1
-}
-
-set modes [list \"SourceIdMode\"]
-set argc [llength $argv]
-
-if {$argc == 2} then {
- #
- # NOTE: Are we updating the "PatchLevel.cs" file?
- #
- set mode [lindex $argv 0]
-
- if {[string length $mode] > 0} then {
- #
- # NOTE: Get the file name to read/update/write.
- #
- set fileName [lindex $argv 1]
-
- #
- # NOTE: Make sure the file name provided is not obviously
- # invalid.
- #
- if {[string length $fileName] > 0} then {
- #
- # NOTE: Read all the data out of the text file.
- #
- set data [readFile $fileName]
-
- #
- # NOTE: Normalize to Unix line-endings.
- #
- set data [string map [list \r\n \n] $data]; # Unix.
-
- #
- # NOTE: Figure out what mode we are in.
- #
- switch -exact -nocase -- $mode {
- SourceIdMode {
- #
- # NOTE: Query the source identifier from Fossil, if available.
- # If we are not within an active checkout, this will fail.
- #
- set pattern {^checkout:\s+([^\s]+)\s+(.*)\s+$}
-
- if {[catch {set exec [exec -success Success -directory \
- [file dirname $fileName] -- fossil info]}] || \
- [regexp -line -- $pattern $exec dummy id timeStamp] == 0} then {
- #
- # NOTE: We could not query the source identifier(s); therefore,
- # use obviously invalid ones. We would also be able to
- # use null values here except that these values end up in
- # native C header files as well (i.e. not just managed
- # assembly attribute values).
- #
- set id 0000000000000000000000000000000000000000
- set timeStamp "0000-00-00 00:00:00 UTC"
- }
-
- #
- # NOTE: Match against this pattern in the "PatchLevel.cs"
- # file (this pattern is fairly strict to prevent
- # false-positives).
- #
- set pattern1 {AssemblySourceId\(.*?\)}
- set pattern2 {AssemblySourceTimeStamp\(.*?\)}
- set pattern3 {INTEROP_SOURCE_ID\s+".*?"}
- set pattern4 {INTEROP_SOURCE_TIMESTAMP\s+".*?"}
-
- #
- # NOTE: Build the final replacement specification string.
- #
- set subSpec1 [appendArgs AssemblySourceId(\" $id \" )]
- set subSpec2 [appendArgs AssemblySourceTimeStamp(\" $timeStamp \" )]
- set subSpec3 [appendArgs INTEROP_SOURCE_ID " \"" $id \"]
- set subSpec4 [appendArgs INTEROP_SOURCE_TIMESTAMP " \"" $timeStamp \"]
-
- #
- # NOTE: Perform the replacements in the original data
- # (first match only).
- #
- set count 0
-
- incr count [regsub -nocase -- $pattern1 $data $subSpec1 data]
- incr count [regsub -nocase -- $pattern2 $data $subSpec2 data]
- incr count [regsub -nocase -- $pattern3 $data $subSpec3 data]
- incr count [regsub -nocase -- $pattern4 $data $subSpec4 data]
-
- #
- # NOTE: If we actually replaced anything, we need to write back
- # to the original file; otherwise, leave it alone.
- #
- if {$count > 0} then {
- #
- # NOTE: Show how we tagged it.
- #
- puts stdout [appendArgs "tagged \"" $fileName "\" " $mode \
- " " $id " " $timeStamp]
-
- #
- # NOTE: Re-write the original file with the modified data.
- #
- writeFile $fileName [string map [list \n \r\n] $data]; # DOS.
- } else {
- #
- # NOTE: We could not replace the string. This is considered
- # an overall failure.
- #
- usage [appendArgs "pattern \"" $pattern "\" not found in \"" \
- $fileName \"]
- }
- }
- default {
- usage [appendArgs "unknown mode, must be " [join $modes " "]]
- }
- }
- } else {
- usage "invalid file name"
- }
- } else {
- usage [appendArgs "invalid mode, must be " [join $modes " "]]
- }
-} else {
- usage ""
-}
Index: Setup/verify.lst
==================================================================
--- Setup/verify.lst
+++ Setup/verify.lst
@@ -127,11 +127,10 @@
Setup/set_x64_2012.bat
Setup/set_x86_2005.bat
Setup/set_x86_2008.bat
Setup/set_x86_2010.bat
Setup/set_x86_2012.bat
- Setup/sourceTag.eagle
Setup/SQLite.iss
Setup/test_all.bat
Setup/test_ce.bat
Setup/updateFileInfo.tcl
Setup/verify.eagle
@@ -236,11 +235,10 @@
SQLite.Interop/src/core/
SQLite.Interop/src/core/sqlite3.c
SQLite.Interop/src/core/sqlite3.h
SQLite.Interop/src/core/sqlite3ext.h
SQLite.Interop/src/ext/
- SQLite.Interop/src/ext/totype.c
SQLite.Interop/src/ext/vtshim.c
SQLite.Interop/src/win/
SQLite.Interop/src/win/AssemblyInfo.cpp
SQLite.Interop/src/win/crypt.c
SQLite.Interop/src/win/interop.c
@@ -261,12 +259,10 @@
SQLite.nuspec
SQLite.x64.nuspec
SQLite.x86.nuspec
System.Data.SQLite/
System.Data.SQLite/AssemblyInfo.cs
- System.Data.SQLite/AssemblySourceIdAttribute.cs
- System.Data.SQLite/AssemblySourceTimeStampAttribute.cs
System.Data.SQLite/DataTypes.xml
System.Data.SQLite/LINQ/
System.Data.SQLite/LINQ/SQLiteConnection_Linq.cs
System.Data.SQLite/LINQ/SQLiteFactory_Linq.cs
System.Data.SQLite/MetaDataCollections.xml
@@ -297,11 +293,10 @@
System.Data.SQLite/SQLiteModule.cs
System.Data.SQLite/SQLiteModuleEnumerable.cs
System.Data.SQLite/SQLiteModuleNoop.cs
System.Data.SQLite/SQLiteParameter.cs
System.Data.SQLite/SQLiteParameterCollection.cs
- System.Data.SQLite/SQLitePatchLevel.cs
System.Data.SQLite/SQLiteStatement.cs
System.Data.SQLite/SQLiteTransaction.cs
System.Data.SQLite/SR.Designer.cs
System.Data.SQLite/SR.resx
System.Data.SQLite/System.Data.SQLite.2005.csproj
@@ -406,11 +401,10 @@
testlinq/testlinq.2008.csproj
testlinq/testlinq.2010.csproj
testlinq/testlinq.2012.csproj
Tests/
Tests/all.eagle
- Tests/authorizer.eagle
Tests/backup.eagle
Tests/basic.eagle
Tests/common.eagle
Tests/empty.eagle
Tests/installer.eagle
@@ -428,11 +422,10 @@
Tests/tkt-17045010df.eagle
Tests/tkt-1c456ae75f.eagle
Tests/tkt-201128cc88.eagle
Tests/tkt-2c630bffa7.eagle
Tests/tkt-2ce0870fad.eagle
- Tests/tkt-3113734605.eagle
Tests/tkt-343d392b51.eagle
Tests/tkt-3567020edf.eagle
Tests/tkt-393d954be0.eagle
Tests/tkt-3aa50d8413.eagle
Tests/tkt-448d663d11.eagle
@@ -448,12 +441,10 @@
Tests/tkt-84718e79fa.eagle
Tests/tkt-8554170e09.eagle
Tests/tkt-8b7d179c3c.eagle
Tests/tkt-8c3bee31c8.eagle
Tests/tkt-996d13cd87.eagle
- Tests/tkt-9ba9346f75.eagle
- Tests/tkt-aba4549801.eagle
Tests/tkt-ac47dd230a.eagle
Tests/tkt-ae5267b863.eagle
Tests/tkt-b4a7ddc83f.eagle
Tests/tkt-bb4b04d457.eagle
Tests/tkt-c010fa6584.eagle
@@ -461,11 +452,10 @@
Tests/tkt-e06c4caff3.eagle
Tests/tkt-e1b2e0f769.eagle
Tests/tkt-e30b820248.eagle
Tests/tkt-e47b3d8346.eagle
Tests/tkt-f2c47a01eb.eagle
- Tests/tkt-f8dbab8baf.eagle
Tests/tkt-fe50b8c2e8.eagle
Tests/Uninstaller_Test_Vs2005.log
Tests/Uninstaller_Test_Vs2008.log
Tests/Uninstaller_Test_Vs2010.log
Tests/Uninstaller_Test_Vs2012.log
DELETED System.Data.SQLite/AssemblySourceIdAttribute.cs
Index: System.Data.SQLite/AssemblySourceIdAttribute.cs
==================================================================
--- System.Data.SQLite/AssemblySourceIdAttribute.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/********************************************************
- * ADO.NET 2.0 Data Provider for SQLite Version 3.X
- * Written by Joe Mistachkin (joe@mistachkin.com)
- *
- * Released to the public domain, use at your own risk!
- ********************************************************/
-
-using System;
-
-namespace System.Data.SQLite
-{
- ///
- /// Defines a source code identifier custom attribute for an assembly
- /// manifest.
- ///
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- public sealed class AssemblySourceIdAttribute : Attribute
- {
- ///
- /// Constructs an instance of this attribute class using the specified
- /// source code identifier value.
- ///
- ///
- /// The source code identifier value to use.
- ///
- public AssemblySourceIdAttribute(string value)
- {
- sourceId = value;
- }
-
- ///////////////////////////////////////////////////////////////////////
-
- private string sourceId;
- ///
- /// Gets the source code identifier value.
- ///
- public string SourceId
- {
- get { return sourceId; }
- }
- }
-}
DELETED System.Data.SQLite/AssemblySourceTimeStampAttribute.cs
Index: System.Data.SQLite/AssemblySourceTimeStampAttribute.cs
==================================================================
--- System.Data.SQLite/AssemblySourceTimeStampAttribute.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/********************************************************
- * ADO.NET 2.0 Data Provider for SQLite Version 3.X
- * Written by Joe Mistachkin (joe@mistachkin.com)
- *
- * Released to the public domain, use at your own risk!
- ********************************************************/
-
-using System;
-
-namespace System.Data.SQLite
-{
- ///
- /// Defines a source code time-stamp custom attribute for an assembly
- /// manifest.
- ///
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
- public sealed class AssemblySourceTimeStampAttribute : Attribute
- {
- ///
- /// Constructs an instance of this attribute class using the specified
- /// source code time-stamp value.
- ///
- ///
- /// The source code time-stamp value to use.
- ///
- public AssemblySourceTimeStampAttribute(string value)
- {
- sourceTimeStamp = value;
- }
-
- ///////////////////////////////////////////////////////////////////////
-
- private string sourceTimeStamp;
- ///
- /// Gets the source code time-stamp value.
- ///
- public string SourceTimeStamp
- {
- get { return sourceTimeStamp; }
- }
- }
-}
Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -363,34 +363,10 @@
{
return UTF8ToString(UnsafeNativeMethods.sqlite3_sourceid(), -1);
}
}
- internal static string InteropVersion
- {
- get
- {
-#if !SQLITE_STANDARD
- return UTF8ToString(UnsafeNativeMethods.sqlite3_libversion_interop(), -1);
-#else
- return null;
-#endif
- }
- }
-
- internal static string InteropSourceId
- {
- get
- {
-#if !SQLITE_STANDARD
- return UTF8ToString(UnsafeNativeMethods.sqlite3_sourceid_interop(), -1);
-#else
- return null;
-#endif
- }
- }
-
internal override bool AutoCommit
{
get
{
return IsAutocommit(_sql, _sql);
@@ -2044,15 +2020,10 @@
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_rekey(_sql, newPasswordBytes, (newPasswordBytes == null) ? 0 : newPasswordBytes.Length);
if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
#endif
- internal override void SetAuthorizerHook(SQLiteAuthorizerCallback func)
- {
- UnsafeNativeMethods.sqlite3_set_authorizer(_sql, func, IntPtr.Zero);
- }
-
internal override void SetUpdateHook(SQLiteUpdateCallback func)
{
UnsafeNativeMethods.sqlite3_update_hook(_sql, func, IntPtr.Zero);
}
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -361,11 +361,10 @@
#if INTEROP_CODEC
internal abstract void SetPassword(byte[] passwordBytes);
internal abstract void ChangePassword(byte[] newPasswordBytes);
#endif
- internal abstract void SetAuthorizerHook(SQLiteAuthorizerCallback func);
internal abstract void SetUpdateHook(SQLiteUpdateCallback func);
internal abstract void SetCommitHook(SQLiteCommitCallback func);
internal abstract void SetTraceCallback(SQLiteTraceCallback func);
internal abstract void SetRollbackHook(SQLiteRollbackCallback func);
internal abstract SQLiteErrorCode SetLogCallback(SQLiteLogCallback func);
@@ -382,15 +381,10 @@
internal abstract int GetCursorForTable(SQLiteStatement stmt, int database, int rootPage);
internal abstract long GetRowIdForCursor(SQLiteStatement stmt, int cursor);
internal abstract object GetValue(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, SQLiteType typ);
- ///
- /// Returns non-zero if the given database connection is in autocommit mode.
- /// Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN
- /// statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
- ///
internal abstract bool AutoCommit
{
get;
}
Index: System.Data.SQLite/SQLiteCommand.cs
==================================================================
--- System.Data.SQLite/SQLiteCommand.cs
+++ System.Data.SQLite/SQLiteCommand.cs
@@ -22,14 +22,12 @@
#endif
public sealed class SQLiteCommand : DbCommand, ICloneable
{
///
/// The default connection string to be used when creating a temporary
- /// connection to execute a command via the static
- /// or
- ///
- /// methods.
+ /// connection to execute a command via the static
+ /// method.
///
private static readonly string DefaultConnectionString = "Data Source=:memory:;";
///
/// The command text this command is based on
@@ -693,52 +691,10 @@
SQLiteExecuteType executeType,
string connectionString,
params object[] args
)
{
- return Execute(
- commandText, executeType, CommandBehavior.Default,
- connectionString, args);
- }
-
- ///
- /// This method creates a new connection, executes the query using the given
- /// execution type and command behavior, closes the connection, and returns
- /// the results. If the connection string is null, a temporary in-memory
- /// database connection will be used.
- ///
- ///
- /// The text of the command to be executed.
- ///
- ///
- /// The execution type for the command. This is used to determine which method
- /// of the command object to call, which then determines the type of results
- /// returned, if any.
- ///
- ///
- /// The command behavior flags for the command.
- ///
- ///
- /// The connection string to the database to be opened, used, and closed. If
- /// this parameter is null, a temporary in-memory databse will be used.
- ///
- ///
- /// The SQL parameter values to be used when building the command object to be
- /// executed, if any.
- ///
- ///
- /// The results of the query -OR- null if no results were produced from the
- /// given execution type.
- ///
- public static object Execute(
- string commandText,
- SQLiteExecuteType executeType,
- CommandBehavior commandBehavior,
- string connectionString,
- params object[] args
- )
- {
if (connectionString == null)
connectionString = DefaultConnectionString;
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
@@ -768,19 +724,19 @@
//
break;
}
case SQLiteExecuteType.NonQuery:
{
- return command.ExecuteNonQuery(commandBehavior);
+ return command.ExecuteNonQuery();
}
case SQLiteExecuteType.Scalar:
{
- return command.ExecuteScalar(commandBehavior);
+ return command.ExecuteScalar();
}
case SQLiteExecuteType.Reader:
{
- return command.ExecuteReader(commandBehavior);
+ return command.ExecuteReader();
}
}
}
}
@@ -788,11 +744,11 @@
}
///
/// Overrides the default behavior to return a SQLiteDataReader specialization class
///
- /// The flags to be associated with the reader.
+ /// The flags to be associated with the reader
/// A SQLiteDataReader
public new SQLiteDataReader ExecuteReader(CommandBehavior behavior)
{
CheckDisposed();
SQLiteConnection.Check(_cnn);
@@ -824,32 +780,17 @@
}
///
/// Execute the command and return the number of rows inserted/updated affected by it.
///
- /// The number of rows inserted/updated affected by it.
+ ///
public override int ExecuteNonQuery()
{
- CheckDisposed();
- SQLiteConnection.Check(_cnn);
- return ExecuteNonQuery(CommandBehavior.Default);
- }
-
- ///
- /// Execute the command and return the number of rows inserted/updated affected by it.
- ///
- /// The flags to be associated with the reader.
- /// The number of rows inserted/updated affected by it.
- public int ExecuteNonQuery(
- CommandBehavior behavior
- )
- {
CheckDisposed();
SQLiteConnection.Check(_cnn);
- using (SQLiteDataReader reader = ExecuteReader(behavior |
- CommandBehavior.SingleRow | CommandBehavior.SingleResult))
+ using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
{
while (reader.NextResult()) ;
return reader.RecordsAffected;
}
}
@@ -856,33 +797,17 @@
///
/// Execute the command and return the first column of the first row of the resultset
/// (if present), or null if no resultset was returned.
///
- /// The first column of the first row of the first resultset from the query.
+ /// The first column of the first row of the first resultset from the query
public override object ExecuteScalar()
{
CheckDisposed();
SQLiteConnection.Check(_cnn);
- return ExecuteScalar(CommandBehavior.Default);
- }
-
- ///
- /// Execute the command and return the first column of the first row of the resultset
- /// (if present), or null if no resultset was returned.
- ///
- /// The flags to be associated with the reader.
- /// The first column of the first row of the first resultset from the query.
- public object ExecuteScalar(
- CommandBehavior behavior
- )
- {
- CheckDisposed();
- SQLiteConnection.Check(_cnn);
-
- using (SQLiteDataReader reader = ExecuteReader(behavior |
- CommandBehavior.SingleRow | CommandBehavior.SingleResult))
+
+ using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
{
if (reader.Read())
return reader[0];
}
return null;
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -12,11 +12,10 @@
using System.Data.Common;
using System.Diagnostics;
using System.Collections.Generic;
using System.Globalization;
using System.ComponentModel;
- using System.Reflection;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -52,15 +51,11 @@
public readonly IDataReader DataReader;
///
/// The critical handle associated with this event, if any.
///
-#if !PLATFORM_COMPACTFRAMEWORK
public readonly CriticalHandle CriticalHandle;
-#else
- public readonly object CriticalHandle;
-#endif
///
/// Command or message text associated with this event, if any.
///
public readonly string Text;
@@ -86,15 +81,11 @@
SQLiteConnectionEventType eventType,
StateChangeEventArgs eventArgs,
IDbTransaction transaction,
IDbCommand command,
IDataReader dataReader,
-#if !PLATFORM_COMPACTFRAMEWORK
CriticalHandle criticalHandle,
-#else
- object criticalHandle,
-#endif
string text,
object data
)
{
EventType = eventType;
@@ -375,20 +366,15 @@
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////
#region Private Static Data
- ///
- /// The managed assembly containing this type.
- ///
- private static readonly Assembly _assembly = typeof(SQLiteConnection).Assembly;
-
///
/// Object used to synchronize access to the static instance data
/// for this class.
///
- private static readonly object _syncRoot = new object();
+ private static object _syncRoot = new object();
///
/// Static variable to store the connection event handlers to call.
///
private static event SQLiteConnectionEventHandler _handlers;
@@ -476,17 +462,15 @@
internal bool _binaryGuid;
internal long _version;
- private event SQLiteAuthorizerEventHandler _authorizerHandler;
private event SQLiteUpdateEventHandler _updateHandler;
private event SQLiteCommitHandler _commitHandler;
private event SQLiteTraceEventHandler _traceHandler;
private event EventHandler _rollbackHandler;
- private SQLiteAuthorizerCallback _authorizerCallback;
private SQLiteUpdateCallback _updateCallback;
private SQLiteCommitCallback _commitCallback;
private SQLiteTraceCallback _traceCallback;
private SQLiteRollbackCallback _rollbackCallback;
#endregion
@@ -2224,13 +2208,10 @@
cmd.ExecuteNonQuery();
}
}
}
- if (_authorizerHandler != null)
- _sql.SetAuthorizerHook(_authorizerCallback);
-
if (_commitHandler != null)
_sql.SetCommitHook(_commitCallback);
if (_updateHandler != null)
_sql.SetUpdateHook(_updateCallback);
@@ -2403,31 +2384,10 @@
return _sql.Changes;
}
}
- ///
- /// Returns non-zero if the given database connection is in autocommit mode.
- /// Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN
- /// statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
- ///
-#if !PLATFORM_COMPACTFRAMEWORK
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-#endif
- public bool AutoCommit
- {
- get
- {
- CheckDisposed();
-
- if (_sql == null)
- throw new InvalidOperationException("Database connection not valid for getting autocommit mode.");
-
- return _sql.AutoCommit;
- }
- }
-
///
/// Returns the amount of memory (in bytes) currently in use by the SQLite core library.
///
#if !PLATFORM_COMPACTFRAMEWORK
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -2485,11 +2445,11 @@
{
get { return SQLite3.DefineConstants; }
}
///
- /// Returns the version of the underlying SQLite core library.
+ /// Returns the version of the underlying SQLite database engine
///
public static string SQLiteVersion
{
get { return SQLite3.SQLiteVersion; }
}
@@ -2502,100 +2462,10 @@
public static string SQLiteSourceId
{
get { return SQLite3.SQLiteSourceId; }
}
- ///
- /// This method returns the version of the interop SQLite assembly
- /// used. If the SQLite interop assembly is not in use or the
- /// necessary information cannot be obtained for any reason, a null
- /// value may be returned.
- ///
- public static string InteropVersion
- {
- get { return SQLite3.InteropVersion; }
- }
-
- ///
- /// This method returns the string whose value contains the unique
- /// identifier for the source checkout used to build the interop
- /// assembly. If the SQLite interop assembly is not in use or the
- /// necessary information cannot be obtained for any reason, a null
- /// value may be returned.
- ///
- public static string InteropSourceId
- {
- get { return SQLite3.InteropSourceId; }
- }
-
- ///
- /// This method returns the version of the managed components used
- /// to interact with the SQLite core library. If the necessary
- /// information cannot be obtained for any reason, a null value may
- /// be returned.
- ///
- public static string ProviderVersion
- {
- get
- {
- return (_assembly != null) ?
- _assembly.GetName().Version.ToString() : null;
- }
- }
-
- ///
- /// This method returns the string whose value contains the unique
- /// identifier for the source checkout used to build the managed
- /// components currently executing. If the necessary information
- /// cannot be obtained for any reason, a null value may be returned.
- ///
- public static string ProviderSourceId
- {
- get
- {
- if (_assembly == null)
- return null;
-
- string sourceId = null;
-
- if (_assembly.IsDefined(typeof(AssemblySourceIdAttribute), false))
- {
- AssemblySourceIdAttribute attribute =
- (AssemblySourceIdAttribute)_assembly.GetCustomAttributes(
- typeof(AssemblySourceIdAttribute), false)[0];
-
- sourceId = attribute.SourceId;
- }
-
- string sourceTimeStamp = null;
-
- if (_assembly.IsDefined(typeof(AssemblySourceTimeStampAttribute), false))
- {
- AssemblySourceTimeStampAttribute attribute =
- (AssemblySourceTimeStampAttribute)_assembly.GetCustomAttributes(
- typeof(AssemblySourceTimeStampAttribute), false)[0];
-
- sourceTimeStamp = attribute.SourceTimeStamp;
- }
-
- if ((sourceId != null) || (sourceTimeStamp != null))
- {
- if (sourceId == null)
- sourceId = "0000000000000000000000000000000000000000";
-
- if (sourceTimeStamp == null)
- sourceTimeStamp = "0000-00-00 00:00:00 UTC";
-
- return String.Format("{0} {1}", sourceId, sourceTimeStamp);
- }
- else
- {
- return null;
- }
- }
- }
-
///
/// Returns the state of the connection.
///
#if !PLATFORM_COMPACTFRAMEWORK
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -2973,11 +2843,11 @@
throw new NotSupportedException();
}
private static DataTable Schema_ReservedWords()
{
- DataTable tbl = new DataTable("ReservedWords");
+ DataTable tbl = new DataTable("MetaDataCollections");
tbl.Locale = CultureInfo.InvariantCulture;
tbl.Columns.Add("ReservedWord", typeof(string));
tbl.Columns.Add("MaximumVersion", typeof(string));
tbl.Columns.Add("MinimumVersion", typeof(string));
@@ -3962,44 +3832,10 @@
tbl.AcceptChanges();
return tbl;
}
- ///
- /// This event is raised whenever SQLite encounters an action covered by the
- /// authorizer during query preparation. Changing the value of the
- /// property will determine if
- /// the specific action will be allowed, ignored, or denied. For the entire
- /// duration of the event, the associated connection and statement objects
- /// must not be modified, either directly or indirectly, by the called code.
- ///
- public event SQLiteAuthorizerEventHandler Authorize
- {
- add
- {
- CheckDisposed();
-
- if (_authorizerHandler == null)
- {
- _authorizerCallback = new SQLiteAuthorizerCallback(AuthorizerCallback);
- if (_sql != null) _sql.SetAuthorizerHook(_authorizerCallback);
- }
- _authorizerHandler += value;
- }
- remove
- {
- CheckDisposed();
-
- _authorizerHandler -= value;
- if (_authorizerHandler == null)
- {
- if (_sql != null) _sql.SetAuthorizerHook(null);
- _authorizerCallback = null;
- }
- }
- }
-
///
/// This event is raised whenever SQLite makes an update/delete/insert into the database on
/// this connection. It only applies to the given connection.
///
public event SQLiteUpdateEventHandler Update
@@ -4026,29 +3862,10 @@
_updateCallback = null;
}
}
}
- private SQLiteAuthorizerReturnCode AuthorizerCallback(
- IntPtr pUserData,
- SQLiteAuthorizerActionCode actionCode,
- IntPtr pArgument1,
- IntPtr pArgument2,
- IntPtr pDatabase,
- IntPtr pAuthContext)
- {
- AuthorizerEventArgs eventArgs = new AuthorizerEventArgs(pUserData, actionCode,
- SQLiteBase.UTF8ToString(pArgument1, -1), SQLiteBase.UTF8ToString(pArgument2, -1),
- SQLiteBase.UTF8ToString(pDatabase, -1), SQLiteBase.UTF8ToString(pAuthContext, -1),
- SQLiteAuthorizerReturnCode.Ok);
-
- if (_authorizerHandler != null)
- _authorizerHandler(this, eventArgs);
-
- return eventArgs.ReturnCode;
- }
-
private void UpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid)
{
_updateHandler(this, new UpdateEventArgs(
SQLiteBase.UTF8ToString(database, -1),
SQLiteBase.UTF8ToString(table, -1),
@@ -4186,22 +4003,10 @@
}
#if !PLATFORM_COMPACTFRAMEWORK
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
- internal delegate SQLiteAuthorizerReturnCode SQLiteAuthorizerCallback(
- IntPtr pUserData,
- SQLiteAuthorizerActionCode actionCode,
- IntPtr pArgument1,
- IntPtr pArgument2,
- IntPtr pDatabase,
- IntPtr pAuthContext
- );
-
-#if !PLATFORM_COMPACTFRAMEWORK
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-#endif
internal delegate void SQLiteUpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid);
#if !PLATFORM_COMPACTFRAMEWORK
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
@@ -4215,19 +4020,10 @@
#if !PLATFORM_COMPACTFRAMEWORK
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
internal delegate void SQLiteRollbackCallback(IntPtr puser);
- ///
- /// Raised when authorization is required to perform an action contained
- /// within a SQL query.
- ///
- /// The connection performing the action.
- /// A that contains the
- /// event data.
- public delegate void SQLiteAuthorizerEventHandler(object sender, AuthorizerEventArgs e);
-
///
/// Raised when a transaction is about to be committed. To roll back a transaction, set the
/// rollbackTrans boolean value to true.
///
/// The connection committing the transaction
@@ -4293,127 +4089,10 @@
int totalPages,
bool retry
);
#endregion
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- ///
- /// The data associated with a call into the authorizer.
- ///
- public class AuthorizerEventArgs : EventArgs
- {
- ///
- /// The user-defined native data associated with this event. Currently,
- /// this will always contain the value of .
- ///
- public readonly IntPtr UserData;
-
- ///
- /// The action code responsible for the current call into the authorizer.
- ///
- public readonly SQLiteAuthorizerActionCode ActionCode;
-
- ///
- /// The first string argument for the current call into the authorizer.
- /// The exact value will vary based on the action code, see the
- /// enumeration for possible
- /// values.
- ///
- public readonly string Argument1;
-
- ///
- /// The second string argument for the current call into the authorizer.
- /// The exact value will vary based on the action code, see the
- /// enumeration for possible
- /// values.
- ///
- public readonly string Argument2;
-
- ///
- /// The database name for the current call into the authorizer, if
- /// applicable.
- ///
- public readonly string Database;
-
- ///
- /// The name of the inner-most trigger or view that is responsible for
- /// the access attempt or a null value if this access attempt is directly
- /// from top-level SQL code.
- ///
- public readonly string Context;
-
- ///
- /// The return code for the current call into the authorizer.
- ///
- public SQLiteAuthorizerReturnCode ReturnCode;
-
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- ///
- /// Constructs an instance of this class with default property values.
- ///
- private AuthorizerEventArgs()
- {
- this.UserData = IntPtr.Zero;
- this.ActionCode = SQLiteAuthorizerActionCode.None;
- this.Argument1 = null;
- this.Argument2 = null;
- this.Database = null;
- this.Context = null;
- this.ReturnCode = SQLiteAuthorizerReturnCode.Ok;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- ///
- /// Constructs an instance of this class with specific property values.
- ///
- ///
- /// The user-defined native data associated with this event.
- ///
- ///
- /// The authorizer action code.
- ///
- ///
- /// The first authorizer argument.
- ///
- ///
- /// The second authorizer argument.
- ///
- ///
- /// The database name, if applicable.
- ///
- ///
- /// The name of the inner-most trigger or view that is responsible for
- /// the access attempt or a null value if this access attempt is directly
- /// from top-level SQL code.
- ///
- ///
- /// The authorizer return code.
- ///
- internal AuthorizerEventArgs(
- IntPtr pUserData,
- SQLiteAuthorizerActionCode actionCode,
- string argument1,
- string argument2,
- string database,
- string context,
- SQLiteAuthorizerReturnCode returnCode
- )
- : this()
- {
- this.UserData = pUserData;
- this.ActionCode = actionCode;
- this.Argument1 = argument1;
- this.Argument2 = argument2;
- this.Database = database;
- this.Context = context;
- this.ReturnCode = returnCode;
- }
- }
-
///////////////////////////////////////////////////////////////////////////////////////////////
///
/// Whenever an update event is triggered on a connection, this enum will indicate
/// exactly what type of operation is being performed.
Index: System.Data.SQLite/SQLiteConvert.cs
==================================================================
--- System.Data.SQLite/SQLiteConvert.cs
+++ System.Data.SQLite/SQLiteConvert.cs
@@ -1472,29 +1472,25 @@
///
None = 0,
///
/// The command is not expected to return a result -OR- the result is not
- /// needed. The or
- /// method
- /// will be called.
+ /// needed. The method will
+ /// be called.
///
NonQuery = 1,
///
/// The command is expected to return a scalar result -OR- the result should
- /// be limited to a scalar result. The
- /// or method will
- /// be called.
+ /// be limited to a scalar result. The
+ /// method will be called.
///
Scalar = 2,
///
/// The command is expected to return result.
- /// The or
- /// method will
- /// be called.
+ /// The method will be called.
///
Reader = 3,
///
/// Use the default command execution type. Using this value is the same
@@ -1501,247 +1497,10 @@
/// as using the value.
///
Default = NonQuery /* TODO: Good default? */
}
- ///
- /// The action code responsible for the current call into the authorizer.
- ///
- public enum SQLiteAuthorizerActionCode
- {
- ///
- /// No action is being performed. This value should not be used from
- /// external code.
- ///
- None = -1,
-
- ///
- /// No longer used.
- ///
- Copy = 0,
-
- ///
- /// An index will be created. The action-specific arguments are the
- /// index name and the table name.
- ///
- ///
- CreateIndex = 1,
-
- ///
- /// A table will be created. The action-specific arguments are the
- /// table name and a null value.
- ///
- CreateTable = 2,
-
- ///
- /// A temporary index will be created. The action-specific arguments
- /// are the index name and the table name.
- ///
- CreateTempIndex = 3,
-
- ///
- /// A temporary table will be created. The action-specific arguments
- /// are the table name and a null value.
- ///
- CreateTempTable = 4,
-
- ///
- /// A temporary trigger will be created. The action-specific arguments
- /// are the trigger name and the table name.
- ///
- CreateTempTrigger = 5,
-
- ///
- /// A temporary view will be created. The action-specific arguments are
- /// the view name and a null value.
- ///
- CreateTempView = 6,
-
- ///
- /// A trigger will be created. The action-specific arguments are the
- /// trigger name and the table name.
- ///
- CreateTrigger = 7,
-
- ///
- /// A view will be created. The action-specific arguments are the view
- /// name and a null value.
- ///
- CreateView = 8,
-
- ///
- /// A DELETE statement will be executed. The action-specific arguments
- /// are the table name and a null value.
- ///
- Delete = 9,
-
- ///
- /// An index will be dropped. The action-specific arguments are the
- /// index name and the table name.
- ///
- DropIndex = 10,
-
- ///
- /// A table will be dropped. The action-specific arguments are the tables
- /// name and a null value.
- ///
- DropTable = 11,
-
- ///
- /// A temporary index will be dropped. The action-specific arguments are
- /// the index name and the table name.
- ///
- DropTempIndex = 12,
-
- ///
- /// A temporary table will be dropped. The action-specific arguments are
- /// the table name and a null value.
- ///
- DropTempTable = 13,
-
- ///
- /// A temporary trigger will be dropped. The action-specific arguments
- /// are the trigger name and the table name.
- ///
- DropTempTrigger = 14,
-
- ///
- /// A temporary view will be dropped. The action-specific arguments are
- /// the view name and a null value.
- ///
- DropTempView = 15,
-
- ///
- /// A trigger will be dropped. The action-specific arguments are the
- /// trigger name and the table name.
- ///
- DropTrigger = 16,
-
- ///
- /// A view will be dropped. The action-specific arguments are the view
- /// name and a null value.
- ///
- DropView = 17,
-
- ///
- /// An INSERT statement will be executed. The action-specific arguments
- /// are the table name and a null value.
- ///
- Insert = 18,
-
- ///
- /// A PRAGMA statement will be executed. The action-specific arguments
- /// are the name of the PRAGMA and the new value or a null value.
- ///
- Pragma = 19,
-
- ///
- /// A table column will be read. The action-specific arguments are the
- /// table name and the column name.
- ///
- Read = 20,
-
- ///
- /// A SELECT statement will be executed. The action-specific arguments
- /// are both null values.
- ///
- Select = 21,
-
- ///
- /// A transaction will be started, committed, or rolled back. The
- /// action-specific arguments are the name of the operation (BEGIN,
- /// COMMIT, or ROLLBACK) and a null value.
- ///
- Transaction = 22,
-
- ///
- /// An UPDATE statement will be executed. The action-specific arguments
- /// are the table name and the column name.
- ///
- Update = 23,
-
- ///
- /// A database will be attached to the connection. The action-specific
- /// arguments are the database file name and a null value.
- ///
- Attach = 24,
-
- ///
- /// A database will be detached from the connection. The action-specific
- /// arguments are the database name and a null value.
- ///
- Detach = 25,
-
- ///
- /// The schema of a table will be altered. The action-specific arguments
- /// are the database name and the table name.
- ///
- AlterTable = 26,
-
- ///
- /// An index will be deleted and then recreated. The action-specific
- /// arguments are the index name and a null value.
- ///
- Reindex = 27,
-
- ///
- /// A table will be analyzed to gathers statistics about it. The
- /// action-specific arguments are the table name and a null value.
- ///
- Analyze = 28,
-
- ///
- /// A virtual table will be created. The action-specific arguments are
- /// the table name and the module name.
- ///
- CreateVtable = 29,
-
- ///
- /// A virtual table will be dropped. The action-specific arguments are
- /// the table name and the module name.
- ///
- DropVtable = 30,
-
- ///
- /// A SQL function will be called. The action-specific arguments are a
- /// null value and the function name.
- ///
- Function = 31,
-
- ///
- /// A savepoint will be created, released, or rolled back. The
- /// action-specific arguments are the name of the operation (BEGIN,
- /// RELEASE, or ROLLBACK) and the savepoint name.
- ///
- Savepoint = 32
- }
-
- ///
- /// The return code for the current call into the authorizer.
- ///
- public enum SQLiteAuthorizerReturnCode
- {
- ///
- /// The action will be allowed.
- ///
- Ok = 0,
-
- ///
- /// The overall action will be disallowed and an error message will be
- /// returned from the query preparation method.
- ///
- Deny = 1,
-
- ///
- /// The specific action will be disallowed; however, the overall action
- /// will continue. The exact effects of this return code vary depending
- /// on the specific action, please refer to the SQLite core library
- /// documentation for futher details.
- ///
- Ignore = 2
- }
-
///
/// Class used internally to determine the datatype of a column in a resultset
///
internal sealed class SQLiteType
{
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -1237,41 +1237,40 @@
CheckDisposed();
CheckClosed();
if (_throwOnDisposed) SQLiteCommand.Check(_command);
SQLiteStatement stmt = null;
- int fieldCount;
- bool schemaOnly = ((_commandBehavior & CommandBehavior.SchemaOnly) != 0);
+ int fieldCount;
while (true)
{
if (stmt == null && _activeStatement != null && _activeStatement._sql != null && _activeStatement._sql.IsOpen())
{
- // Reset the previously-executed statement
- if (!schemaOnly) _activeStatement._sql.Reset(_activeStatement);
+ // Reset the previously-executed statement
+ _activeStatement._sql.Reset(_activeStatement);
// If we're only supposed to return a single rowset, step through all remaining statements once until
// they are all done and return false to indicate no more resultsets exist.
if ((_commandBehavior & CommandBehavior.SingleResult) != 0)
{
for (; ; )
{
stmt = _command.GetStatement(_activeStatementIndex + 1);
if (stmt == null) break;
- _activeStatementIndex++;
-
- if (!schemaOnly) stmt._sql.Step(stmt);
+ _activeStatementIndex++;
+
+ stmt._sql.Step(stmt);
if (stmt._sql.ColumnCount(stmt) == 0)
{
if (_rowsAffected == -1) _rowsAffected = 0;
int changes = 0;
if (stmt.TryGetChanges(ref changes))
_rowsAffected += changes;
else
return false;
- }
- if (!schemaOnly) stmt._sql.Reset(stmt); // Gotta reset after every step to release any locks and such!
+ }
+ stmt._sql.Reset(stmt); // Gotta reset after every step to release any locks and such!
}
return false;
}
}
@@ -1286,34 +1285,34 @@
if (_readingState < 1)
_readingState = 1;
_activeStatementIndex++;
- fieldCount = stmt._sql.ColumnCount(stmt);
-
+ fieldCount = stmt._sql.ColumnCount(stmt);
+
// If the statement is not a select statement or we're not retrieving schema only, then perform the initial step
- if (!schemaOnly || (fieldCount == 0))
- {
- if (!schemaOnly && stmt._sql.Step(stmt))
- {
- _readingState = -1;
- }
- else if (fieldCount == 0) // No rows returned, if fieldCount is zero, skip to the next statement
- {
- if (_rowsAffected == -1) _rowsAffected = 0;
- int changes = 0;
- if (stmt.TryGetChanges(ref changes))
- _rowsAffected += changes;
- else
- return false;
- if (!schemaOnly) stmt._sql.Reset(stmt);
- continue; // Skip this command and move to the next, it was not a row-returning resultset
- }
- else // No rows, fieldCount is non-zero so stop here
- {
- _readingState = 1; // This command returned columns but no rows, so return true, but HasRows = false and Read() returns false
- }
+ if ((_commandBehavior & CommandBehavior.SchemaOnly) == 0 || fieldCount == 0)
+ {
+ if (stmt._sql.Step(stmt))
+ {
+ _readingState = -1;
+ }
+ else if (fieldCount == 0) // No rows returned, if fieldCount is zero, skip to the next statement
+ {
+ if (_rowsAffected == -1) _rowsAffected = 0;
+ int changes = 0;
+ if (stmt.TryGetChanges(ref changes))
+ _rowsAffected += changes;
+ else
+ return false;
+ stmt._sql.Reset(stmt);
+ continue; // Skip this command and move to the next, it was not a row-returning resultset
+ }
+ else // No rows, fieldCount is non-zero so stop here
+ {
+ _readingState = 1; // This command returned columns but no rows, so return true, but HasRows = false and Read() returns false
+ }
}
// Ahh, we found a row-returning resultset eligible to be returned!
_activeStatement = stmt;
_fieldCount = fieldCount;
@@ -1361,14 +1360,11 @@
/// True if a new row was successfully loaded and is ready for processing
public override bool Read()
{
CheckDisposed();
CheckClosed();
- if (_throwOnDisposed) SQLiteCommand.Check(_command);
-
- if ((_commandBehavior & CommandBehavior.SchemaOnly) != 0)
- return false;
+ if (_throwOnDisposed) SQLiteCommand.Check(_command);
if (_readingState == -1) // First step was already done at the NextResult() level, so don't step again, just return true.
{
_readingState = 0;
return true;
DELETED System.Data.SQLite/SQLitePatchLevel.cs
Index: System.Data.SQLite/SQLitePatchLevel.cs
==================================================================
--- System.Data.SQLite/SQLitePatchLevel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-/********************************************************
- * ADO.NET 2.0 Data Provider for SQLite Version 3.X
- * Written by Joe Mistachkin (joe@mistachkin.com)
- *
- * Released to the public domain, use at your own risk!
- ********************************************************/
-
-using System.Data.SQLite;
-
-///////////////////////////////////////////////////////////////////////////////
-
-[assembly: AssemblySourceId(null)]
-
-///////////////////////////////////////////////////////////////////////////////
-
-[assembly: AssemblySourceTimeStamp(null)]
Index: System.Data.SQLite/System.Data.SQLite.Files.targets
==================================================================
--- System.Data.SQLite/System.Data.SQLite.Files.targets
+++ System.Data.SQLite/System.Data.SQLite.Files.targets
@@ -13,12 +13,10 @@
******************************************************************************
-->
-
-
@@ -45,11 +43,10 @@
-
SR.resx
True
Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -769,16 +769,10 @@
// get working when using the standard SQLite library.
#region interop added functionality
#if !SQLITE_STANDARD
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_libversion_interop();
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_sourceid_interop();
-
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_close_interop(IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq);
@@ -1467,17 +1461,10 @@
[DllImport(SQLITE_DLL)]
#endif
internal static extern SQLiteErrorCode sqlite3_rekey(IntPtr db, byte[] key, int keylen);
#endif
-#if !PLATFORM_COMPACTFRAMEWORK
- [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
-#else
- [DllImport(SQLITE_DLL)]
-#endif
- internal static extern IntPtr sqlite3_set_authorizer(IntPtr db, SQLiteAuthorizerCallback func, IntPtr pvUser);
-
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
DELETED Tests/authorizer.eagle
Index: Tests/authorizer.eagle
==================================================================
--- Tests/authorizer.eagle
+++ /dev/null
@@ -1,163 +0,0 @@
-###############################################################################
-#
-# authorizer.eagle --
-#
-# Written by Joe Mistachkin.
-# Released to the public domain, use at your own risk!
-#
-###############################################################################
-
-package require Eagle
-package require Eagle.Library
-package require Eagle.Test
-
-runTestPrologue
-
-###############################################################################
-
-package require System.Data.SQLite.Test
-runSQLiteTestPrologue
-
-###############################################################################
-
-runTest {test authorizer-1.1 {SQLiteConnection Authorize event} -setup {
- proc onAuthorize { sender e } {
- #
- # NOTE: Filter out the "noise" by allowing all standard
- # events on the "sqlite_*" tables.
- #
- set noiseActionCodes [list \
- CreateTable CreateIndex Read Insert Update Delete]
-
- if {[$e ActionCode] in $noiseActionCodes && \
- [string match "sqlite_*" [$e Argument1]]} then {
- return
- }
-
- #
- # NOTE: Filter out all "non-primary" events to make the test
- # results more deterministic in the face of different
- # query plans.
- #
- if {[$e ActionCode] ne $::filter} then {
- return
- }
-
- #
- # NOTE: Record the authorizer arguments exactly as we received
- # them.
- #
- lappend ::data [list \
- [$e UserData] [$e ActionCode] [$e Argument1] \
- [$e Argument2] [$e Database] [$e Context]]
-
- #
- # NOTE: Deny all attempts to create a table named "tDeny".
- #
- if {[$e ActionCode] eq "CreateTable" && \
- [$e Argument1] eq "tDeny"} then {
- $e ReturnCode Deny
- }
- }
-
- setupDb [set fileName authorizer-1.1.db]
-} -body {
- set connection [getDbConnection]
-
- set callback onAuthorize
- object invoke $connection add_Authorize $callback
-
- set results [list]
-
- set sql [list \
- CreateTable {CREATE TABLE t1(x);} \
- CreateIndex {CREATE INDEX i1 ON t1(x);} \
- CreateTrigger {CREATE TRIGGER tr1 BEFORE INSERT ON t1
- BEGIN
- SELECT RAISE(IGNORE);
- END;} \
- CreateView {CREATE VIEW v1 AS SELECT * FROM t1;} \
- CreateTempTable {CREATE TEMPORARY TABLE t2(x);} \
- CreateTempIndex {CREATE INDEX i2 ON t2(x);} \
- CreateTempTrigger {CREATE TEMPORARY TRIGGER tr2 BEFORE INSERT ON t2
- BEGIN
- SELECT RAISE(IGNORE);
- END;} \
- CreateTempView {CREATE TEMPORARY VIEW v2 AS SELECT * FROM t2;} \
- Pragma {PRAGMA journal_mode=WAL;} \
- Function {SELECT julianday('now');} \
- Read {SELECT x FROM t1;} \
- Select {SELECT * FROM t1;} \
- Insert {INSERT INTO t1(x) VALUES(1);} \
- Update {UPDATE t1 SET x = x - 1;} \
- Delete {DELETE FROM t1;} \
- AlterTable {ALTER TABLE t1 ADD COLUMN y;} \
- Reindex {REINDEX t1;} \
- Analyze {ANALYZE t1;} \
- DropTempView {DROP VIEW v2;} \
- DropTempTrigger {DROP TRIGGER tr2;} \
- DropTempIndex {DROP INDEX i2;} \
- DropTempTable {DROP TABLE t2;} \
- DropView {DROP VIEW v1;} \
- DropTrigger {DROP TRIGGER tr1;} \
- DropIndex {DROP INDEX i1;} \
- DropTable {DROP TABLE t1;} \
- Transaction {BEGIN; SELECT 0; COMMIT;} \
- Savepoint {SAVEPOINT s1; RELEASE SAVEPOINT s1;} \
- Attach {ATTACH DATABASE ':memory:' AS d1;} \
- Detach {DETACH DATABASE d1;} \
- CreateVtable {CREATE VIRTUAL TABLE t3 USING fts4(x TEXT);} \
- DropVtable {DROP TABLE t3;} \
- CreateTable {CREATE TABLE tDeny(x);}]
-
- foreach {name value} $sql {
- set filter $name; set data [list]
- set code [catch {sql execute $db $value} result]
- set result [lindex [split [string map [list \r\n \n] $result] \n] 0]
- lappend results [list $name $data $code $result]
- }
- lappend results [isTableInDb tDeny]
-
- set results
-} -cleanup {
- catch {object invoke $connection remove_Authorize $callback}
- catch {object removecallback $callback}
-
- cleanupDb $fileName
-
- freeDbConnection
-
- unset -nocomplain result code data filter value name sql results callback \
- connection db fileName
-
- rename onAuthorize ""
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{{CreateTable {{0 CreateTable t1 {} main {}}} 0 0} {CreateIndex {{0 CreateIndex\
-i1 t1 main {}}} 0 0} {CreateTrigger {{0 CreateTrigger tr1 t1 main {}}} 0 0}\
-{CreateView {{0 CreateView v1 {} main {}}} 0 0} {CreateTempTable {{0\
-CreateTempTable t2 {} temp {}}} 0 0} {CreateTempIndex {{0 CreateTempIndex i2 t2\
-temp {}}} 0 0} {CreateTempTrigger {{0 CreateTempTrigger tr2 t2 temp {}}} 0 0}\
-{CreateTempView {{0 CreateTempView v2 {} temp {}}} 0 0} {Pragma {{0 Pragma\
-journal_mode WAL {} {}}} 0 0} {Function {{0 Function {} julianday {} {}}} 0 0}\
-{Read {{0 Read t1 x main {}}} 0 0} {Select {{0 Select {} {} {} {}}} 0 0}\
-{Insert {{0 Insert t1 {} main {}}} 0 0} {Update {{0 Update t1 x main {}}} 0 0}\
-{Delete {{0 Delete t1 {} main {}}} 0 0} {AlterTable {{0 AlterTable main t1 {}\
-{}}} 0 0} {Reindex {{0 Reindex i1 {} main {}}} 0 0} {Analyze {{0 Analyze t1 {}\
-main {}}} 0 0} {DropTempView {{0 DropTempView v2 {} temp {}}} 0 0}\
-{DropTempTrigger {{0 DropTempTrigger tr2 t2 temp {}}} 0 0} {DropTempIndex {{0\
-DropTempIndex i2 t2 temp {}}} 0 0} {DropTempTable {{0 DropTempTable t2 {} temp\
-{}}} 0 0} {DropView {{0 DropView v1 {} main {}}} 0 0} {DropTrigger {{0\
-DropTrigger tr1 t1 main {}}} 0 0} {DropIndex {{0 DropIndex i1 t1 main {}}} 0 0}\
-{DropTable {{0 DropTable t1 {} main {}}} 0 0} {Transaction {{0 Transaction\
-BEGIN {} {} {}} {0 Transaction COMMIT {} {} {}}} 0 0} {Savepoint {{0 Savepoint\
-BEGIN s1 {} {}} {0 Savepoint RELEASE s1 {} {}}} 0 0} {Attach {{0 Attach\
-:memory: {} {} {}}} 0 0} {Detach {{0 Detach d1 {} {} {}}} 0 0} {CreateVtable\
-{{0 CreateVtable t3 fts4 main {}}} 0 0} {DropVtable {{0 DropVtable t3 fts4 main\
-{}}} 0 0} {CreateTable {{0 CreateTable tDeny {} main {}}} 1\
-{System.Data.SQLite.SQLiteException (0x80004005): authorization denied}} False}}
-
-###############################################################################
-
-runSQLiteTestEpilogue
-runTestEpilogue
Index: Tests/backup.eagle
==================================================================
--- Tests/backup.eagle
+++ Tests/backup.eagle
@@ -220,12 +220,13 @@
freeDbConnection memSource
unset -nocomplain result results errors code index memSource dataSource \
id memDb db fileName callbackResults
- } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result [appendArgs \
+ } -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result [appendArgs \
"^Ok System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} " \
[lindex $params(results) $i]]}
}
###############################################################################
Index: Tests/basic.eagle
==================================================================
--- Tests/basic.eagle
+++ Tests/basic.eagle
@@ -96,12 +96,12 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain totalCount failureCount successCount code output \
error fileName
-} -constraints {eagle SQLite file_System.Data.SQLite.dll file_test.exe\
-testExec} -result {0 {}}}
+} -constraints {eagle SQLite file_System.Data.SQLite.dll file_test.exe} \
+-result {0 {}}}
###############################################################################
runTest {test data-1.2 {unit tests from the 'testlinq' project} -setup {
#
@@ -138,11 +138,11 @@
unset -nocomplain code output error savedEncoding encoding
} -constraints \
{eagle monoToDo SQLite file_System.Data.SQLite.dll\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db\
-file_testlinq.out testExec} -result {0 True {}}}
+file_testlinq.out} -result {0 True {}}}
###############################################################################
runTest {test data-1.3 {SELECT scalar/reader, CREATE, INSERT} -setup {
setupDb [set fileName data-1.3.db]
@@ -217,13 +217,14 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 System#Data#DataTable#\d+$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+System#Data#DataTable#\d+$}}
###############################################################################
runTest {test data-1.5 {GetSchema with ForeignKeys} -setup {
setupDb [set fileName data-1.5.db]
@@ -303,16 +304,16 @@
} -cleanup {
cleanupDb $fileName
unset -nocomplain result rows foreignKey foreignKeys results errors code \
dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\{main FK_t1_0_0 main t1\
-\{FOREIGN KEY\} False False 0 x main t2 \{\} 0 \{SET DEFAULT\} CASCADE NONE\}\
-\{main FK_t2_0_0 main t2 \{FOREIGN KEY\} False False 0 x main t3 \{\} 0 \{NO\
-ACTION\} \{NO ACTION\} NONE\}\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+\{\{main FK_t1_0_0 main t1 \{FOREIGN KEY\} False False 0 x main t2 \{\} 0 \{SET\
+DEFAULT\} CASCADE NONE\} \{main FK_t2_0_0 main t2 \{FOREIGN KEY\} False False 0\
+x main t3 \{\} 0 \{NO ACTION\} \{NO ACTION\} NONE\}\}$}}
###############################################################################
runTest {test data-1.6 {SQLITE_FCNTL_WIN32_AV_RETRY} -setup {
setupDb [set fileName data-1.6.db]
@@ -406,13 +407,14 @@
cleanupDb $fileName
unset -nocomplain result count interval savedCount savedInterval results \
errors code dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 True$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+True$}}
###############################################################################
runTest {test data-1.7 {properly closed database file (non-query)} -setup {
set fileName data-1.7.db
@@ -462,13 +464,14 @@
[close [open $dataSource RDONLY 0 "" -share None]]
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+\{\} \{\}$}}
###############################################################################
runTest {test data-1.8 {properly closed database file (reader #1)} -setup {
set fileName data-1.8.db
@@ -521,13 +524,14 @@
[close [open $dataSource RDONLY 0 "" -share None]]
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+\{\} \{\}$}}
###############################################################################
runTest {test data-1.9 {properly closed database file (reader #2)} -setup {
set fileName data-1.9.db
@@ -582,13 +586,14 @@
[close [open $dataSource RDONLY 0 "" -share None]]
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+\{\} \{\}$}}
###############################################################################
runTest {test data-1.10 {Changes property} -setup {
setupDb [set fileName data-1.10.db]
@@ -883,11 +888,11 @@
)
{
SQLiteConnectionStringBuilder builder =
new SQLiteConnectionStringBuilder();
- builder.Add("Data Source", "test.db");
+ builder.Add("Date Source", "test.db");
builder.Add("DateTimeFormat", format);
builder.Add("DateTimeKind", kind);
builder.Add("DateTimeFormatString", formatString);
return builder.ToString();
@@ -925,16 +930,16 @@
object invoke _Dynamic${id}.Test${id} GetConnectionString \
Ticks Local yyyy-MM-dd
} result] : [set result ""]}] $result
} -cleanup {
unset -nocomplain result results errors code id
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{Data Source=test\.db\} 0\
-\{Data Source=test\.db;DateTimeFormat=(?:Default|ISO8601)\} 0 \{Data\
-Source=test\.db;DateTimeKind=Unspecified\} 0 \{Data\
-Source=test\.db;DateTimeFormat=(?:Default|ISO8601);DateTimeKind=Utc\} 0 \{Data\
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{Date\
+Source=test\.db\} 0 \{Date Source=test\.db;DateTimeFormat=(?:Default|ISO8601)\}\
+0 \{Date Source=test\.db;DateTimeKind=Unspecified\} 0 \{Date\
+Source=test\.db;DateTimeFormat=(?:Default|ISO8601);DateTimeKind=Utc\} 0 \{Date\
Source=test\.db;DateTimeFormat=Ticks;DateTimeKind=Local;DateTimeFormatString=yyyy-MM-dd\}$}}
###############################################################################
runTest {test data-1.16 {SQLiteConnectionStringBuilder properties} -body {
@@ -1046,22 +1051,22 @@
set results
} -cleanup {
unset -nocomplain propertyName propertyNames value key values keys result \
results errors code id
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result \
-{^System#CodeDom#Compiler#CompilerResults#\d+ Ok \{\} 0 \{, \} 0 \{3,\
-Version=3\} 0 \{Normal, Synchronous=Normal\} 0 \{True, UseUTF16Encoding=True\}\
-0 \{False, Pooling=False\} 0 \{True, BinaryGUID=True\} 0 \{test\.db, Data\
-Source=test\.db\} 0 \{test\.db, Uri=test\.db\} 0 \{file:test.db,\
-FullUri=file:test\.db\} 0 \{60, Default Timeout=60\} 0 \{False, Enlist=False\}\
-0 \{True, FailIfMissing=True\} 0 \{False, Legacy Format=False\} 0 \{True, Read\
-Only=True\} 0 \{secret, Password=secret\} 0 \{4096, Page Size=4096\} 0 \{1024,\
-Max Page Count=1024\} 0 \{8192, Cache Size=8192\} 0 \{UnixEpoch,\
-DateTimeFormat=UnixEpoch\} 0 \{Utc, DateTimeKind=Utc\} 0 \{yyyy-MM-dd,\
-DateTimeFormatString=yyyy-MM-dd\} 0 \{sqlite_schema,\
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^System#CodeDom#Compiler#CompilerResults#\d+ Ok \{\} 0 \{, \} 0\
+\{3, Version=3\} 0 \{Normal, Synchronous=Normal\} 0 \{True,\
+UseUTF16Encoding=True\} 0 \{False, Pooling=False\} 0 \{True, BinaryGUID=True\}\
+0 \{test\.db, Data Source=test\.db\} 0 \{test\.db, Uri=test\.db\} 0\
+\{file:test.db, FullUri=file:test\.db\} 0 \{60, Default Timeout=60\} 0 \{False,\
+Enlist=False\} 0 \{True, FailIfMissing=True\} 0 \{False, Legacy Format=False\}\
+0 \{True, Read Only=True\} 0 \{secret, Password=secret\} 0 \{4096, Page\
+Size=4096\} 0 \{1024, Max Page Count=1024\} 0 \{8192, Cache Size=8192\} 0\
+\{UnixEpoch, DateTimeFormat=UnixEpoch\} 0 \{Utc, DateTimeKind=Utc\} 0\
+\{yyyy-MM-dd, DateTimeFormatString=yyyy-MM-dd\} 0 \{sqlite_schema,\
BaseSchemaName=sqlite_schema\} 0 \{Memory, Journal Mode=Memory\} 0\
\{Serializable, Default IsolationLevel=Serializable\} 0 \{False, Foreign\
Keys=False\} 0 \{(?:Default|LogCallbackException),\
Flags=(?:Default|LogCallbackException)\} 0 \{False, SetDefaults=False\} 0\
\{False, ToFullPath=False\} 0 {736563726574, HexPassword=736563726574}$}}
@@ -1204,13 +1209,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runTest {test data-1.22 {SQLiteFunction collation exception} -setup {
setupDb [set fileName data-1.22.db]
@@ -1288,13 +1293,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 1\
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 1\
\{System\.Reflection\.TargetInvocationException: Exception has been thrown by\
the target of an invocation\. ---> System\.Data\.SQLite\.SQLiteException:\
interrupted.*$}}
###############################################################################
@@ -2471,16 +2476,17 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result \
-[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
-\{\} 1 \{System\.Reflection\.TargetInvocationException: Exception has been\
-thrown by the target of an invocation\. --->\
-System\.Data\.SQLite\.SQLiteException: SQL logic error or missing database
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result [string map [list \n \r\n] {^Ok\
+System#CodeDom#Compiler#CompilerResults#\d+ \{\} 1\
+\{System\.Reflection\.TargetInvocationException: Exception has been thrown by\
+the target of an invocation\. ---> System\.Data\.SQLite\.SQLiteException: SQL\
+logic error or missing database
no such function: MyRandom.*\} 0 (?:-)?\d+ 1\
\{System\.Reflection\.TargetInvocationException: Exception has been thrown by\
the target of an invocation\. ---> System\.Data\.SQLite\.SQLiteException: SQL\
logic error or missing database
no such function: MyRandom.*\}$}]}
@@ -2523,43 +2529,14 @@
{UNIQUEIDENTIFIER Guid} {UNSIGNEDINTEGER UInt64} {UNSIGNEDINTEGER8 Byte}\
{UNSIGNEDINTEGER16 UInt16} {UNSIGNEDINTEGER32 UInt32} {UNSIGNEDINTEGER64\
UInt64} {VARBINARY Binary} {VARCHAR AnsiString} {VARCHAR2 AnsiString} {YESNO\
Boolean}}}
-###############################################################################
-
-runTest {test data-1.52 {totype extension} -setup {
- setupDb [set fileName data-1.52.db]
-} -body {
- set connection [getDbConnection]
- set result [list]
-
- $connection EnableExtensions true
- $connection LoadExtension [getCoreBinaryFileName] sqlite3_totype_init
-
- lappend result [sql execute -execute scalar $db "SELECT tointeger('1');"]
- lappend result [sql execute -execute scalar $db "SELECT tointeger('1x');"]
- lappend result [sql execute -execute scalar $db "SELECT toreal('1.01');"]
- lappend result [sql execute -execute scalar $db "SELECT toreal('1.0x');"]
-
- set result
-} -cleanup {
- freeDbConnection
-
- unset -nocomplain result connection
-
- cleanupDb $fileName
-
- unset -nocomplain db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{1 {} 1.01 {}}}
-
###############################################################################
unset -nocomplain systemDataSQLiteDllFile systemDataSQLiteLinqDllFile \
testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/common.eagle
==================================================================
--- Tests/common.eagle
+++ Tests/common.eagle
@@ -740,24 +740,16 @@
}
}
}
}
- proc checkForSQLiteLibrary { channel } {
- tputs $channel "---- checking for SQLite core library... "
+ proc checkForSQLite { channel } {
+ tputs $channel "---- checking for core SQLite library... "
if {[catch {
object invoke -flags +NonPublic System.Data.SQLite.SQLite3 \
SQLiteVersion} version] == 0} then {
- #
- # NOTE: Check if the returned version was null. If so, make it easy
- # to spot.
- #
- if {[string length $version] == 0} then {
- set version null
- }
-
#
# NOTE: Attempt to query the Fossil source identifier for the SQLite
# core library.
#
if {[catch {
@@ -767,69 +759,15 @@
# NOTE: We failed to query the Fossil source identifier.
#
set sourceId unknown
}
- #
- # NOTE: Check if the returned Fossil source identifier was null. If
- # so, make it easy to spot.
- #
- if {[string length $sourceId] == 0} then {
- set sourceId null
- }
-
#
# NOTE: Yes, the SQLite core library appears to be available.
#
addConstraint SQLite
- tputs $channel [appendArgs "yes (" $version " " $sourceId ")\n"]
- } else {
- tputs $channel no\n
- }
- }
-
- proc checkForSQLiteInterop { channel } {
- tputs $channel "---- checking for SQLite interop assembly... "
-
- if {[catch {
- object invoke -flags +NonPublic System.Data.SQLite.SQLite3 \
- InteropVersion} version] == 0} then {
- #
- # NOTE: Check if the returned version was null. If so, make it easy
- # to spot.
- #
- if {[string length $version] == 0} then {
- set version null
- }
-
- #
- # NOTE: Attempt to query the Fossil source identifier for the SQLite
- # core library.
- #
- if {[catch {
- object invoke -flags +NonPublic System.Data.SQLite.SQLite3 \
- InteropSourceId} sourceId]} then {
- #
- # NOTE: We failed to query the Fossil source identifier.
- #
- set sourceId unknown
- }
-
- #
- # NOTE: Check if the returned Fossil source identifier was null. If
- # so, make it easy to spot.
- #
- if {[string length $sourceId] == 0} then {
- set sourceId null
- }
-
- #
- # NOTE: Yes, the SQLite interop assembly appears to be available.
- #
- addConstraint SQLiteInterop
-
tputs $channel [appendArgs "yes (" $version " " $sourceId ")\n"]
} else {
tputs $channel no\n
}
}
@@ -980,32 +918,10 @@
#
return [expr {$fileName eq ":memory:" || \
[string range $fileName 0 12] eq "file::memory:"}]
}
- proc isTableInDb { name {varName db} } {
- #
- # NOTE: Refer to the specified variable (e.g. "db") in the context of our
- # caller. It contains the database connection handle that will be
- # used to execute the query used to determine if the named table is
- # present in that database.
- #
- upvar 1 $varName db
-
- #
- # NOTE: Execute the SQL query against the sqlite_master table to check if
- # the named table is present and return non-zero if it is.
- #
- return [expr {[sql execute -execute scalar $db \
- "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = ?;" \
- [list param1 String $name]] > 0}]
- }
-
- proc trimSql { sql } {
- return [regsub -all -- {\s+} [string trim $sql] " "]
- }
-
proc executeSql { sql {execute none} {fileName ""} } {
if {[string length $fileName] == 0} then {set fileName :memory:}
setupDb $fileName "" "" "" "" "" false false false false memDb
try {
@@ -1999,43 +1915,11 @@
if {[catch {object invoke -flags +NonPublic \
System.Data.SQLite.SQLite3 DefineConstants} \
defineConstants] == 0} then {
tputs $::test_channel [appendArgs [formatList [lsort \
- $defineConstants] ] \n]
- } else {
- tputs $::test_channel unknown\n
- }
- }
-
- catch {
- tputs $::test_channel \
- "---- source version of \"System.Data.SQLite.dll\"... "
-
- if {[catch {object invoke -flags +NonPublic \
- System.Data.SQLite.SQLiteConnection ProviderVersion} \
- version] == 0} then {
- if {[string length $version] == 0} then {
- set version null
- }
- tputs $::test_channel [appendArgs $version \n]
- } else {
- tputs $::test_channel unknown\n
- }
- }
-
- catch {
- tputs $::test_channel \
- "---- source checkout of \"System.Data.SQLite.dll\"... "
-
- if {[catch {object invoke -flags +NonPublic \
- System.Data.SQLite.SQLiteConnection ProviderSourceId} \
- sourceId] == 0} then {
- if {[string length $sourceId] == 0} then {
- set sourceId null
- }
- tputs $::test_channel [appendArgs $sourceId \n]
+ $defineConstants]] \n]
} else {
tputs $::test_channel unknown\n
}
}
@@ -2049,16 +1933,11 @@
# (i.e. because the managed-only System.Data.SQLite assembly can
# load without it; however, it cannot do anything useful without
# it). If we are using the mixed-mode assembly and we already
# found it (above), this should always succeed.
#
- checkForSQLiteLibrary $::test_channel
-
- #
- # NOTE: Check if the SQLite interop assembly is available.
- #
- checkForSQLiteInterop $::test_channel
+ checkForSQLite $::test_channel
#
# NOTE: Check the SQLite database and temporary directories.
#
checkForSQLiteDirectories $::test_channel
@@ -2144,11 +2023,11 @@
#
# NOTE: Show the active test constraints.
#
tputs $::test_channel [appendArgs "---- constraints: " \
- [formatList [lsort [getConstraints]] ] \n]
+ [formatList [lsort [getConstraints]]] \n]
#
# NOTE: Save the test constraints for use by threads created in this
# application domain. This is necessary because all the Eagle
# "test context" information is per-thread.
Index: Tests/installer.eagle
==================================================================
--- Tests/installer.eagle
+++ Tests/installer.eagle
@@ -152,11 +152,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2005 visualStudio2005\
-System.Data.SQLite.dll_v2.0.50727 file_Installer.exe testExec\
+System.Data.SQLite.dll_v2.0.50727 file_Installer.exe\
file_System.Data.SQLite.dll file_Installer_Test_Vs2005.log} -result {0 True}}
###############################################################################
runTest {test installer-1.2 {uninstaller tool / Visual Studio 2005} -setup {
@@ -189,11 +189,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2005 visualStudio2005\
-System.Data.SQLite.dll_v2.0.50727 file_Installer.exe testExec\
+System.Data.SQLite.dll_v2.0.50727 file_Installer.exe\
file_System.Data.SQLite.dll file_Uninstaller_Test_Vs2005.log} -result {0 True}}
###############################################################################
runTest {test installer-1.3 {installer tool / Visual Studio 2008} -setup {
@@ -226,11 +226,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2008 visualStudio2008\
-System.Data.SQLite.dll_v2.0.50727 file_Installer.exe testExec\
+System.Data.SQLite.dll_v2.0.50727 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Installer_Test_Vs2008.log} -result {0 True}}
###############################################################################
@@ -264,11 +264,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2008 visualStudio2008\
-System.Data.SQLite.dll_v2.0.50727 file_Installer.exe testExec\
+System.Data.SQLite.dll_v2.0.50727 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Uninstaller_Test_Vs2008.log} -result {0 True}}
###############################################################################
@@ -302,11 +302,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2010 visualStudio2010\
-System.Data.SQLite.dll_v4.0.30319 file_Installer.exe testExec\
+System.Data.SQLite.dll_v4.0.30319 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Installer_Test_Vs2010.log} -result {0 True}}
###############################################################################
@@ -340,11 +340,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2010 visualStudio2010\
-System.Data.SQLite.dll_v4.0.30319 file_Installer.exe testExec\
+System.Data.SQLite.dll_v4.0.30319 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Uninstaller_Test_Vs2010.log} -result {0 True}}
###############################################################################
@@ -378,11 +378,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2012 visualStudio2012\
-System.Data.SQLite.dll_v4.0.30319 file_Installer.exe testExec\
+System.Data.SQLite.dll_v4.0.30319 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Installer_Test_Vs2012.log} -result {0 True}}
###############################################################################
@@ -416,11 +416,11 @@
} -cleanup {
cleanupFile $fileName
unset -nocomplain wow64 is64 code output error fileName
} -constraints {eagle administrator buildYear.2012 visualStudio2012\
-System.Data.SQLite.dll_v4.0.30319 file_Installer.exe testExec\
+System.Data.SQLite.dll_v4.0.30319 file_Installer.exe\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll\
file_Uninstaller_Test_Vs2012.log} -result {0 True}}
###############################################################################
Index: Tests/stress.eagle
==================================================================
--- Tests/stress.eagle
+++ Tests/stress.eagle
@@ -1426,11 +1426,11 @@
unset -nocomplain result thread index workload priority noWorkload \
priorities srcDb db fileName compiled options count times logFileName \
logListener event timeout connection indicators iterations exitOnFail \
coTaskMem noTrace failures status
} -time true -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -result {0}}
+System.Data.SQLite} -result {0}}
###############################################################################
#
# NOTE: Report after test.
Index: Tests/thread.eagle
==================================================================
--- Tests/thread.eagle
+++ Tests/thread.eagle
@@ -456,11 +456,11 @@
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id db fileName
} -time true -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result [appendArgs "^Ok\
+System.Data.SQLite} -match regexp -result [appendArgs "^Ok\
System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} 0 \\{\\d+ \\d+ " $count(1) \
"\\} \\{\\} \\{" $handle_counts "\\} " $memory_used \$]}
###############################################################################
Index: Tests/tkt-00f86f9739.eagle
==================================================================
--- Tests/tkt-00f86f9739.eagle
+++ Tests/tkt-00f86f9739.eagle
@@ -81,11 +81,11 @@
set result
} -cleanup {
unset -nocomplain code output error result value
} -constraints \
{eagle monoToDo defineConstant.System.Data.SQLite.USE_INTEROP_DLL\
-defineConstant.System.Data.SQLite.INTEROP_EXTENSION_FUNCTIONS SQLite testExec\
+defineConstant.System.Data.SQLite.INTEROP_EXTENSION_FUNCTIONS SQLite\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll file_testlinq.exe\
file_northwindEF.db} -result {0 {} 0 {DRACD OLDWO RATTC} 0 {ALFKI CACTU CHOPS\
FOLKO GALED KOENE LILAS MAGAA MAISD OCEAN RANCH SAVEA THECR} 0 {} 0 {} 0 {} 0\
{}}}
Index: Tests/tkt-201128cc88.eagle
==================================================================
--- Tests/tkt-201128cc88.eagle
+++ Tests/tkt-201128cc88.eagle
@@ -92,13 +92,13 @@
[sql execute -execute scalar $db "SELECT Base64(CAST('foo' AS BLOB));"]
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}\
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}\
System#Data#SQLite#SQLiteConnection#\d+ \{\} \{\} Zm9v$}}
###############################################################################
runSQLiteTestEpilogue
Index: Tests/tkt-343d392b51.eagle
==================================================================
--- Tests/tkt-343d392b51.eagle
+++ Tests/tkt-343d392b51.eagle
@@ -188,13 +188,13 @@
cleanupDb $fileName; unset -nocomplain db fileName
cleanupDb $otherFileName
unset -nocomplain result code results errors i sql otherTable otherDbName \
otherDataSource dataSource id otherFileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match glob -result {*\
-System.Data.DBConcurrencyException: *}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+glob -result {* System.Data.DBConcurrencyException: *}}
###############################################################################
runTest {test tkt-343d392b51-2.2 {SQLiteDataAdapter update success} -setup {
setupDb [set fileName tkt-343d392b51-2.2.db] "" JulianDay
@@ -294,13 +294,13 @@
cleanupDb $fileName; unset -nocomplain db fileName
cleanupDb $otherFileName
unset -nocomplain result code results errors i sql otherTable otherDbName \
otherDataSource dataSource id otherFileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runTest {test tkt-343d392b51-3.1 {attached database, same table name} -setup {
setupDb [set fileName tkt-343d392b51-3.1.db]
@@ -430,13 +430,13 @@
cleanupDb $fileName; unset -nocomplain db fileName
cleanupDb $otherFileName
unset -nocomplain result code results errors i sql otherTable otherDbName \
otherDataSource dataSource id otherFileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-3aa50d8413.eagle
==================================================================
--- Tests/tkt-3aa50d8413.eagle
+++ Tests/tkt-3aa50d8413.eagle
@@ -74,13 +74,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-48a6b8e4ca.eagle
==================================================================
--- Tests/tkt-48a6b8e4ca.eagle
+++ Tests/tkt-48a6b8e4ca.eagle
@@ -76,13 +76,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-4a791e70ab.eagle
==================================================================
--- Tests/tkt-4a791e70ab.eagle
+++ Tests/tkt-4a791e70ab.eagle
@@ -69,13 +69,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-59edc1018b.eagle
==================================================================
--- Tests/tkt-59edc1018b.eagle
+++ Tests/tkt-59edc1018b.eagle
@@ -81,11 +81,11 @@
set result
} -cleanup {
unset -nocomplain code output error result value
} -constraints \
{eagle monoToDo defineConstant.System.Data.SQLite.USE_INTEROP_DLL\
-defineConstant.System.Data.SQLite.INTEROP_EXTENSION_FUNCTIONS SQLite testExec\
+defineConstant.System.Data.SQLite.INTEROP_EXTENSION_FUNCTIONS SQLite\
file_System.Data.SQLite.dll file_System.Data.SQLite.Linq.dll file_testlinq.exe\
file_northwindEF.db} -result {0 {} 0 {FURIB GALED GODOS LAZYK LINOD PRINI REGGC\
WOLZA} 0 {} 0 ERNSH 0 {} 0 {AROUT BSBEV CONSH EASTC NORTS SEVES} 0 {}}}
###############################################################################
Index: Tests/tkt-6434e23a0f.eagle
==================================================================
--- Tests/tkt-6434e23a0f.eagle
+++ Tests/tkt-6434e23a0f.eagle
@@ -74,13 +74,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-6c6ecccc5f.eagle
==================================================================
--- Tests/tkt-6c6ecccc5f.eagle
+++ Tests/tkt-6c6ecccc5f.eagle
@@ -69,13 +69,14 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result results errors code sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
+\{\}$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-72905c9a77.eagle
==================================================================
--- Tests/tkt-72905c9a77.eagle
+++ Tests/tkt-72905c9a77.eagle
@@ -272,12 +272,12 @@
cleanupDb $fileName
unset -nocomplain result code results errors dataSource fileName
} -constraints [fixConstraints {eagle monoBug28 configuration.Release\
!defineConstant.System.Data.SQLite.INTEROP_LOG command.sql compile.DATA\
-SQLite System.Data.SQLite compileCSharp}] -match regexp -result [appendArgs \
-"^Ok System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} 0 \\{" [string repeat \
+SQLite System.Data.SQLite}] -match regexp -result [appendArgs "^Ok\
+System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} 0 \\{" [string repeat \
"SQLite message \\(0\\): TEST $id
" [expr {4 * [info processors]}]] "\\}\$"]}
###############################################################################
Index: Tests/tkt-7e3fa93744.eagle
==================================================================
--- Tests/tkt-7e3fa93744.eagle
+++ Tests/tkt-7e3fa93744.eagle
@@ -126,13 +126,13 @@
} result] : [set result ""]}] $result
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id db fileName
-} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 8$}}
+} -constraints \
+{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 8$}}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: Tests/tkt-8b7d179c3c.eagle
==================================================================
--- Tests/tkt-8b7d179c3c.eagle
+++ Tests/tkt-8b7d179c3c.eagle
@@ -79,11 +79,11 @@
}
set result
} -cleanup {
unset -nocomplain code output error result pageSize
-} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
+} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-result {0 {} 0 {DRACD RATTC OLDWO GALED LILAS MAGAA ALFKI CHOPS SAVEA KOENE\
MAISD FOLKO CACTU OCEAN RANCH THECR GOURL GROSR SUPRD HUNGO ISLAT QUICK HUNGC\
GREAL LEHMS RICSU ERNSH WILMK LINOD TRAIH SIMOB OTTIK SPLIR MORGK FOLIG FURIB\
PRINI AROUT BSBEV CONSH EASTC NORTS SEVES BERGS VICTE BOLID FISSA ROMEY BLAUS\
Index: Tests/tkt-996d13cd87.eagle
==================================================================
--- Tests/tkt-996d13cd87.eagle
+++ Tests/tkt-996d13cd87.eagle
@@ -285,11 +285,11 @@
unset -nocomplain result results errors code sql dataSource id \
poolCounts havePoolCounts fileName
rename getPoolCounts ""
} -constraints {eagle monoBug28 command.sql compile.DATA\
-SQLite System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
+SQLite System.Data.SQLite} -match regexp -result {^Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \d+ \{\} True True$}}
}
###############################################################################
DELETED Tests/tkt-9ba9346f75.eagle
Index: Tests/tkt-9ba9346f75.eagle
==================================================================
--- Tests/tkt-9ba9346f75.eagle
+++ /dev/null
@@ -1,61 +0,0 @@
-###############################################################################
-#
-# tkt-9ba9346f75.eagle --
-#
-# Written by Joe Mistachkin.
-# Released to the public domain, use at your own risk!
-#
-###############################################################################
-
-package require Eagle
-package require Eagle.Library
-package require Eagle.Test
-
-runTestPrologue
-
-###############################################################################
-
-package require System.Data.SQLite.Test
-runSQLiteTestPrologue
-
-###############################################################################
-
-runTest {test tkt-9ba9346f75-1.1 {AutoCommit property} -setup {
- setupDb [set fileName tkt-9ba9346f75-1.1.db]
-} -body {
- set connection [getDbConnection]
-
- set result [list]
-
- lappend result [object invoke $connection AutoCommit]; # True
-
- sql execute $db "CREATE TABLE t1(x);"
- lappend result [object invoke $connection AutoCommit]; # True
-
- sql execute $db "INSERT INTO t1 (x) VALUES(1);"
- lappend result [object invoke $connection AutoCommit]; # True
-
- sql execute $db "BEGIN TRANSACTION;"
- lappend result [object invoke $connection AutoCommit]; # False
-
- sql execute $db "INSERT INTO t1 (x) VALUES(1);"
- lappend result [object invoke $connection AutoCommit]; # False
-
- sql execute $db "COMMIT;"
- lappend result [object invoke $connection AutoCommit]; # True
-
- set result
-} -cleanup {
- cleanupDb $fileName
-
- freeDbConnection
-
- unset -nocomplain result connection db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{True True True False False True}}
-
-###############################################################################
-
-runSQLiteTestEpilogue
-runTestEpilogue
Index: Tests/tkt-ae5267b863.eagle
==================================================================
--- Tests/tkt-ae5267b863.eagle
+++ Tests/tkt-ae5267b863.eagle
@@ -145,11 +145,11 @@
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id db fileName
} -constraints [fixConstraints {eagle monoBug28 command.sql compile.DATA\
-SQLite System.Data.SQLite !mda compileCSharp\
+SQLite System.Data.SQLite !mda\
!defineConstant.System.Data.SQLite.INTEROP_LEGACY_CLOSE}] -match regexp \
-result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
Index: Tests/tkt-ccfa69fc32.eagle
==================================================================
--- Tests/tkt-ccfa69fc32.eagle
+++ Tests/tkt-ccfa69fc32.eagle
@@ -79,11 +79,11 @@
}
set result
} -cleanup {
unset -nocomplain code output error result add
-} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
+} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} -match \
glob -result {0 {1581 1730 1833 2116 2139} 0 {System.Data.UpdateException: *\
---> System.Data.SQLite.SQLiteException: constraint failed
PRIMARY KEY must be unique
*} 0 {1 2 3 4 5 6 7 8 9 10 1576 1577 1578 1579 1580 1581 1730 1833 2116 2139}}}
Index: Tests/tkt-e06c4caff3.eagle
==================================================================
--- Tests/tkt-e06c4caff3.eagle
+++ Tests/tkt-e06c4caff3.eagle
@@ -31,11 +31,11 @@
cleanupDb $fileName
unset -nocomplain NaN db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
--returnCodes 1 -match regexp -result [string map [list \n \r\n] \
+-returnCodes 1 -match regexp -result [string map [list \n \r\n]\
{^System\.Data\.SQLite\.SQLiteException \(0x80004005\): constraint failed
t1\.x may not be NULL
.*$}]}
###############################################################################
Index: Tests/tkt-e1b2e0f769.eagle
==================================================================
--- Tests/tkt-e1b2e0f769.eagle
+++ Tests/tkt-e1b2e0f769.eagle
@@ -121,14 +121,14 @@
} -cleanup {
cleanupDb $fileName
unset -nocomplain result2 result1 code results errors sql table dataSource \
id x db fileName
-} -constraints [fixConstraints {eagle monoBug28 command.sql compile.DATA SQLite\
-!defineConstant.System.Data.SQLite.CHECK_STATE System.Data.SQLite\
-compileCSharp}] -match regexp -result {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 3 Ok\
+} -constraints \
+[fixConstraints {eagle monoBug28 command.sql compile.DATA SQLite\
+!defineConstant.System.Data.SQLite.CHECK_STATE System.Data.SQLite}] -match \
+regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 3 Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 0$}}
###############################################################################
runSQLiteTestEpilogue
Index: Tests/tkt-e30b820248.eagle
==================================================================
--- Tests/tkt-e30b820248.eagle
+++ Tests/tkt-e30b820248.eagle
@@ -106,12 +106,13 @@
[reportSQLiteResources $test_channel true]
} -cleanup {
cleanupDb $fileName
unset -nocomplain result code results errors sql name dataSource id fileName
-} -constraints {eagle logFile monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result [appendArgs "^Ok\
+} -constraints \
+{eagle logFile monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
+-match regexp -result [appendArgs "^Ok\
System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} 0 \\{\\} " $memory_used \$]}
###############################################################################
for {set i 2} {$i < 5} {incr i} {
@@ -260,11 +261,11 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql name dataSource id \
fileName
} -constraints {eagle logFile monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite compileCSharp} -match regexp -result [appendArgs "^Ok\
+System.Data.SQLite} -match regexp -result [appendArgs "^Ok\
System#CodeDom#Compiler#CompilerResults#\\d+ \\{\\} 0 \\{\\} " $memory_used \$]}
}
###############################################################################
DELETED Tests/tkt-f8dbab8baf.eagle
Index: Tests/tkt-f8dbab8baf.eagle
==================================================================
--- Tests/tkt-f8dbab8baf.eagle
+++ /dev/null
@@ -1,143 +0,0 @@
-###############################################################################
-#
-# tkt-f8dbab8baf.eagle --
-#
-# Written by Joe Mistachkin.
-# Released to the public domain, use at your own risk!
-#
-###############################################################################
-
-package require Eagle
-package require Eagle.Library
-package require Eagle.Test
-
-runTestPrologue
-
-###############################################################################
-
-package require System.Data.SQLite.Test
-runSQLiteTestPrologue
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.1 {SchemaOnly with CREATE TABLE} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.1.db]
-} -body {
- sql execute -execute reader -format none -behavior SchemaOnly $db \
- "CREATE TABLE t1(x);"
-
- isTableInDb t1
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{False}}
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.2 {SchemaOnly with ALTER TABLE} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.2.db]
-} -body {
- sql execute $db "CREATE TABLE t1(x);"
-
- sql execute -execute reader -format none -behavior SchemaOnly $db \
- "ALTER TABLE t1 RENAME TO t2;"
-
- list [isTableInDb t1] [isTableInDb t2]
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{True False}}
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.3 {SchemaOnly with DROP TABLE} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.3.db]
-} -body {
- sql execute $db "CREATE TABLE t1(x);"
-
- sql execute -execute reader -format none -behavior SchemaOnly $db \
- "DROP TABLE t1;"
-
- isTableInDb t1
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{True}}
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.4 {CREATE/SELECT success} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.4.db]
-} -body {
- sql execute -execute reader $db {
- CREATE TABLE t1(x);
- INSERT INTO t1 (x) VALUEs(1);
- SELECT x FROM t1;
- }
-
- list [isTableInDb t1] \
- [expr {[info exists rows(count)] ? $rows(count) : -1}] \
- [expr {[info exists rows(names)] ? $rows(names) : ""}]
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain rows db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{True 1 x}}
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.5 {SchemaOnly CREATE/SELECT success} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.5.db]
-} -body {
- sql execute $db "CREATE TABLE t1(x);"
- sql execute $db "INSERT INTO t1 (x) VALUEs(1);"
- sql execute -execute reader -behavior SchemaOnly $db "SELECT x FROM t1;"
-
- list [isTableInDb t1] \
- [expr {[info exists rows(count)] ? $rows(count) : -1}] \
- [expr {[info exists rows(names)] ? $rows(names) : ""}]
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain rows db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
-{True 0 x}}
-
-###############################################################################
-
-runTest {test tkt-f8dbab8baf-1.6 {SchemaOnly CREATE/SELECT failure} -setup {
- setupDb [set fileName tkt-f8dbab8baf-1.6.db]
-} -body {
- sql execute -execute reader -format none -behavior SchemaOnly $db \
- "CREATE TABLE t1(x); SELECT x FROM t1;"
-
- list [isTableInDb t1] \
- [expr {[info exists rows(count)] ? $rows(count) : -1}] \
- [expr {[info exists rows(names)] ? $rows(names) : ""}]
-} -cleanup {
- cleanupDb $fileName
-
- unset -nocomplain rows db fileName
-} -constraints \
-{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
--returnCodes 1 -match regexp -result [string map [list \n \r\n] \
-{^System\.Data\.SQLite\.SQLiteException \(0x80004005\): SQL logic error or\
-missing database
-no such table: t1.*$}]}
-
-###############################################################################
-
-runSQLiteTestEpilogue
-runTestEpilogue
Index: Tests/version.eagle
==================================================================
--- Tests/version.eagle
+++ Tests/version.eagle
@@ -166,50 +166,10 @@
unset -nocomplain assemblyName
} -constraints {eagle file_testlinq.exe} -result $version(full)}
###############################################################################
-runTest {test version-1.11 {SQLiteVersion} -body {
- object invoke System.Data.SQLite.SQLiteConnection SQLiteVersion
-} -constraints {eagle SQLite System.Data.SQLite} -match regexp -result \
-{^\d+\.\d+\.\d+(?:\.\d+)?$}}
-
-###############################################################################
-
-runTest {test version-1.12 {SQLiteSourceId} -body {
- object invoke System.Data.SQLite.SQLiteConnection SQLiteSourceId
-} -constraints {eagle SQLite System.Data.SQLite} -match regexp -result \
-{^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [0-9a-f]{40}$}}
-
-###############################################################################
-
-runTest {test version-1.13 {InteropVersion} -body {
- object invoke System.Data.SQLite.SQLiteConnection InteropVersion
-} -constraints {eagle SQLiteInterop System.Data.SQLite} -result $version(full)}
-
-###############################################################################
-
-runTest {test version-1.14 {InteropSourceId} -body {
- object invoke System.Data.SQLite.SQLiteConnection InteropSourceId
-} -constraints {eagle SQLiteInterop System.Data.SQLite} -match regexp -result \
-{^[0-9a-f]{40} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC$}}
-
-###############################################################################
-
-runTest {test version-1.15 {ProviderVersion} -body {
- object invoke System.Data.SQLite.SQLiteConnection ProviderVersion
-} -constraints {eagle System.Data.SQLite} -result $version(full)}
-
-###############################################################################
-
-runTest {test version-1.16 {ProviderSourceId} -body {
- object invoke System.Data.SQLite.SQLiteConnection ProviderSourceId
-} -constraints {eagle System.Data.SQLite} -match regexp -result \
-{^[0-9a-f]{40} \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC$}}
-
-###############################################################################
-
set patterns [list \
[appendArgs Version= [string map [list . \\.] $version(full)] ,] \
[appendArgs [string map [list . \\.] $version(full)] \
] \
[appendArgs [string map [list . \\.] $version(full)] \
@@ -330,11 +290,11 @@
if {![haveConstraint [appendArgs file_ $constraint]]} then {
checkForFile $test_channel $fileName $constraint
}
- runTest {test [appendArgs version-1.17. $i] \
+ runTest {test [appendArgs version-1.11. $i] \
[appendArgs "pattern {" $pattern "} in file \"" $fileName \"] -body {
regexp -- $pattern [readFile $fileName]
} -constraints [list eagle [appendArgs file_ $constraint]] -result {1}}
}
Index: Tests/vtab.eagle
==================================================================
--- Tests/vtab.eagle
+++ Tests/vtab.eagle
@@ -101,12 +101,12 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+{^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
###############################################################################
runTest {test vtab-1.2.1 {IEnumerable virtual table} -setup {
set fileName vtab-1.2.1.db
@@ -206,14 +206,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{one two three 4 5\.0 Error\
-\{SQL logic error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{one two three 4 5\.0 Error \{SQL logic error or missing database
virtual table "t\d+" is read-only\}\}$}]}
###############################################################################
runTest {test vtab-1.2.2 {IEnumerable virtual table} -setup {
@@ -317,14 +316,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{one two three 4 5\.0 Error\
-\{SQL logic error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{one two three 4 5\.0 Error \{SQL logic error or missing database
virtual table "t\d+" is read-only\}\}$}]}
###############################################################################
runTest {test vtab-1.3.1 {IEnumerable virtual table} -setup {
@@ -426,14 +424,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{1 2 3 4 5 Error \{SQL\
-logic error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{1 2 3 4 5 Error \{SQL logic error or missing database
virtual table "t\d+" is read-only\}\}$}]}
###############################################################################
runTest {test vtab-1.3.2 {IEnumerable virtual table} -setup {
@@ -538,14 +535,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{1 2 3 4 5 Error \{SQL\
-logic error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{1 2 3 4 5 Error \{SQL logic error or missing database
virtual table "t\d+" is read-only\}\}$}]}
###############################################################################
runTest {test vtab-1.4 {virtual table function support} -setup {
@@ -790,14 +786,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\{\} b25l \{SQL logic\
-error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{\{\} b25l \{SQL logic error or missing database
unable to use function Base64 in the requested context\} \{SQL logic error or\
missing database
no such function: Base65\}\}$}]}
###############################################################################
@@ -1044,14 +1039,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\{\} b25l \{SQL logic\
-error or missing database
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{\{\} b25l \{SQL logic error or missing database
(?:unable to use function Base64 in the requested context|need exactly one\
argument, got 3)\} \{SQL logic error or missing database
no such function: Base65\}\}$}]}
###############################################################################
@@ -1224,13 +1218,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\{\} t\d+ \{\} x\d+\}$}]}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{\{\} t\d+ \{\} x\d+\}$}]}
###############################################################################
runTest {test vtab-1.7 {virtual table xBestIndex marshalling (1)} -setup {
set fileName vtab-1.7.db
@@ -1324,14 +1318,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{0 5 two three one 5\.0\
-4\}$}]}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{0 5 two three one 5\.0 4\}$}]}
###############################################################################
runTest {test vtab-1.8 {virtual table xBestIndex marshalling (2)} -setup {
set fileName vtab-1.8.db
@@ -1426,13 +1419,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{0 5 one three\}$}]}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{0 5 one three\}$}]}
###############################################################################
runTest {test vtab-1.9 {IEnumerable virtual table w/large byte array} -setup {
set fileName vtab-1.9.db
@@ -1504,13 +1497,13 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -time true -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 (?:-)?\d+$}]}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 (?:-)?\d+$}]}
###############################################################################
runTest {test vtab-1.10 {virtual table xRowId uniqueness} -setup {
set fileName vtab-1.10.db
@@ -1601,15 +1594,14 @@
cleanupDb $fileName
unset -nocomplain result code results errors sql dataSource id fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
-defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE compileCSharp} -match \
-regexp -result [string map [list \n \r\n] {^Ok\
-System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{0 4294967296 4294967296\
-8589934592 8589934592 12884901888 12884901888 17179869184 17179869184\
-21474836480 21474836480 25769803776 25769803776\}$}]}
+defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
+[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
+\{\} 0 \{0 4294967296 4294967296 8589934592 8589934592 12884901888 12884901888\
+17179869184 17179869184 21474836480 21474836480 25769803776 25769803776\}$}]}
###############################################################################
runSQLiteTestEpilogue
runTestEpilogue
Index: exclude_src.txt
==================================================================
--- exclude_src.txt
+++ exclude_src.txt
@@ -16,20 +16,17 @@
Externals/Eagle/bin/Eagle.dll
Externals/Eagle/bin/EagleShell.exe
Externals/Eagle/bin/SQLite.Interop.*
Externals/Eagle/bin/sqlite3.*
Externals/Eagle/bin/System.*
-Externals/Eagle/bin/x64/*
-Externals/Eagle/bin/x86/*
Externals/Eagle/lib/Eagle1.0/embed.eagle
Externals/Eagle/lib/Eagle1.0/init.eagle
Externals/Eagle/lib/Eagle1.0/pkgIndex.eagle
Externals/Eagle/lib/Eagle1.0/pkgIndex.tcl
Externals/Eagle/lib/Eagle1.0/safe.eagle
Externals/Eagle/lib/Eagle1.0/shell.eagle
Externals/Eagle/lib/Eagle1.0/test.eagle
-Externals/Eagle/lib/Eagle1.0/word.tcl
Externals/Eagle/lib/Test1.0/constraints.eagle
Externals/Eagle/lib/Test1.0/epilogue.eagle
Externals/Eagle/lib/Test1.0/pkgIndex.eagle
Externals/Eagle/lib/Test1.0/pkgIndex.tcl
Externals/Eagle/lib/Test1.0/prologue.eagle
Index: readme.htm
==================================================================
--- readme.htm
+++ readme.htm
@@ -3,11 +3,11 @@
ADO.NET SQLite Data Provider
-Version 1.0.89.0 October XX, 2013 (release scheduled)
+Version 1.0.89.0 September XX, 2013 (release scheduled)
Using SQLite 3.8.1
Originally written by Robert Simpson
Released to the public domain, use at your own risk!
Official provider website: http://system.data.sqlite.org/
Legacy versions: http://sqlite.phxsoftware.com/
@@ -185,25 +185,20 @@
Version History
- 1.0.89.0 - October XX, 2013 (release scheduled)
+ 1.0.89.0 - September XX, 2013 (release scheduled)
- Updated to SQLite 3.8.1 .
- Add AutoCommit property to the SQLiteConnection class. Fix for [9ba9346f75].
+ Updated to SQLite 3.8.1 .
Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605].
Check the result of sqlite3_column_name function against NULL.
Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.
Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801].
- Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.
Revise how the extra object data is passed to the static SQLiteConnection.Changed event. ** Potentially Incompatible Change **
- Make sure the database cannot be changed by a query when the CommandBehavior.SchemaOnly flag is used. Fix for [f8dbab8baf]. ** Potentially Incompatible Change **
Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6].
- Add InteropVersion, InteropSourceId, ProviderVersion, and ProviderSourceId properties to the SQLiteConnection class.
- Add experimental support for interfacing with the authorizer callback in the SQLite core library.
1.0.88.0 - August 7, 2013
Index: www/news.wiki
==================================================================
--- www/news.wiki
+++ www/news.wiki
@@ -1,25 +1,20 @@
News
Version History
- 1.0.89.0 - October XX, 2013 (release scheduled)
+ 1.0.89.0 - September XX, 2013 (release scheduled)
- Updated to [http://www.sqlite.org/releaselog/3_8_1.html|SQLite 3.8.1].
- Add AutoCommit property to the SQLiteConnection class. Fix for [9ba9346f75].
+ Updated to [http://www.sqlite.org/src/info/trunk|SQLite 3.8.1].
Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605].
Check the result of sqlite3_column_name function against NULL.
Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.
Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801].
- Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.
Revise how the extra object data is passed to the static SQLiteConnection.Changed event. ** Potentially Incompatible Change **
- Make sure the database cannot be changed by a query when the CommandBehavior.SchemaOnly flag is used. Fix for [f8dbab8baf]. ** Potentially Incompatible Change **
Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6].
- Add InteropVersion, InteropSourceId, ProviderVersion, and ProviderSourceId properties to the SQLiteConnection class.
- Add experimental support for interfacing with the authorizer callback in the SQLite core library.
1.0.88.0 - August 7, 2013